<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>getopts_long.sh</filename>
    </added>
    <added>
      <filename>test/unit/test-dbg-opts.sh.in</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1 +1,8 @@
 R. Bernstein (rocky@gnu.org)
+
+Kate Ward is the author of shunit2 used in unit testing
+
+St&#233;phane Chazelas is the author of getopts_long.sh for GNU long options 
+         processing 
+
+Nikolaj Schumacher is the author of elk-test.el used in GNU Emacs testing</diff>
      <filename>AUTHORS</filename>
    </modified>
    <modified>
      <diff>@@ -30,7 +30,7 @@ pkgdata_DATA =       \
 # Set up the install target 
 bin_SCRIPTS = zshdb
 
-EXTRA_DIST = $(pkgdata_DATA) THANKS getopt-test.sh
+EXTRA_DIST = $(pkgdata_DATA) THANKS getopts_long.sh
 
 # cvs2cl
 MAINTAINERCLEANFILES = ChangeLog</diff>
      <filename>Makefile.am</filename>
    </modified>
    <modified>
      <diff>@@ -1,2 +1,6 @@
 Thanks to Peter Stephenson for the adding necessary support to zsh
 needed to get this off the ground and make debugging possible.
+
+Thanks to Kate Ward, St&#233;phane Chazelas and Nikolaj Schumacher for
+programs used in conjunction with zshdb.
+</diff>
      <filename>THANKS</filename>
    </modified>
    <modified>
      <diff>@@ -103,6 +103,8 @@ AC_CONFIG_FILES([test/example/hanoi.sh],
 AC_CONFIG_FILES([test/unit/test-alias.sh], [chmod +x test/unit/test-alias.sh])
 AC_CONFIG_FILES([test/unit/test-columns.sh], 
                 [chmod +x test/unit/test-columns.sh])
+AC_CONFIG_FILES([test/unit/test-dbg-opts.sh], 
+                [chmod +x test/unit/test-dbg-opts.sh])
 AC_CONFIG_FILES([test/unit/test-file.sh],
 	        [chmod +x test/unit/test-file.sh])
 AC_CONFIG_FILES([test/unit/test-filecache.sh],</diff>
      <filename>configure.ac</filename>
    </modified>
    <modified>
      <diff>@@ -6,7 +6,7 @@
 #   Software Foundation; either version 2, or (at your option) any later
 #   version.
 #
-#   kshd is distributed in the hope that it will be useful, but WITHOUT ANY
+#   zshdb is distributed in the hope that it will be useful, but WITHOUT ANY
 #   WARRANTY; without even the implied warranty of MERCHANTABILITY or
 #   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 #   for more details.</diff>
      <filename>dbg-main.sh</filename>
    </modified>
    <modified>
      <diff>@@ -31,69 +31,124 @@ options:
                             (Needed in regression tests)
     -L libdir | --library libdir
                             Set the directory location of library helper file: $_Dbg_main
-    -n | --nx |--no-init    Don't run initialization files.
+    -n | --nx | --no-init   Don't run initialization files.
     -V | --version          Print the debugger version number.
     -x command | --command CMDFILE
                             Execute debugger commands from CMDFILE.
-&quot;
+&quot; &gt;&amp;2
   exit 100
 }
 
 _Dbg_show_version() {
   printf 'There is absolutely no warranty for zshdb.  Type &quot;show warranty&quot; for details.
-'
+' &gt;&amp;2
   exit 101
+
 }
 
+# Script arguments before adulteration by _Dbg_parse_otps
+typeset -a _Dbg_orig_script_args
+_Dbg_orig_script_args=($@)
+
+
+# The following globals are set by _Dbg_parse_opts. Any values set are 
+# the default values.
+typeset -a _Dbg_script_args
+
 typeset -i _Dbg_annotate=0
 typeset -i _Dbg_linetrace=0
+typeset -i _Dbg_basename_only=0
+typeset -i _Dbg_o_nx=0
+
+
+_Dbg_parse_options() {
+
+    . ${_Dbg_libdir}/getopts_long.sh
+
+    typeset -i _Dbg_o_quiet=0
+    typeset -i _Dbg_o_version=0
 
-# Debugger command file
-typeset _Dbg_o_cmdfile='' _Dbg_o_nx='' _Dbg_o_basename='' _Dbg_o_quiet=''
-
-local temp
-zparseopts -D --                                       \
-  A:=_Dbg_o_annotate  -annotate:=_Dbg_o_annotate       \
-  B=_Dbg_o_basename   -basename=_Dbg_o_basename        \
-  L:=temp             -library:=temp                   \
-  V=_Dbg_o_version    -version=_Dbg_o_version          \
-  h=_Dbg_o_help       -help=_Dbg_o_help                \
-  n=_Dbg_o_nx         -nx=_Dbg_o_nx -no-init=_Dbg_o_nx \
-  q=_Dbg_o_quiet      -quiet=_Dbg_o_quiet              \
-  x:=_Dbg_o_cmdfile   -command:=_Dbg_o_cmdfile
-                
-[[ $? != 0 || &quot;$_Dbg_o_help&quot; != '' ]] &amp;&amp; _Dbg_usage
-
-if [[ -z $_Dbg_o_quiet || -n $_Dbg_o_version ]]; then 
-  print &quot;Zsh Shell Debugger, release $_Dbg_release&quot;
-  printf '
+    while getopts_long A:Bx:hL:nqV opt   \
+	annotate required_argument       \
+	basename 0                       \
+	cmdfile  required_argument       \
+    	help     0                       \
+	'?'      0                       \
+	library  required_argument       \
+	no-init  0                       \
+	nx       0                       \
+	quiet    0                       \
+	version  0                       \
+	'' &quot;$@&quot;
+    do
+	case &quot;$opt&quot; in 
+	    A | annotate ) 
+		_Dbg_o_annotate=$OPTLARG
+		;;
+	    B | basename )
+		_Dbg_basename_only=1
+		;;
+	    x | command )
+		DBG_INPUT=$OPTLARG
+		;;
+	    h | '?' | help )
+		_Dbg_usage
+		;;
+	    L | library ) 
+		;;
+	    V | version )
+		_Dbg_o_version=1
+		;;
+	    n | nx | no-init )
+		_Dbg_o_nx=1
+		;;
+	    q | quiet )
+		_Dbg_o_quiet=1
+		;;
+	    * ) 
+		print &quot;Unknown option $opt. Use -h or --help to see options&quot; &gt;&amp;2
+		exit 2
+		;;
+	esac
+    done	
+    shift &quot;$(($OPTLIND - 1))&quot;
+    
+    if (( ! _Dbg_o_quiet &amp;&amp; ! _Dbg_o_version )); then 
+	print &quot;Zsh Shell Debugger, release $_Dbg_release&quot;
+	printf '
 Copyright 2008 Rocky Bernstein
 This is free software, covered by the GNU General Public License, and you are
 welcome to change it and/or distribute copies of it under certain conditions.
 
 '
