brad@hcx1.ssd.csd.harris.com (Brad Appleton) (03/19/91)
Submitted-by: Brad Appleton <brad@hcx1.ssd.csd.harris.com> Posting-number: Volume 17, Issue 58 Archive-name: parseargs/patch01 Patch-To: parseargs: Volume 17, Issue 45-57 This is a patch for parseargs. The only things that was wrong is that I incorrectly documented something, (this is NOT a bugfix). This patch consists of two files: PATCH : patches for 'xparse.c' and 'doc/env_parse.inc' TXTPATCH : patches for 'parseargs1.txt' and 'parseargs3.txt' The second file is ONLY needed by those who do not have nroff or troff available to them. -- ______________________ "And miles to go before I sleep." ______________________ Brad Appleton Harris Corp., Computer Systems Division Software Engineer 2101 West Cypress Creek Road, M/S 161 brad@ssd.csd.harris.com Fort Lauderdale, FL 33309-1892 USA ...!uunet!hcx1!brad Phone: (305) 973-5360 ~~~~~~~~~~~~~~~~~~~~ Disclaimer: I said it, not my company! ~~~~~~~~~~~~~~~~~~~ #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of shell archive." # Contents: PATCH TXTPATCH # Wrapped by brad@hcx2 on Mon Mar 18 09:33:10 1991 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'PATCH' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'PATCH'\" else echo shar: Extracting \"'PATCH'\" \(2415 characters\) sed "s/^X//" >'PATCH' <<'END_OF_FILE' X*** doc/env_parse.inc.OLD Mon Mar 18 09:10:32 1991 X--- doc/env_parse.inc Sat Mar 16 15:19:28 1991 X*************** X*** 62,66 **** X undefined, then parsing behavior set by the programmer is used. X If the programmer has not explicitly used X .IR parsecntl (3) X! to modify the parsing behavior will be ``!Prompt + !Ignore'' for Unix X! MS-DOS, OS/2, and AmigaDOS systems, and ``Prompt'' for VMS systems. X--- 62,68 ---- X undefined, then parsing behavior set by the programmer is used. X If the programmer has not explicitly used X .IR parsecntl (3) X! to modify the parsing behavior, then the default behavior will be X! ``Flags1st'' for Unix systems, ``!Prompt + !Ignore'' for AmigaDOS X! systems, ``CaseIgnore'' for MS-DOS and OS/2 systems, and ``Prompt'' X! for VMS systems. X*** xparse.c.OLD Mon Mar 18 09:10:36 1991 X--- xparse.c Mon Mar 18 08:51:08 1991 X*************** X*** 537,543 **** X--- 537,553 ---- X else anchor = ad; X X /* set default parse-flags */ X+ #ifndef ibm_style X cmd_flags(argd) = pa_DEFAULTS; X+ #else X+ { X+ char *pfx = getenv( "SWITCHAR" ); X+ if ( pfx && *pfx == '-' ) X+ cmd_flags(argd) = pa_FLAGS1ST; X+ else X+ cmd_flags(argd) = pa_DEFAULTS; X+ } X+ #endif X X /* if new-style, get the purpose from the command name */ X if ( !old_style && cmd_name(argd) ) { X*************** X*** 1168,1176 **** X ** X ** If the environment variable "PARSECNTL" is empty or undefined, then X ** parsing behavior set by the programmer is used. If the programmer has X! ** not explicitly used parsecntl(3) to modify the parsing behavior will X! ** be "!Prompt + !Ignore" for Unix and AmigaDOS systems, "Prompt" for X! ** VMS systems, and "CaseIgnore" for MS-DOS and OS/2 systems. X ** X ** ^REQUIREMENTS: X ** <cmd> must point to an array that has been declared using the CMD_XXXX X--- 1178,1187 ---- X ** X ** If the environment variable "PARSECNTL" is empty or undefined, then X ** parsing behavior set by the programmer is used. If the programmer has X! ** not explicitly used parsecntl(3) to modify the parsing behavior, then X! ** the default behavior will be "Flags1st" for Unix Systems, X! ** "!Prompt + !Ignore" for AmigaDOS systems, "Prompt" for VMS systems, X! ** and "CaseIgnore" for MS-DOS and OS/2 systems. X ** X ** ^REQUIREMENTS: X ** <cmd> must point to an array that has been declared using the CMD_XXXX END_OF_FILE if test 2415 -ne `wc -c <'PATCH'`; then echo shar: \"'PATCH'\" unpacked with wrong size! fi # end of 'PATCH' fi if test -f 'TXTPATCH' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'TXTPATCH'\" else echo shar: Extracting \"'TXTPATCH'\" \(9637 characters\) sed "s/^X//" >'TXTPATCH' <<'END_OF_FILE' XNo differences encountered X*** parseargs1.txt.OLD Mon Mar 18 09:24:28 1991 X--- parseargs1.txt Mon Mar 18 09:25:29 1991 X*************** X*** 607,615 **** X If the environment variable ``PARSECNTL'' is empty or X undefined, then parsing behavior set by the programmer is X used. If the programmer has not explicitly used X! parsecntl(3) to modify the parsing behavior will be X! ``!Prompt + !Ignore'' for Unix MS-DOS, OS/2, and AmigaDOS X! systems, and ``Prompt'' for VMS systems. X X USAGE MESSAGES X Through the use of an environment variable (or a VMS X--- 607,616 ---- X If the environment variable ``PARSECNTL'' is empty or X undefined, then parsing behavior set by the programmer is X used. If the programmer has not explicitly used X! parsecntl(3) to modify the parsing behavior, then the X! default behavior will be ``Flags1st'' for Unix systems, X! ``!Prompt + !Ignore'' for AmigaDOS systems, ``CaseIgnore'' X! for MS-DOS and OS/2 systems, and ``Prompt'' for VMS systems. X X USAGE MESSAGES X Through the use of an environment variable (or a VMS X*************** X*** 650,656 **** X Description X The command description is printed. X X- Terse X X X X--- 651,656 ---- X*************** X*** 665,670 **** X--- 665,671 ---- X X X X+ Terse X Terse mode, just print command-line synopsis. X X Verbose X*************** X*** 716,722 **** X FALSE (an empty string). X X -X A Boolean ``X Rated'' flag. This is not X- printed in the usage message. X X X X--- 717,722 ---- X*************** X*** 731,736 **** X--- 731,738 ---- X X X X+ printed in the usage message. X+ X The two positional arguments are both strings, as is the X final list. If we were to invoke the above script with the X following command line: X*************** X*** 781,788 **** X X ## parse command-line and save assignments in a temporary file ## X parseargs -s sh -e ARGUMENTS -u -- "$NAME" "$@" >/tmp/tmp$$ X- if [ $? -ne 0 ] X- then rm -f /tmp/tmp$$; exit 2 ## non-zero status (usage given) X X X X--- 783,788 ---- X*************** X*** 797,802 **** X--- 797,804 ---- X X X X+ if [ $? -ne 0 ] X+ then rm -f /tmp/tmp$$; exit 2 ## non-zero status (usage given) X fi X X ## evaluate results from parseargs and remove temporary file X*************** X*** 846,857 **** X 4 A syntax error was encountered in the argument X specification string that was specified to parseargs. X X- FILES X- /usr/local/parseargs.pl X- This file defines a perl function named parseargs to X X X X Page 13 X X X--- 848,857 ---- X 4 A syntax error was encountered in the argument X specification string that was specified to parseargs. X X X X X+ X Page 13 X X X*************** X*** 863,868 **** X--- 863,871 ---- X X X X+ FILES X+ /usr/local/parseargs.pl X+ This file defines a perl function named parseargs to X parse arguments more conveniently for perl-scripts. The X function is both documented and implemented in this X file. The user should ``require'' this file in his/her X*************** X*** 913,923 **** X Hence multiple ``leading dash'' arguments may specified as X follows: X X- -f-dash_arg1 -f-dash_arg2 ... X X X- X- X Page 14 X X X--- 916,923 ---- X*************** X*** 929,934 **** X--- 929,936 ---- X X X X+ -f-dash_arg1 -f-dash_arg2 ... X+ X BUGS X It does not make sense to use any arguments of type argTBool X since parseargs currently has no way of knowing what the X*************** X*** 971,978 **** X AUTHOR X Brad Appleton (brad@ssd.csd.harris.com) X Harris Computer Systems, Fort Lauderdale, FL USA X- X- X X X X--- 973,978 ---- X*** parseargs3.txt.OLD Mon Mar 18 09:24:29 1991 X--- parseargs3.txt Mon Mar 18 09:25:47 1991 X*************** X*** 643,656 **** X If the environment variable ``PARSECNTL'' is empty or unde- X fined, then parsing behavior set by the programmer is used. X If the programmer has not explicitly used parsecntl(3) to X! modify the parsing behavior will be ``!Prompt + !Ignore'' X! for Unix MS-DOS, OS/2, and AmigaDOS systems, and ``Prompt'' X! for VMS systems. X X USAGE MESSAGES X Through the use of an environment variable (or a VMS sym- X bol), the user may control the syntax and the verbosity of X- the command-usage messages that are printed by parseargs. X X X X--- 643,656 ---- X If the environment variable ``PARSECNTL'' is empty or unde- X fined, then parsing behavior set by the programmer is used. X If the programmer has not explicitly used parsecntl(3) to X! modify the parsing behavior, then the default behavior will X! be ``Flags1st'' for Unix systems, ``!Prompt + !Ignore'' for X! AmigaDOS systems, ``CaseIgnore'' for MS-DOS and OS/2 sys- X! tems, and ``Prompt'' for VMS systems. X X USAGE MESSAGES X Through the use of an environment variable (or a VMS sym- X bol), the user may control the syntax and the verbosity of X X X X*************** X*** 665,670 **** X--- 665,671 ---- X X X X+ the command-usage messages that are printed by parseargs. X The desired level of verbosity may be set by defining the X environment variable ``USAGECNTL" to be a combination of X strings (case insensitive). The value of each string con- X*************** X*** 715,725 **** X Same as LongOpts. X X X- If the environment variable ``USAGECNTL'' is empty or unde- X- fined, then the default usage level (which is presently X X X X Page 11 X X X--- 716,725 ---- X Same as LongOpts. X X X X X X+ X Page 11 X X X*************** X*** 731,736 **** X--- 731,738 ---- X X X X+ If the environment variable ``USAGECNTL'' is empty or unde- X+ fined, then the default usage level (which is presently X ``Verbose + Options'') will be used. X X MULTI-VALUED ARGUMENTS X*************** X*** 781,791 **** X ( StrVec.array[ StrVec.count ] == (char *)NULL ) X X is always true, and character-vectors will always have an X- extra NUL-character at the end such that: X X X X- X Page 12 X X X--- 783,791 ---- X*************** X*** 797,802 **** X--- 797,804 ---- X X X X+ extra NUL-character at the end such that: X+ X ( CharVec.array[ CharVec.count ] == '\0' ) X X is always true. Integer and floating point vectors contain X*************** X*** 847,854 **** X i, StrVec.array[i], StrVec.flags[i] ); X X for ( i = 0 ; i < NumVec.count ; i++ ) X- printf( "Number[%d]=%s, flags=%x\n", X- i, NumVec.array[i], NumVec.flags[i] ); X X X X--- 849,854 ---- X*************** X*** 863,868 **** X--- 863,871 ---- X X X X+ printf( "Number[%d]=%s, flags=%x\n", X+ i, NumVec.array[i], NumVec.flags[i] ); X+ X listFree( StrList ); X StrList = ARGLISTNULL; X X*************** X*** 912,920 **** X typedef ARGVEC_T(FILE *) FILEvec_t; X X BOOL argReadFile( ARGDESC *ad, char *vp, BOOL copyf ) X- { X- register FILE *fp; X- fp = fopen(vp, "r"); X X X X--- 915,920 ---- X*************** X*** 929,934 **** X--- 929,938 ---- X X X X+ { X+ register FILE *fp; X+ fp = fopen(vp, "r"); X+ X if ( ! fp ) { X usrerr("cannot open '%s' for reading", vp); X return (FALSE); X*************** X*** 978,989 **** X ment descriptor) is always used to match for possible argu- X ments (or keywords, or qualifiers). X X- For all supported operating systems, a long option may be X- matched in one of two ways: it may match all uppercase char- X- acters in the prompt field, or it may match all characters X X X- X Page 15 X X X--- 982,989 ---- X*************** X*** 995,1000 **** X--- 995,1003 ---- X X X X+ For all supported operating systems, a long option may be X+ matched in one of two ways: it may match all uppercase char- X+ acters in the prompt field, or it may match all characters X in the prompt field (as in ``+count=4'' and ``+rep- X count=4''). X X*************** X*** 1045,1055 **** X the pc_ARGFLAGS functions code) was found in the given X argdesc-array or in its default-list. X X- pe_BADMODE X- Bad mode for given command in parsecntl. This occurs X X X- X Page 16 X X X--- 1048,1055 ---- X*************** X*** 1061,1066 **** X--- 1061,1068 ---- X X X X+ pe_BADMODE X+ Bad mode for given command in parsecntl. This occurs X when pc_WRITE or pc_RDWR mode is passed to parsecntl in X conjunction with the pc_ARGFLAGS functions code. Par- X secntl will not modify existing arguments. X*************** X*** 1110,1121 **** X X -f-dash_arg1 -f-dash_arg2 ... X X- BUGS X- When a non-multivalued argument appears more than once on X- the command-line then only the last value supplied is used. X X X X Page 17 X X X--- 1112,1121 ---- X X -f-dash_arg1 -f-dash_arg2 ... X X X X X+ X Page 17 X X X*************** X*** 1127,1132 **** X--- 1127,1135 ---- X X X X+ BUGS X+ When a non-multivalued argument appears more than once on X+ the command-line then only the last value supplied is used. X A problem occurs however in the following scenario: suppose X `-s' is an option that takes an optional string argument (nd X suppose `-x' is some boolean flag). Then if the following X*************** X*** 1156,1164 **** X argument flags ARGPOS, ARGVALOPT, ARGVALREQ, ARGVALGIVEN, X ARGNOVAL, and ARGVEC; and VAX/VMS version and IBM-PC version X by Brad Appleton X- X- X- X X X X--- 1159,1164 ---- XNo differences encountered END_OF_FILE if test 9637 -ne `wc -c <'TXTPATCH'`; then echo shar: \"'TXTPATCH'\" unpacked with wrong size! fi # end of 'TXTPATCH' fi echo shar: End of shell archive. exit 0 exit 0 # Just in case... -- Kent Landfield INTERNET: kent@sparky.IMD.Sterling.COM Sterling Software, IMD UUCP: uunet!sparky!kent Phone: (402) 291-8300 FAX: (402) 291-4362 Please send comp.sources.misc-related mail to kent@uunet.uu.net.