home *** CD-ROM | disk | FTP | other *** search
- *** patchlevel.h.parseargs_patch12 Sat May 30 18:10:20 1992
- --- patchlevel.h Sat May 30 17:46:52 1992
- ***************
- *** 3,8 ****
- --- 3,13 ----
- **
- ** ^HISTORY:
- **
- + ** 05/30/92 Brad Appleton <brad@ssd.csd.harris.com>
- + ** Patch13
- + ** - Finishing touches to get parseargs working successfully with
- + ** the tcl shell (parseargs.tcl works now).
- + **
- ** 05/18/92 Brad Appleton <brad@ssd.csd.harris.com>
- ** Patch12
- ** - Fixes to the Makefile and for tcl.
- ***************
- *** 161,167 ****
-
- #define VERSION 2
- #define REVISION 0
- ! #define PATCHLEVEL 12
-
- #ifdef __STDC__
- static const char
- --- 166,172 ----
-
- #define VERSION 2
- #define REVISION 0
- ! #define PATCHLEVEL 13
-
- #ifdef __STDC__
- static const char
- ***************
- *** 168,171 ****
- #else
- static char
- #endif
- ! _Ident[] = "@(#)parseargs 2.0 patchlevel 12";
- --- 173,176 ----
- #else
- static char
- #endif
- ! _Ident[] = "@(#)parseargs 2.0 patchlevel 13";
- *** Makefile.parseargs_patch12 Sat May 30 18:10:17 1992
- --- Makefile Sat May 30 17:46:42 1992
- ***************
- *** 23,28 ****
- --- 23,29 ----
- LIBDIR = ${LOCAL}/lib
- INCDIR = ${LOCAL}/include
- PERLLIB = ${LIBDIR}/perl
- + TCLLIB = ${LIBDIR}/tcl
-
- ###
- # compilation options
- ***************
- *** 99,106 ****
- doc/sparseargs3.inc \
- doc/usage3.inc \
- doc/vparseargs3.inc
- ! SCRIPTS = test.sh test.csh test.ksh test.rc test.awk test.pl
- PERLSUB = ${NAME}.pl
- XXFILES = Intro README MANIFEST Makefile VMSbuild.com
-
- HDRS = ${NAME}.h \
- --- 100,108 ----
- doc/sparseargs3.inc \
- doc/usage3.inc \
- doc/vparseargs3.inc
- ! SCRIPTS = test.sh test.csh test.ksh test.rc test.awk test.pl test.tcl
- PERLSUB = ${NAME}.pl
- + TCLSUB = ${NAME}.tcl
- XXFILES = Intro README MANIFEST Makefile VMSbuild.com
-
- HDRS = ${NAME}.h \
- ***************
- *** 138,144 ****
- PROG_OBJS = ${NAME}.o unix_man.o
- TEST_OBJS = stest.o
-
- ! FILES = ${XXFILES} ${DOCS} ${HDRS} ${SRCS} ${PERLSUB} ${SCRIPTS}
-
- ###
- # target dependencies
- --- 140,146 ----
- PROG_OBJS = ${NAME}.o unix_man.o
- TEST_OBJS = stest.o
-
- ! FILES = ${XXFILES} ${DOCS} ${HDRS} ${SRCS} ${PERLSUB} ${TCLSUB} ${SCRIPTS}
-
- ###
- # target dependencies
- ***************
- *** 184,203 ****
- ${LIBDIR}/${LIBFILE} \
- ${LOCAL}/${PROGRAM}
-
- ! ${INCDIR}/${NAME}.h: ${NAME}.h useful.h
- ( ${CHDIR} ${INCDIR}; ${DEL} ${NAME}.h useful.h )
- ${COPY} ${NAME}.h useful.h ${INCDIR}
-
- ! ${LIBDIR}/${LIBFILE}: ${LIBARGS}
- ${DEL} ${LIBDIR}/${LIBFILE}
- ${COPY} ${LIBARGS} ${LIBDIR}/${LIBFILE}
- ${RANLIB} ${LIBDIR}/${LIBFILE}
-
- ! ${LOCAL}/${PROGRAM}: ${PROGRAM} ${PERLSUB}
- ! ${DEL} ${LOCAL}/${PROGRAM} ${PERLIB}/${PERLSUB}
- ${COPY} ${PROGRAM} ${LOCAL}
- ${STRIP} ${LOCAL}/${PROGRAM}
- ! ${COPY} ${PERLSUB} ${PERLLIB}
-
- ###
- # maintenance dependencies
- --- 186,206 ----
- ${LIBDIR}/${LIBFILE} \
- ${LOCAL}/${PROGRAM}
-
- ! ${INCDIR}/${NAME}.h: ${NAME}.h useful.h
- ( ${CHDIR} ${INCDIR}; ${DEL} ${NAME}.h useful.h )
- ${COPY} ${NAME}.h useful.h ${INCDIR}
-
- ! ${LIBDIR}/${LIBFILE}: ${LIBARGS}
- ${DEL} ${LIBDIR}/${LIBFILE}
- ${COPY} ${LIBARGS} ${LIBDIR}/${LIBFILE}
- ${RANLIB} ${LIBDIR}/${LIBFILE}
-
- ! ${LOCAL}/${PROGRAM}: ${PROGRAM} ${PERLSUB} ${TCLSUB}
- ! -${DEL} ${LOCAL}/${PROGRAM} ${PERLIB}/${PERLSUB} ${TCLLIB}/${TCLSUB}
- ${COPY} ${PROGRAM} ${LOCAL}
- ${STRIP} ${LOCAL}/${PROGRAM}
- ! -${COPY} ${PERLSUB} ${PERLLIB}
- ! -${COPY} ${TCLSUB} ${TCLLIB}
-
- ###
- # maintenance dependencies
- *** test.tcl.parseargs_patch12 Sat May 30 18:10:20 1992
- --- test.tcl Sat May 30 17:46:55 1992
- ***************
- *** 1,7 ****
- ! #!/usr/bin/tcl -q
-
- ! source parseargs.tcl
-
- set arguments {
- { '?', ARGHIDDEN, argUsage, NULL, "Help : print usage and exit" },
- { 'S', ARGVALOPT, argStr, string, "STRing : optional string arg" },
- --- 1,9 ----
- ! #!/usr/local/bin/tcl
-
- ! load "parseargs.tcl"
-
- + set scriptName "test.tcl"
- +
- set arguments {
- { '?', ARGHIDDEN, argUsage, NULL, "Help : print usage and exit" },
- { 'S', ARGVALOPT, argStr, string, "STRing : optional string arg" },
- ***************
- *** 20,32 ****
- set count 1
- set dirname "."
- set sepch ","
- ! set xflag ""
- ! set yflag "TRUE"
- set files {}
- set groups {}
- - set name ""
- set string ""
- - set string_flag ""
-
- eval [ parseargs -u -a $arguments $scriptName $argv ]
-
- --- 22,32 ----
- set count 1
- set dirname "."
- set sepch ","
- ! set xflag 0
- ! set yflag 1
- set files {}
- set groups {}
- set string ""
-
- eval [ parseargs -u -a $arguments $scriptName $argv ]
-
- ***************
- *** 41,47 ****
- echo "SepChar = $sepch"
- echo "Name = $name"
- echo "Files = $files"
- ! if {( "$string_flag" != "") } {
- if {( "$string" == "" )} {
- set string "!string arg ommitted on cmd-line!"
- }
- --- 41,47 ----
- echo "SepChar = $sepch"
- echo "Name = $name"
- echo "Files = $files"
- ! if {( [info exists string_flag] )} {
- if {( "$string" == "" )} {
- set string "!string arg ommitted on cmd-line!"
- }
- *** doc/parseargs.man1.parseargs_patch12 Sat May 30 18:10:18 1992
- --- doc/parseargs.man1 Sat May 30 17:46:46 1992
- ***************
- *** 348,359 ****
- specified to \fBparseargs\fP.
- .\"-----------------------------------------------------------
- .SH FILES
- ! .IP "\fI/usr/local/parseargs.pl\fP"
- This file defines a \fIperl\fP function named \fIparseargs\fP to parse
- arguments more conveniently for perl-scripts. The function is
- both documented and implemented in this file. The user should
- ``require'' this file in his/her perl-script before invoking the
- function.
- .IP "\fI/usr/local/parseargs.awk\fP"
- This file defines an \fIawk\fP function named \fIparseargs\fP to parse
- arguments more conveniently for awk-scripts. The function is
- --- 348,365 ----
- specified to \fBparseargs\fP.
- .\"-----------------------------------------------------------
- .SH FILES
- ! .IP "\fI/usr/local/lib/perl/parseargs.pl\fP"
- This file defines a \fIperl\fP function named \fIparseargs\fP to parse
- arguments more conveniently for perl-scripts. The function is
- both documented and implemented in this file. The user should
- ``require'' this file in his/her perl-script before invoking the
- function.
- + .IP "\fI/usr/local/lib/tcl/parseargs.tcl\fP"
- + This file defines a \fItcl\fP procedure named \fIparseargs\fP to parse
- + arguments more conveniently for tcl-scripts. The procedure is
- + both documented and implemented in this file. The user should
- + ``load'' this file in his/her tcl-script before invoking the
- + procedure.
- .IP "\fI/usr/local/parseargs.awk\fP"
- This file defines an \fIawk\fP function named \fIparseargs\fP to parse
- arguments more conveniently for awk-scripts. The function is
- *** parseargs.tcl.parseargs_patch12 Sat May 30 18:10:19 1992
- --- parseargs.tcl Sat May 30 17:46:49 1992
- ***************
- *** 13,21 ****
- # ^PROCEDURE: parseargs - parse command-line argument lists
- #
- # ^SYNOPSIS:
- ! # parseargs <options> -- $scriptName arg [arg ...]
- #
- # where <options> is any valid option combination for parseargs(1)
- #
- # ^DESCRIPTION:
- # Parseargs will invoke parseargs(1) with the options and arguments
- --- 13,22 ----
- # ^PROCEDURE: parseargs - parse command-line argument lists
- #
- # ^SYNOPSIS:
- ! # parseargs <options> -- $scriptName $argv
- #
- # where <options> is any valid option combination for parseargs(1)
- + # and $argv is a list.
- #
- # ^DESCRIPTION:
- # Parseargs will invoke parseargs(1) with the options and arguments
- ***************
- *** 22,122 ****
- # specified by the caller.
- #
- # ^RETURN-VALUE:
- ! # A string of variable settings for the caller to evaluate
- #
- # ^EXAMPLE:
- ! # #!/usr/bin/tcl -q
- #
- ! # source parseargs.tcl
- #
- # set arguments {
- ! # { '?', ARGHIDDEN, argUsage, NULL, "Help : print usage and exit" },
- ! # { 'S', ARGVALOPT, argStr, string, "STRing : optional string arg" },
- ! # { 'g', ARGLIST, argStr, groups, "newsGROUPS : groups to test" },
- ! # { 'r', ARGOPT, argInt, count, "REPcount : group repeat count" },
- ! # { 'd', ARGOPT, argStr, dirname, "DIRectory : working directory" },
- ! # { 'x', ARGOPT, argBool, xflag, "Xflag : turn on X-mode" },
- ! # { 'y', ARGOPT, argUBool, yflag, "Yflag : turn off Y-mode" },
- ! # { 's', ARGOPT, argChar, sepch, "SEPchar : field separator" },
- ! # { 'f', ARGLIST, argStr, files, "files : files to process" },
- ! # { 'n', ARGREQ|ARGPOS, argStr, name, "name : name to use" },
- ! # { ' ', ARGLIST, argStr, argv, "argv : remaining arguments" },
- ! # ENDOFARGS
- # }
- #
- # set count 1 ; set dirname "." ; set sepch "," ;
- ! # set xflag "" ; set yflag "TRUE" ;
- ! # set files {} ; set groups {} ; set name "" ;
- ! # set string "" ; set string_flag "" ;
- #
- ! # eval [ parseargs -u -a $arguments $scriptName $argv ]
- #
- - #
- - # ^ALGORITHM:
- - # We need to do an "eval exec parseargs $args" in order have exec
- - # treat $args as many arguments instead of just one argument. Before
- - # we can do that however, we must quote each argument in $args and
- - # escape any special characters that it contains. Hence we have the
- - # following algorithm:
- - #
- - # - quote and escape special character for each arg in $args
- - # - do an "eval exec $args" and save the results
- - # - if parseargs(1) exit-status is non-zero than exit (and make
- - # sure the parseargs message(s) is/are printed).
- - # else
- - # return the standard-output of parseargs(1)
- - # endif
- - #
- - #
- - # ^BUGS:
- - # Actually - this procedure doesnt work. It has some problems,
- - # some of which I know about and can describe below:
- - #
- - # 1) TCL refuses to let ME do the error-checking after exec'ing parseargs(1).
- - # What I need to do is look at the exit-status and exit if it is non-zero.
- - # If parseargs happens to write anything to stderr (which it always does
- - # if it prints usage or a syntax error) then TCL automatically terminates
- - # my procedure (not the process) and doesnt let me check the exit-status.
- - #
- - # 2) Error messages printed by parseargs(1) are prefixed with "Error: "
- - # and suffixed by some other error-message info added by TCL. I dont
- - # want ANY of this, just let parseargs(1) print the error text and dont
- - # embellish it. As a fix, I tried to have parseargs(1) write error messages
- - # to stdout (for TCL only) and exit with a non-zero status. This didnt
- - # work at all (and Im not completely sure as to why).
- - #
- - # 3) I ought to be able to use far fewer "regsub" statements below but I
- - # couldnt seem to get "&" or "\0" to work as documented as substitution
- - # strings.
- - #
- - # If you happen to get this procedure (along with test.tcl) working, then
- - # please, PLEASE let me know and tell me how you did it!!
- - #
- ###^^####
- proc parseargs args {
- ! set escaped_args {}
- ! foreach arg $args {
- ! regsub -all "\\\\" "$arg" "\\\\" arg
- ! regsub -all "\\\$" "$arg" "\\\$" arg
- ! regsub -all "\\\[" "$arg" "\\\[" arg
- ! regsub -all "\]" "$arg" "\\\]" arg
- ! regsub -all "\{" "$arg" "\\\{" arg
- ! regsub -all "\]" "$arg" "\\\]" arg
- ! regsub -all "\"" "$arg" "\\\"" arg
- ! regsub -all "\t" "$arg" "\\t" arg
- ! regsub -all "\n" "$arg" "\\n" arg
- ! regsub -all "\r" "$arg" "\\r" arg
- ! regsub -all "\v" "$arg" "\\v" arg
- ! regsub -all "\f" "$arg" "\\f" arg
- ! regsub -all "\b" "$arg" "\\b" arg
- ! append escaped_args " \"$arg\""
- }
- - set errorCode {}
- - set opt_settings [ eval exec parseargs -s tcl $escaped_args ]
- - if {( $errorCode != {} )} {
- - ## echo $opt_settings
- - exit [lindex $errorCode 2]
- - }
- - return $opt_settings ;
- }
-
- --- 23,97 ----
- # specified by the caller.
- #
- # ^RETURN-VALUE:
- ! # A string of variable settings for the caller to evaluate.
- ! # If parseargs(1) exits with a non-zero status, then execution
- ! # is terminated.
- #
- # ^EXAMPLE:
- ! # #!/usr/local/bin/tcl
- #
- ! # load parseargs.tcl
- #
- # set arguments {
- ! # { '?', ARGHIDDEN, argUsage, NULL, "Help : print usage and exit" },
- ! # { 'S', ARGVALOPT, argStr, string, "STRing : optional string arg" },
- ! # { 'g', ARGLIST, argStr, groups, "newsGROUPS : groups to test" },
- ! # { 'r', ARGOPT, argInt, count, "REPcount : group repeat count" },
- ! # { 'd', ARGOPT, argStr, dirname, "DIRectory : working directory" },
- ! # { 'x', ARGOPT, argBool, xflag, "Xflag : turn on X-mode" },
- ! # { 'y', ARGOPT, argUBool, yflag, "Yflag : turn off Y-mode" },
- ! # { 's', ARGOPT, argChar, sepch, "SEPchar : field separator" },
- ! # { 'f', ARGLIST, argStr, files, "files : files to process" },
- ! # { 'n', ARGREQ|ARGPOS, argStr, name, "name : name to use" },
- ! # { ' ', ARGLIST, argStr, argv, "argv : any remaining args" },
- ! # ENDOFARGS
- # }
- #
- # set count 1 ; set dirname "." ; set sepch "," ;
- ! # set xflag 0 ; set yflag 1 ;
- ! # set files {} ; set groups {} ;
- ! # set string "" ;
- #
- ! # eval [ parseargs -decls $arguments $scriptName $argv ]
- #
- ###^^####
- proc parseargs args {
- ! ## set temp-file name
- ! if {( ! [info exists env] )} { set env(TMP) "/tmp" }
- ! if {( $env(TMP) == "" )} { set env(TMP) "/tmp" }
- ! set tmpFileName "$env(TMP)/tmp[id process]"
- !
- ! ## isolate the last argument (a list) from the rest
- ! set last [expr {[llength $args] - 1}]
- ! set cmdArgv [lindex $args $last]
- ! set cmdOpts [lrange $args 0 [expr {$last - 1}]]
- !
- ! ## fork and exec
- ! if {( [set childPid [fork]] == 0 )} {
- ! ## This is the child ...
- ! ## redirect stdout to temp-file and exec parseargs(1)
- ! ##
- ! set tmpFile [open $tmpFileName "w"]
- ! close stdout
- ! dup $tmpFile stdout
- ! close $tmpFile
- ! execl parseargs [concat -s tcl $cmdOpts $cmdArgv]
- ! } else {
- ! ## This is the parent ...
- ! ## wait for the child, check its status, then return its output
- ! ## dont forget to remove the temp-file.
- ! ##
- ! set childStatus [wait $childPid]
- ! set how [lindex $childStatus 1]
- ! set ret [lindex $childStatus 2]
- ! if {( ($how == "EXIT") && ($ret == 0) )} {
- ! set variableSettings [exec cat $tmpFileName]
- ! unlink -nocomplain $tmpFileName
- ! return $variableSettings
- ! } else {
- ! unlink -nocomplain $tmpFileName
- ! exit [expr {$how == "EXIT" ? $ret : 127}]
- ! }
- }
- }
-
- *** MANIFEST.parseargs_patch12 Sat May 30 18:10:16 1992
- --- MANIFEST Sat May 30 17:46:39 1992
- ***************
- *** 5,11 ****
- Makefile 2 makefile for parseargs library
- README 1 release information
- VMSbuild.com 2 VMS makefile for the parseargs library
- ! amiga_args.c 5 parse AmigaDOS command-lines
- arglist.c 3 implement the listXxxx functions for arglists
- argtype.c 5 implement the argXxxx argument type functions
- doc 1 directory containing documentation
- --- 5,11 ----
- Makefile 2 makefile for parseargs library
- README 1 release information
- VMSbuild.com 2 VMS makefile for the parseargs library
- ! amiga_args.c 4 parse AmigaDOS command-lines
- arglist.c 3 implement the listXxxx functions for arglists
- argtype.c 5 implement the argXxxx argument type functions
- doc 1 directory containing documentation
- ***************
- *** 34,40 ****
- doc/parsecntl.man3 1 {n,t}roff source for parsecntl(3)
- doc/parsecntl3.inc 1 describe parsecntl(3)
- doc/parsecntls.inc 2 describe function-codes for parsecntl(3)
- ! doc/parseflags.inc 3 describe parse flags
- doc/parsemodes.inc 1 describe modes for parsecntl(3)
- doc/returns.inc 2 describe function return values
- doc/sh_arrays.inc 3 describe handling of shell arrays
- --- 34,40 ----
- doc/parsecntl.man3 1 {n,t}roff source for parsecntl(3)
- doc/parsecntl3.inc 1 describe parsecntl(3)
- doc/parsecntls.inc 2 describe function-codes for parsecntl(3)
- ! doc/parseflags.inc 2 describe parse flags
- doc/parsemodes.inc 1 describe modes for parsecntl(3)
- doc/returns.inc 2 describe function return values
- doc/sh_arrays.inc 3 describe handling of shell arrays
- ***************
- *** 43,52 ****
- doc/usage3.inc 1 describe usage(3)
- doc/vparseargs3.inc 1 describe vparseargs(3)
- exit_codes.h 1 #defines for arguments to exit(3C)
- ! ibm_args.c 6 parse MS-DOS and OS/2 command-lines
- parseargs.awk 3 parseargs for awk
- ! parseargs.c 10 C source for parseargs(1)
- ! parseargs.h 8 include file for parseargs library
- parseargs.pl 2 parseargs for perl
- parseargs.tcl 2 parseargs for tcl
- patchlevel.h 3 list of patches (most recent first)
- --- 43,52 ----
- doc/usage3.inc 1 describe usage(3)
- doc/vparseargs3.inc 1 describe vparseargs(3)
- exit_codes.h 1 #defines for arguments to exit(3C)
- ! ibm_args.c 5 parse MS-DOS and OS/2 command-lines
- parseargs.awk 3 parseargs for awk
- ! parseargs.c 9 C source for parseargs(1)
- ! parseargs.h 7 include file for parseargs library
- parseargs.pl 2 parseargs for perl
- parseargs.tcl 2 parseargs for tcl
- patchlevel.h 3 list of patches (most recent first)
- ***************
- *** 53,59 ****
- pgopen.c 4 pipe output to a pager
- pgopen.h 1 include file for pgopen.c
- stest.c 4 test program for parseargs(3)
- ! strfuncs.c 7 string library
- strfuncs.h 2 include file for strfuncs.c
- syserr.c 3 diagnostic message printing routines
- test.awk 3 awk test program for parseargs(1)
- --- 53,59 ----
- pgopen.c 4 pipe output to a pager
- pgopen.h 1 include file for pgopen.c
- stest.c 4 test program for parseargs(3)
- ! strfuncs.c 6 string library
- strfuncs.h 2 include file for strfuncs.c
- syserr.c 3 diagnostic message printing routines
- test.awk 3 awk test program for parseargs(1)
- ***************
- *** 66,73 ****
- test.zsh 2 Z shell test program for parseargs(1)
- unix_args.c 5 parse Unix command-lines
- unix_man.c 4 print Unix manual-page templates
- ! useful.h 4 common include file for the library
- vms_args.c 6 parse VAX/VMS DCL command-lines
- vprintf.c 3 portable vfprintf, vprintf, and vsprintf
- winsize.c 3 determine # rows and # columns of window
- ! xparse.c 9 implement the parseargs library
- --- 66,73 ----
- test.zsh 2 Z shell test program for parseargs(1)
- unix_args.c 5 parse Unix command-lines
- unix_man.c 4 print Unix manual-page templates
- ! useful.h 3 common include file for the library
- vms_args.c 6 parse VAX/VMS DCL command-lines
- vprintf.c 3 portable vfprintf, vprintf, and vsprintf
- winsize.c 3 determine # rows and # columns of window
- ! xparse.c 8 implement the parseargs library
-