-fi
-[[ -n &quot;$_Dbg_o_version&quot; ]] &amp;&amp; _Dbg_show_version
-[[ -n &quot;$_Dbg_o_basename&quot; ]] &amp;&amp; _Dbg_basename_only=1
-[[ -n &quot;$_Dbg_o_cmdfile&quot; ]] &amp;&amp; {
-    typeset -a _Dbg_input
-    _Dbg_input=($_Dbg_o_cmdfile)
-    DBG_INPUT=${_Dbg_input[-1]}
-    unset _Dbg_input
-}
-
+    fi
+    (( _Dbg_o_version )) &amp;&amp; _Dbg_show_version
 
-# FIXME: check that _Dbg_o_annotate is an integer
-if [[ -n $_Dbg_o_annotate ]] ; then
-    typeset -a level; eval &quot;level=($_Dbg_o_annotate)&quot;
-    if [[ ${level[-1]} == [0-9]* ]] ; then
-	if (( ${level[-1]} &gt; 3 || ${level[-1]} &lt; 0)); then
-	    print &quot;Annotation level must be less between 0 and 3. Got: ${level[-1]}.&quot;
+    if [[ -n $_Dbg_o_annotate ]] ; then
+	if [[ ${_Dbg_o_annotate} == [0-9]* ]] ; then
+	    _Dbg_annotate=$_Dbg_o_annotate
+	    if (( _Dbg_annotate &gt; 3 || _Dbg_annotate &lt; 0)); then
+		print &quot;Annotation level must be less between 0 and 3. Got: $_Dbg_annotate.&quot; &gt;&amp;2
+		print &quot;Setting Annotation level to 0.&quot; &gt;&amp;2
+		_Dbg_annotate=0
+	    fi
 	else
-	    _Dbg_annotate=${level[-1]}
+	    print &quot;Annotate option should be an integer, got ${_Dbg_o_annotate}.&quot; &gt;&amp;2
+	    print &quot;Setting annotation level to 0.&quot; &gt;&amp;2
 	fi
-    else
-	print &quot;Annotate option should be an integer, got ${level[-1]}.&quot;
     fi
+    unset _Dbg_o_annotate _Dbg_o_version _Dbg_o_quiet
+    _Dbg_script_args=($@)
+}
+
+[[ -n $DBG_INPUT ]] &amp;&amp; typeset -p DBG_INPUT
+
+
+# Stand-alone Testing. 
+if [[ -n &quot;$_Dbg_dbg_opts_test&quot; ]] ; then
+    _Dbg_libdir='.'
+    _Dbg_parse_options &quot;$@&quot;
+    typeset -p _Dbg_annotate
+    typeset -p _Dbg_linetrace
+    typeset -p _Dbg_basename_only
 fi
-unset _Dbg_o_annotate _Dbg_o_version _Dbg_o_basename _Dbg_o_cmdfile</diff>
      <filename>dbg-opts.sh</filename>
    </modified>
    <modified>
      <diff>@@ -44,8 +44,6 @@ typeset -r _Dbg_release='0.01git'
 # Will be set to 1 if the top-level call is a debugger.
 typeset -i _Dbg_script=0
 
-typeset -i _Dbg_basename_only=0
-
 # Expand filename given as $1.
 # we echo the expanded name or return $1 unchanged if a bad filename.
 # Return is 0 if good or 1 if bad.
@@ -97,6 +95,8 @@ _Dbg_tempname() {
 
 # Process command-line options
 . ${_Dbg_libdir}/dbg-opts.sh
+OPTLIND=1
+_Dbg_parse_options &quot;$@&quot;
 
 if [[ ! -d $_Dbg_tmpdir ]] &amp;&amp; [[ ! -w $_Dbg_tmpdir ]] ; then
   echo &quot;${_Dbg_pname}: cannot write to temp directory $_Dbg_tmpdir.&quot; &gt;&amp;2
@@ -114,9 +114,6 @@ typeset _Dbg_init_cwd=$PWD
 #   fi
 # fi
 
-typeset -a _Dbg_script_args
-_Dbg_script_args=($@)
-
 typeset -i _Dbg_running=1      # True we are not finished running the program
 
 typeset -i _Dbg_currentbp=0    # If nonzero, the breakpoint number that we </diff>
      <filename>dbg-pre.sh</filename>
    </modified>
    <modified>
      <diff>@@ -4,6 +4,7 @@
 /Makefile.in
 /test-alias.sh
 /test-columns.sh
+/test-dbg-opts.sh
 /test-file.sh
 /test-filecache.sh
 /test-fns.sh</diff>
      <filename>test/unit/.gitignore</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,6 @@
 TESTS = test-alias.sh        \
 	test-columns.sh      \
+	test-dbg-opts.sh     \
 	test-file.sh         \
 	test-filecache.sh    \
 	test-fns.sh          \
@@ -19,7 +20,8 @@ TESTS_ENVIRONMENT = \
 
 EXTRA_DIST = $(TESTS) $(check_DATA) \
 	test-alias.sh.in            \
-	test-columns.sh             \
+	test-columns.sh.in          \
+	test-dbg-opts.sh.in         \
 	test-file.sh.in             \
 	test-filecache.sh.in        \
 	test-fns.sh.in              \</diff>
      <filename>test/unit/Makefile.am</filename>
    </modified>
    <modified>
      <diff>@@ -64,7 +64,7 @@ for shunit_const_ in ${shunit_constants_}; do
       *) shunit_ro_opts_='-g' ;;  # declare readonly constants globally
     esac
   fi
-  readonly ${shunit_ro_opts_} ${shunit_const_}
+  # readonly ${shunit_ro_opts_} ${shunit_const_}
 done
 unset shunit_const_ shunit_constants_ shunit_ro_opts_
 
@@ -380,7 +380,7 @@ assertTrue()
 
   [ -z &quot;${shunit_message_:-}&quot; ] &amp;&amp; shunit_message_=''
   if [ $# -eq 2 ]; then
-    shunit_message_=&quot;${shunit_message_}$1&quot;
+    shunit_message_=&quot;$1&quot;
     shift
   fi
   shunit_condition_=$1
@@ -450,7 +450,7 @@ assertFalse()
 
   [ -z &quot;${shunit_message_:-}&quot; ] &amp;&amp; shunit_message_=''
   if [ $# -eq 2 ]; then
-    shunit_message_=&quot;${shunit_message_}$1&quot;
+    shunit_message_=&quot;$1&quot;
     shift
   fi
   shunit_condition_=$1
@@ -513,7 +513,7 @@ fail()
 
   [ -z &quot;${shunit_message_:-}&quot; ] &amp;&amp; shunit_message_=''
   if [ $# -eq 1 ]; then
-    shunit_message_=&quot;${shunit_message_}$1&quot;
+    shunit_message_=&quot;$1&quot;
     shift
   fi
 </diff>
      <filename>test/unit/shunit2</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,5 @@
 #!@SH_PROG@
 # -*- shell-script -*-
-
 PS4='(%x:%I): [%?] zsh+ 
 '
 setopt ksharrays
@@ -42,12 +41,12 @@ test_columnized()
 
 }
 
-# Make sure @top_builddir@ has a trailing slash
 if [ '@abs_top_srcdir@' = '' ] ; then
   echo &quot;Something is wrong abs_top_srcdir is not set.&quot;
  exit 1
 fi
 abs_top_srcdir=@abs_top_srcdir@
+# Make sure @top_srcdir@ has a trailing slash
 abs_top_srcdir=${abs_top_srcdir%%/}/
 
 . $abs_top_srcdir/lib/columns.sh</diff>
      <filename>test/unit/test-columns.sh.in</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>getopt-test.sh</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>26d332133359e55d9c52facab7cbd52bf44b6c38</id>
    </parent>
  </parents>
  <author>
    <name>R. Bernstein</name>
    <email>rocky@gnu.org</email>
  </author>
  <url>http://github.com/rocky/zshdb/commit/33ef07385c1e6afe1389790419b3117bc7ca4b48</url>
  <id>33ef07385c1e6afe1389790419b3117bc7ca4b48</id>
  <committed-date>2008-09-29T19:27:07-07:00</committed-date>
  <authored-date>2008-09-29T19:27:07-07:00</authored-date>
  <message>Convert options processing to getopts_long by St&#233;phane Chazelas. Thanks St&#233;phane!</message>
  <tree>ca25bf32e98f3a22d7e5faaeff5ef6be4efdc028</tree>
  <committer>
    <name>R. Bernstein</name>
    <email>rocky@gnu.org</email>
  </committer>
</commit>
