v17i073: parseargs - functions to parse command line arguments, Patch02

Brad Appleton brad at hcx1.ssd.csd.harris.com
Thu Mar 28 04:45:44 AEST 1991


Submitted-by: Brad Appleton <brad at hcx1.ssd.csd.harris.com>
Posting-number: Volume 17, Issue 73
Archive-name: parseargs/patch02
Patch-To: parseargs: Volume 17, Issue 00-12

This is the second patch for parseargs. It fixes most of the documentation
errors (It is NOT a bug-fix).

______________________ "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 at 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
# Wrapped by brad at hcx2 on Tue Mar 26 11:42:19 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'\" \(38200 characters\)
sed "s/^X//" >'PATCH' <<'END_OF_FILE'
X*** argtype.c.OLD	Tue Mar 26 11:31:00 1991
X--- argtype.c	Tue Mar 26 10:19:41 1991
X***************
X*** 79,85 ****
X  ** ^DESCRIPTION:
X  **    Each of these converts a parameter value to the internal form, includ-
X  **    ing validity checking.  Their parameters and return values all behave
X! **    similarly. One of these routines are called when an argunent of that
X  **    particular type is matched by one of the argument parsing function in
X  **    parseargs(3). When such an argument is matched, its argument transla-
X  **    tion routines is invoked and is passed (1) the address of the argument
X--- 79,85 ----
X  ** ^DESCRIPTION:
X  **    Each of these converts a parameter value to the internal form, includ-
X  **    ing validity checking.  Their parameters and return values all behave
X! **    similarly. One of these routines is called when an argument of that
X  **    particular type is matched by one of the argument parsing function in
X  **    parseargs(3). When such an argument is matched, its argument transla-
X  **    tion routines is invoked and is passed (1) the address of the argument
X***************
X*** 151,157 ****
X  **    usage to be printed.
X  **
X  **    ArgDummy is used to force an item to show up in usage-messages but
X! **    the item itself is never matched against any argumenmts from the
X  **    command-line.
X  **
X  **    ArgEnd is used by amiga_args.c and vms_args.c to indicate an argument
X--- 151,157 ----
X  **    usage to be printed.
X  **
X  **    ArgDummy is used to force an item to show up in usage-messages but
X! **    the item itself is never matched against any arguments from the
X  **    command-line.
X  **
X  **    ArgEnd is used by amiga_args.c and vms_args.c to indicate an argument
X*** doc/argdesc.inc.OLD	Tue Mar 26 11:31:16 1991
X--- doc/argdesc.inc	Tue Mar 26 11:01:10 1991
X***************
X*** 22,28 ****
X  .\"---------------------------------------------
X  .IP "\fIargTypePtr_t  ad_type;\fP"
X  This field is a pointer to a type conversion function (such as the
X! ones provided in \fIargtype\fP(3). The type conversion function is
X  responsible for verifying the validity of the argument, allocating any
X  necessary storage for its internal representation, and converting
X  the command-line argument into its required internal form. The type
X--- 22,28 ----
X  .\"---------------------------------------------
X  .IP "\fIargTypePtr_t  ad_type;\fP"
X  This field is a pointer to a type conversion function (such as the
X! ones provided in \fIargtype\fP(3)). The type conversion function is
X  responsible for verifying the validity of the argument, allocating any
X  necessary storage for its internal representation, and converting
X  the command-line argument into its required internal form. The type
X***************
X*** 41,57 ****
X  pointer to a number, a boolean value, a string, a list, or anything
X  else for which there exists a corresponding arg-type function to
X  use in the \fIad_type\fP field. In the case of of \fIparseargs\fP(1) this
X! field must be the name of the corresponding shell variable which eventually
X! hold the value of the argument given on the command-line.
X  .\"---------------------------------------------
X  .IP "\fIconst char  *ad_prompt;\fP"
X  This field contains the long-name of the argument and an optional
X  description (the description must be separated from the long-name by
X! at least one whitespace characters and may optionally be enclosed in
X  a set of balanced delimiters (such as parentheses, curly-braces,
X! square-brackets, or angle-brackets. If the long-name contains any
X  uppercase characters, then the substring of long-name consisting of
X! all uppercase characters is used as the argument name and the entire
X! long-name is used as the name of the argument-value (if a value my be
X  supplied). The long-name may be matched by supplying a unique prefix
X! of either the argument name or the argument-value name.
X--- 41,57 ----
X  pointer to a number, a boolean value, a string, a list, or anything
X  else for which there exists a corresponding arg-type function to
X  use in the \fIad_type\fP field. In the case of of \fIparseargs\fP(1) this
X! field must be the name of the corresponding shell variable which will
X! eventually hold the value of the argument given on the command-line.
X  .\"---------------------------------------------
X  .IP "\fIconst char  *ad_prompt;\fP"
X  This field contains the long-name of the argument and an optional
X  description (the description must be separated from the long-name by
X! at least one whitespace character and may optionally be enclosed in
X  a set of balanced delimiters (such as parentheses, curly-braces,
X! square-brackets, or angle-brackets). If the long-name contains any
X  uppercase characters, then the substring of long-name consisting of
X! all uppercase characters is used as the argument keyword and the entire
X! long-name is used as the name of the argument (if a value my be
X  supplied). The long-name may be matched by supplying a unique prefix
X! of either the argument keyword or the argument name.
X*** doc/argtype.man3.OLD	Tue Mar 26 11:31:22 1991
X--- doc/argtype.man3	Tue Mar 26 10:24:42 1991
X***************
X*** 34,41 ****
X  .PP
X  Each of these converts a parameter value to the internal form,
X  including validity checking.  Their parameters and return values
X! all behave similarly. One of these routines are called when an
X! argunent of that particular type is matched by one of the argument
X  parsing function in \fIparseargs\fP(3). When such an argument is matched,
X  its argument translation routines is invoked and is passed (1) the address of
X  the argument descriptor for the matched argument, (2) the possible argument
X--- 34,41 ----
X  .PP
X  Each of these converts a parameter value to the internal form,
X  including validity checking.  Their parameters and return values
X! all behave similarly. One of these routines is called when an
X! argument of that particular type is matched by one of the argument
X  parsing function in \fIparseargs\fP(3). When such an argument is matched,
X  its argument translation routines is invoked and is passed (1) the address of
X  the argument descriptor for the matched argument, (2) the possible argument
X***************
X*** 50,56 ****
X  the matched argument has the \s-1ARGVEC\s+1 flag enabled). If the argument is
X  an \s-1ARGVEC\s+1 or \s-1ARGLIST\s+1 then the routine is responsible for
X  allocating any space, copying the arg-flags to the value-specific flags, and
X! setting the \s-1ARGCOPYF\fP flag for the value if it needs to be allocated
X  as well.
X  
X  .SH "RETURN VALUE"
X--- 50,56 ----
X  the matched argument has the \s-1ARGVEC\s+1 flag enabled). If the argument is
X  an \s-1ARGVEC\s+1 or \s-1ARGLIST\s+1 then the routine is responsible for
X  allocating any space, copying the arg-flags to the value-specific flags, and
X! setting the \s-1ARGCOPYF\s+1 flag for the value if it needs to be allocated
X  as well.
X  
X  .SH "RETURN VALUE"
X***************
X*** 65,71 ****
X  The conversion was successful but only \fIN\fP characters of the value
X  were used, the remaining characters may still match other arguments.
X  
X! .SH "PSEUDO-TYPES"
X  .PP
X  .I ArgUsage
X  is used to specify an argument that causes the command usage to be printed.
X--- 65,71 ----
X  The conversion was successful but only \fIN\fP characters of the value
X  were used, the remaining characters may still match other arguments.
X  
X! .SH "PSEUDO-TYPES: argUsage, argDummy, argEnd"
X  .PP
X  .I ArgUsage
X  is used to specify an argument that causes the command usage to be printed.
X***************
X*** 72,78 ****
X  
X  .I ArgDummy
X  is used to force an item to show up in usage-messages but
X! the item itself is never matched against any argumenmts from the
X  command-line.
X  
X  .I ArgEnd
X--- 72,78 ----
X  
X  .I ArgDummy
X  is used to force an item to show up in usage-messages but
X! the item itself is never matched against any arguments from the
X  command-line.
X  
X  .I ArgEnd
X***************
X*** 82,88 ****
X  These three are dummy functions. The routines themselves do nothing
X  of importance, we just need to have their addresses available for
X  identification in the corresponding command-line styles.
X! .SH "STRING-TYPES"
X  .PP
X  \fIArgStr\fP is one of the few argument translation routines that actually
X  uses the \fIcopyf\fP flag. If \fIcopyf\fP is true then the string is
X--- 82,88 ----
X  These three are dummy functions. The routines themselves do nothing
X  of importance, we just need to have their addresses available for
X  identification in the corresponding command-line styles.
X! .SH "STRING-TYPES: argStr"
X  .PP
X  \fIArgStr\fP is one of the few argument translation routines that actually
X  uses the \fIcopyf\fP flag. If \fIcopyf\fP is true then the string is
X***************
X*** 94,100 ****
X  
X  \fIArgStr\fP ensures that the very last item in a vector of strings (the one
X  accessed as \f4vec.array[ vec.count ]\fP) will always be \s-1NULL\s+1.
X! .SH "CHARACTER-TYPES"
X  .PP
X  .I ArgChar
X  assigns the given character to the value referenced by \fIarg_valp(ad)\fP
X--- 94,100 ----
X  
X  \fIArgStr\fP ensures that the very last item in a vector of strings (the one
X  accessed as \f4vec.array[ vec.count ]\fP) will always be \s-1NULL\s+1.
X! .SH "CHARACTER-TYPES: argChar"
X  .PP
X  .I ArgChar
X  assigns the given character to the value referenced by \fIarg_valp(ad)\fP
X***************
X*** 109,125 ****
X  
X  Unlike \fIargStr\fP, \fIargChar\fP will translate character escape sequences
X  such as `\\n' and `\\012'.
X! .SH "INTEGER-TYPES"
X  .PP
X  Each of these functions converts the given string to the desired
X  integral type. The value may be specified as an octal number by
X  specifying the first digit to be 0. Similarly, If the first two 
X  characters are `0x' then the number is treated as hexadecimal.
X! .SH "FLOATING-POINT-TYPES"
X  .PP
X  Each of these functions converts the given string to the desired
X  floating-point type.
X! .SH "BOOLEAN-TYPES"
X  .PP
X  \fIArgBool\fP and \fIargSBool\fP set a boolean value (if no value is given).
X  \fIArgUBool\fP unsets a boolean value (if no value is given). \fIArgTBool\fP
X--- 109,125 ----
X  
X  Unlike \fIargStr\fP, \fIargChar\fP will translate character escape sequences
X  such as `\\n' and `\\012'.
X! .SH "INTEGER-TYPES: argInt, argShort, argLong"
X  .PP
X  Each of these functions converts the given string to the desired
X  integral type. The value may be specified as an octal number by
X  specifying the first digit to be 0. Similarly, If the first two 
X  characters are `0x' then the number is treated as hexadecimal.
X! .SH "FLOATING-POINT-TYPES: argFloat, argDouble"
X  .PP
X  Each of these functions converts the given string to the desired
X  floating-point type.
X! .SH "BOOLEAN-TYPES: argBool, argSBool, argTBool, argUBool"
X  .PP
X  \fIArgBool\fP and \fIargSBool\fP set a boolean value (if no value is given).
X  \fIArgUBool\fP unsets a boolean value (if no value is given). \fIArgTBool\fP
X***************
X*** 148,154 ****
X  The corresponding boolean flag is set to \s-1FALSE\s+1.
X  .IP "``1'', ``+'', ``ON'', or ``TRUE''"
X  The corresponding boolean flag is set to \s-1TRUE\s+1.
X! .SH LIST TYPES
X  .PP
X  The \fIlistStr\fP argument translation routine is only intended for use
X  on behalf of arguments that have the \s-1ARGLIST\s+1 flag enabled. It will
X--- 148,154 ----
X  The corresponding boolean flag is set to \s-1FALSE\s+1.
X  .IP "``1'', ``+'', ``ON'', or ``TRUE''"
X  The corresponding boolean flag is set to \s-1TRUE\s+1.
X! .SH "LIST TYPES: listStr"
X  .PP
X  The \fIlistStr\fP argument translation routine is only intended for use
X  on behalf of arguments that have the \s-1ARGLIST\s+1 flag enabled. It will
X***************
X*** 168,171 ****
X  type of the items in the vector.
X  .SH SEE ALSO
X  .IR parseargs (3),
X! .IR parseargs (1),
X--- 168,172 ----
X  type of the items in the vector.
X  .SH SEE ALSO
X  .IR parseargs (3),
X! .IR parseargs (3),
X! .IR parsecntl (1),
X*** doc/env_args.inc.OLD	Tue Mar 26 11:31:43 1991
X--- doc/env_args.inc	Tue Mar 26 10:42:13 1991
X***************
X*** 10,16 ****
X  will be parsed for any "default" arguments before the command-line is parsed.
X  The command-line will over-ride any options that are specified in this
X  environment variable (except that \s-1ARGLIST\s+1s and \s-1ARGVEC\s+1s set in
X! ``\s-1CMD_ARGS\s+1'' will be appended from the command-line
X  
X  It is important to note that the contents of the ``\s-1\fICMD\fP_ARGS\s+1''
X  environment variable are NOT expanded by the shell and hence any special
X--- 10,17 ----
X  will be parsed for any "default" arguments before the command-line is parsed.
X  The command-line will over-ride any options that are specified in this
X  environment variable (except that \s-1ARGLIST\s+1s and \s-1ARGVEC\s+1s set in
X! ``\s-1CMD_ARGS\s+1'' will be appended from the command-line if they are
X! selected).
X  
X  It is important to note that the contents of the ``\s-1\fICMD\fP_ARGS\s+1''
X  environment variable are NOT expanded by the shell and hence any special
X*** doc/env_parse.inc.OLD	Tue Mar 26 11:31:46 1991
X--- doc/env_parse.inc	Tue Mar 26 10:46:48 1991
X***************
X*** 25,31 ****
X  Ignore any unrecognized or improperly specified command-line arguments
X  and continue execution of the program. Normally, if an argument is
X  unmatched (or is improperly specified), a usage message is printed
X! program execution is terminated.
X  .\"----------------------
X  .IP "\fIOptsOnly\fP"
X  Under UNIX, setting this flag will disable the parsing of long-option
X--- 25,31 ----
X  Ignore any unrecognized or improperly specified command-line arguments
X  and continue execution of the program. Normally, if an argument is
X  unmatched (or is improperly specified), a usage message is printed
X! and program execution is terminated.
X  .\"----------------------
X  .IP "\fIOptsOnly\fP"
X  Under UNIX, setting this flag will disable the parsing of long-option
X***************
X*** 53,65 ****
X  considered to consist of one option and one positional argument.
X  .\"----------------------
X  .IP "\fICaseIgnore\fP"
X! Setting this flag cause character-case to be ignored when attempting
X  to match single-character argument names (i.e. causes "-i" and "-I"
X  will be considered equivalent).
X  .sp 4p
X  .PP
X  If the environment variable ``\s-1PARSECNTL\s+1'' is empty or
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--- 53,65 ----
X  considered to consist of one option and one positional argument.
X  .\"----------------------
X  .IP "\fICaseIgnore\fP"
X! Setting this flag causes character-case to be ignored when attempting
X  to match single-character argument names (i.e. causes "-i" and "-I"
X  will be considered equivalent).
X  .sp 4p
X  .PP
X  If the environment variable ``\s-1PARSECNTL\s+1'' is empty or
X! undefined, then the 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*** doc/lib_bugs.inc.OLD	Tue Mar 26 11:31:57 1991
X--- doc/lib_bugs.inc	Tue Mar 26 11:13:04 1991
X***************
X*** 7,13 ****
X  When a non-multivalued argument appears more than once on the command-line
X  then only the last value supplied is used. A problem occurs however in the
X  following scenario: suppose `\fB\-s\fP' is an option that takes an optional
X! string argument (nd suppose `\fB\-x\fP' is some boolean flag). Then if the
X  following command-line is issued:
X  
X  .RS
X--- 7,13 ----
X  When a non-multivalued argument appears more than once on the command-line
X  then only the last value supplied is used. A problem occurs however in the
X  following scenario: suppose `\fB\-s\fP' is an option that takes an optional
X! string argument (and suppose `\fB\-x\fP' is some boolean flag). Then if the
X  following command-line is issued:
X  
X  .RS
X*** doc/lparseargs3.inc.OLD	Tue Mar 26 11:32:01 1991
X--- doc/lparseargs3.inc	Tue Mar 26 10:54:24 1991
X***************
X*** 4,7 ****
X  .\"----------------------------------------------------------------------------
X  .PP
X  Given an ArgList and an argdesc array, \fIlparseargs\fP
X! will parse arguments in a file in much the same manner as \fIparseargs\fP.
X--- 4,7 ----
X  .\"----------------------------------------------------------------------------
X  .PP
X  Given an ArgList and an argdesc array, \fIlparseargs\fP
X! will parse arguments in an ArgList in much the same manner as \fIparseargs\fP.
X*** doc/multivals.inc.OLD	Tue Mar 26 11:32:05 1991
X--- doc/multivals.inc	Tue Mar 26 11:08:39 1991
X***************
X*** 22,35 ****
X  ArgList structure. \s-1L_NEXT\s+1 returns the address of the next item in the
X  list and \s-1L_STRING\s+1 returns the string-value of the current list-item.
X  \s-1L_FLAGS\s+1 return the arg-flags for a given item in the list. With
X! non-multivalued, only the flags in the argument descriptor are needed; lists
X! and vectors however need a set of flags for each item they contain. 
X! Once an arg-list has been created, it may be deallocated using the function
X  .I listFree.
X  .I ListFree
X! takes two parameters, the first of which is the address of the first item in
X! the arg-list, and the second of which is a boolean value that is \s-1TRUE\s+1
X! only if each value pointed to by each item should also be deallocated.
X  .PP
X  An alternative to argument-lists is argument vectors (or arg-vectors).
X  Arg-vectors use the \s-1ARGVEC\s+1 flag instead of the \s-1ARGLIST\s+1 flag
X--- 22,35 ----
X  ArgList structure. \s-1L_NEXT\s+1 returns the address of the next item in the
X  list and \s-1L_STRING\s+1 returns the string-value of the current list-item.
X  \s-1L_FLAGS\s+1 return the arg-flags for a given item in the list. With
X! non-multivalued arguments, only the flags in the argument descriptor are
X! needed; lists and vectors however need a set of flags for each item they
X! contain. Once an arg-list has been created, it may be deallocated using
X! the function
X  .I listFree.
X  .I ListFree
X! takes one parameter: first of which is the address of the first item in
X! the arg-list.
X  .PP
X  An alternative to argument-lists is argument vectors (or arg-vectors).
X  Arg-vectors use the \s-1ARGVEC\s+1 flag instead of the \s-1ARGLIST\s+1 flag
X*** doc/parseargs.man1.OLD	Tue Mar 26 11:32:11 1991
X--- doc/parseargs.man1	Tue Mar 26 10:34:35 1991
X***************
X*** 188,194 ****
X  the calling program is needed in order for \fBparseargs\fP to be able to
X  distinguish options to itself from options for the calling program.
X  .PP
X! The default behavior of parseargs is allow both single-character options and
X  long-options (keywords) on the command-line. The user may specify that only
X  options (long-options) are to be permitted by specifying the \fB\-o\fP
X  (\fB\-l\) option on the command-line.
X--- 188,194 ----
X  the calling program is needed in order for \fBparseargs\fP to be able to
X  distinguish options to itself from options for the calling program.
X  .PP
X! The default behavior of parseargs is to allow both single-character options and
X  long-options (keywords) on the command-line. The user may specify that only
X  options (long-options) are to be permitted by specifying the \fB\-o\fP
X  (\fB\-l\) option on the command-line.
X*** doc/parseargs.man3.OLD	Tue Mar 26 11:32:16 1991
X--- doc/parseargs.man3	Tue Mar 26 11:12:33 1991
X***************
X*** 12,18 ****
X  int  fparseargs(  FILE *fp,  ARGDESC *argd  )
X  int  lparseargs(  ArgList *argls,  ARGDESC *argd  )
X  int  sparseargs(  char *str,  ARGDESC *argd  )
X! int  vparseargs(  ARGDESC *argd,  ...  )
X  void  usage(  const ARGDESC *argd  )
X  .fi
X  .\"-----------------------------------------------------------
X--- 12,18 ----
X  int  fparseargs(  FILE *fp,  ARGDESC *argd  )
X  int  lparseargs(  ArgList *argls,  ARGDESC *argd  )
X  int  sparseargs(  char *str,  ARGDESC *argd  )
X! int  vparseargs(  ARGDESC *argd, int argc,  ...  )
X  void  usage(  const ARGDESC *argd  )
X  .fi
X  .\"-----------------------------------------------------------
X***************
X*** 122,134 ****
X  Its main use is to find the location in which to store the converted value,
X  located in argd\(->ad_valp.
X  The string value to be converted is passed in
X! .IR argp
X  (which will be \s-1NULL\s+1 if the \s-1ARGNOVAL\s+1 flag was set for the
X  corresponding entry in the arg-descriptor table).
X  The
X  .I copyf
X  flag is TRUE if the
X! .I argp
X  string value must be copied when saved.
X  Most non-string types are copied implicitly
X  (for example, integer arguments are stored in binary form,
X--- 122,134 ----
X  Its main use is to find the location in which to store the converted value,
X  located in argd\(->ad_valp.
X  The string value to be converted is passed in
X! .IR vp
X  (which will be \s-1NULL\s+1 if the \s-1ARGNOVAL\s+1 flag was set for the
X  corresponding entry in the arg-descriptor table).
X  The
X  .I copyf
X  flag is TRUE if the
X! .I vp
X  string value must be copied when saved.
X  Most non-string types are copied implicitly
X  (for example, integer arguments are stored in binary form,
X***************
X*** 137,143 ****
X  Put simply, this flag is
X  TRUE
X  when
X! .I argp
X  points to a temporary buffer area.
X  .PP
X  If the type function successfully converts the value,
X--- 137,143 ----
X  Put simply, this flag is
X  TRUE
X  when
X! .I vp
X  points to a temporary buffer area.
X  .PP
X  If the type function successfully converts the value,
X*** doc/parseargs1.inc.OLD	Tue Mar 26 11:32:21 1991
X--- doc/parseargs1.inc	Tue Mar 26 10:27:15 1991
X***************
X*** 14,20 ****
X  extra arguments,
X  and argument values that are syntactically incorrect.
X  Other behavior such as prompting the user for missing arguments and
X! ignoring as command-line syntax may be specified on the command-line
X  through the use of various options, or through the use of the
X  ``\s-1PARSECNTL\s+1'' environment variable.
X  .PP
X--- 14,20 ----
X  extra arguments,
X  and argument values that are syntactically incorrect.
X  Other behavior such as prompting the user for missing arguments and
X! ignoring bad command-line syntax may be specified on the command-line
X  through the use of various options, or through the use of the
X  ``\s-1PARSECNTL\s+1'' environment variable.
X  .PP
X*** doc/sh_arrays.inc.OLD	Tue Mar 26 11:32:52 1991
X--- doc/sh_arrays.inc	Tue Mar 26 10:39:21 1991
X***************
X*** 33,39 ****
X  ``\fB*\fP'', then the positional parameters of the calling program
X  will be re-assigned to the contents of the argument list.
X  .PP
X! For the \fIawk\fP and \fIperl\fP,
X  if the variable name corresponding to the \s-1ARGLIST\s+1 argument is
X  ``\fBARGV\fP'', then the positional parameters of the calling program
X  will be re-assigned to the contents of the argument list.
X--- 33,39 ----
X  ``\fB*\fP'', then the positional parameters of the calling program
X  will be re-assigned to the contents of the argument list.
X  .PP
X! For \fIawk\fP and \fIperl\fP,
X  if the variable name corresponding to the \s-1ARGLIST\s+1 argument is
X  ``\fBARGV\fP'', then the positional parameters of the calling program
X  will be re-assigned to the contents of the argument list.
X***************
X*** 178,188 ****
X  .nf
X  .RS
X  .ft 4
X! @name=( arg1 , arg2 ,  ... )
X  .ft R
X  .RE
X  .fi
X! .SS ""A Final Note on Argument Lists"
X  .PP
X  The word-lists used by the C shell, the arrays used by the Korn shell, the 
X  Plan 9 shell, \fIawk\fP, \fIperl\fP, and the positional parameters used by
X--- 178,188 ----
X  .nf
X  .RS
X  .ft 4
X! @name=( arg1 , arg2 ,  ... );
X  .ft R
X  .RE
X  .fi
X! .SS "A Final Note on Argument Lists"
X  .PP
X  The word-lists used by the C shell, the arrays used by the Korn shell, the 
X  Plan 9 shell, \fIawk\fP, \fIperl\fP, and the positional parameters used by
X*** doc/shells.inc.OLD	Tue Mar 26 11:32:55 1991
X--- doc/shells.inc	Tue Mar 26 10:31:22 1991
X***************
X*** 18,24 ****
X  shell syntax to use. At present, \fBparseargs\fP only recognizes
X  ``sh'', ``csh'', ``ksh'', ``tcsh'', ``bash'', ``rc'', ``awk'', and ``perl''
X  as valid command interpreters. \fIAwk\fP output is slightly different from 
X! that of the other shells in that the actual variable setting are not
X  printed but each line of an associative array is printed (the first field
X  is the array index, the second is the value for that index).
X  If no shell is specified, then the Bourne shell (``sh'') will be assumed.
X--- 18,24 ----
X  shell syntax to use. At present, \fBparseargs\fP only recognizes
X  ``sh'', ``csh'', ``ksh'', ``tcsh'', ``bash'', ``rc'', ``awk'', and ``perl''
X  as valid command interpreters. \fIAwk\fP output is slightly different from 
X! that of the other shells in that the actual variable settings are not
X  printed but each line of an associative array is printed (the first field
X  is the array index, the second is the value for that index).
X  If no shell is specified, then the Bourne shell (``sh'') will be assumed.
X*** parseargs.c.OLD	Tue Mar 26 11:33:29 1991
X--- parseargs.c	Tue Mar 26 10:38:26 1991
X***************
X*** 13,19 ****
X  **    arguments, converts values to the desired type, and diagnoses problems
X  **    such as missing arguments, extra arguments, and argument values that
X  **    are syntactically incorrect.  Other behavior such as prompting the
X! **    user for missing arguments and ignoring as command-line syntax may be
X  **    specified on the command-line through the use of various options, or
X  **    through the use of the "PARSECNTL" environment variable.
X  **
X--- 13,19 ----
X  **    arguments, converts values to the desired type, and diagnoses problems
X  **    such as missing arguments, extra arguments, and argument values that
X  **    are syntactically incorrect.  Other behavior such as prompting the
X! **    user for missing arguments and ignoring bad command-line syntax may be
X  **    specified on the command-line through the use of various options, or
X  **    through the use of the "PARSECNTL" environment variable.
X  **
X***************
X*** 158,164 ****
X  **    to use. At present, parseargs only recognizes "sh", "csh", "ksh",
X  **    "tcsh", "bash", "rc", "awk", and "perl" as valid command interpreters.
X  **    Awk output is slightly different from that of the other shells in that
X! **    the actual variable setting are not printed but each line of an
X  **    associative array is printed (the first field is the array index, the
X  **    second is the value for that index).  If no shell is specified, then
X  **    the Bourne shell ("sh") will be assumed.
X--- 158,164 ----
X  **    to use. At present, parseargs only recognizes "sh", "csh", "ksh",
X  **    "tcsh", "bash", "rc", "awk", and "perl" as valid command interpreters.
X  **    Awk output is slightly different from that of the other shells in that
X! **    the actual variable settings are not printed but each line of an
X  **    associative array is printed (the first field is the array index, the
X  **    second is the value for that index).  If no shell is specified, then
X  **    the Bourne shell ("sh") will be assumed.
X***************
X*** 1578,1584 ****
X  **    For perl, each argument list is considered an array and is set using
X  **    the following syntax:
X  **
X! **         @name=( arg1 , arg2 ,  ... )
X  **
X  ** ^A_Final_Note_on_Argument_Lists:
X  **    The word-lists used by the C shell, the arrays used by the Korn shell,
X--- 1578,1584 ----
X  **    For perl, each argument list is considered an array and is set using
X  **    the following syntax:
X  **
X! **         @name=( arg1 , arg2 ,  ... );
X  **
X  ** ^A_Final_Note_on_Argument_Lists:
X  **    The word-lists used by the C shell, the arrays used by the Korn shell,
X*** parseargs.h.OLD	Tue Mar 26 11:33:56 1991
X--- parseargs.h	Tue Mar 26 11:10:05 1991
X***************
X*** 70,76 ****
X  */ 
X     BOOL (*ad_type) ARGS((struct _argdesc *, char *, BOOL));
X  /*    -- This field is a pointer to a type conversion function (such as the
X! **       ones provided in argtype(3). The type conversion function is respon-
X  **       sible for verifying the validity of the argument, allocating any
X  **       necessary storage for its internal representation, and converting
X  **       the command-line argument into its required internal form. The type
X--- 70,76 ----
X  */ 
X     BOOL (*ad_type) ARGS((struct _argdesc *, char *, BOOL));
X  /*    -- This field is a pointer to a type conversion function (such as the
X! **       ones provided in argtype(3)). The type conversion function is respon-
X  **       sible for verifying the validity of the argument, allocating any
X  **       necessary storage for its internal representation, and converting
X  **       the command-line argument into its required internal form. The type
X***************
X*** 89,108 ****
X  **       pointer to a number, a boolean value, a string, a list, or anything
X  **       else for which there exists a corresponding arg-type function to
X  **       use in the ad_type field. In the case of of parseargs(1) this field
X! **       must be the name of the corresponding shell variable which eventually
X! **       hold the value of the argument given on the command-line.
X  */ 
X     CONST char *ad_prompt;
X  /*    -- This field contains the long-name of the argument and an optional
X  **       description (the description must be separated from the long-name by
X! **       at least one whitespace characters and may optionally be enclosed in
X  **       a set of balanced delimiters (such as parentheses, curly-braces,
X! **       square-brackets, or angle-brackets. If the long-name contains any
X  **       uppercase characters, then the substring of long-name consisting of
X! **       all uppercase characters is used as the argument name and the entire
X! **       long-name is used as the name of the argument-value (if a value my be
X! **       supplied). The long-name may be matched by supplying a unique prefix
X! **       of either the argument name or the argument-value name.
X  */ 
X  } ARGDESC;
X  /**^^**********************************************************************/
X--- 89,108 ----
X  **       pointer to a number, a boolean value, a string, a list, or anything
X  **       else for which there exists a corresponding arg-type function to
X  **       use in the ad_type field. In the case of of parseargs(1) this field
X! **       must be the name of the corresponding shell variable which will
X! **       eventually hold the value of the argument given on the command-line.
X  */ 
X     CONST char *ad_prompt;
X  /*    -- This field contains the long-name of the argument and an optional
X  **       description (the description must be separated from the long-name by
X! **       at least one whitespace character and may optionally be enclosed in
X  **       a set of balanced delimiters (such as parentheses, curly-braces,
X! **       square-brackets, or angle-brackets). If the long-name contains any
X  **       uppercase characters, then the substring of long-name consisting of
X! **       all uppercase characters is used as the argument keyword and the
X! **       entire long-name is used as the name of the argument (if a value may
X! **       be supplied). The long-name may be matched by supplying a unique
X! **       prefix of either the argument keyword or the argument name.
X  */ 
X  } ARGDESC;
X  /**^^**********************************************************************/
X***************
X*** 419,433 ****
X  **    ARGLISTNULL is simply the NULL argument-list pointer.  L_NEXT and
X  **    L_STRING each take a pointer to a non-NULL ArgList structure. L_NEXT
X  **    returns the address of the next item in the list and L_STRING returns
X! **    the string-value of the current list-item.  L_FLAGS return the arg-
X! **    flags for a given item in the list. With non-multivalued, only the
X  **    flags in the argument descriptor are needed; lists and vectors however
X  **    need a set of flags for each item they contain. Once an arg-list has
X  **    been created, it may be deallocated using the function listFree. List-
X! **    Free takes two parameters, the first of which is the address of the
X! **    first item in the arg-list, and the second of which is a boolean value
X! **    that is TRUE only if each value pointed to by each item should also be
X! **    deallocated.
X  **
X  **    An alternative to argument-lists is argument vectors (or arg-vectors).
X  **    Arg-vectors use the ARGVEC flag instead of the ARGLIST flag and do not
X--- 419,430 ----
X  **    ARGLISTNULL is simply the NULL argument-list pointer.  L_NEXT and
X  **    L_STRING each take a pointer to a non-NULL ArgList structure. L_NEXT
X  **    returns the address of the next item in the list and L_STRING returns
X! **    the string-value of the current list-item.  L_FLAGS return the argflags
X! **    for a given item in the list. With non-multivalued arguments, only the
X  **    flags in the argument descriptor are needed; lists and vectors however
X  **    need a set of flags for each item they contain. Once an arg-list has
X  **    been created, it may be deallocated using the function listFree. List-
X! **    Free takes one parameter: the address of the first item in the arg-list.
X  **
X  **    An alternative to argument-lists is argument vectors (or arg-vectors).
X  **    Arg-vectors use the ARGVEC flag instead of the ARGLIST flag and do not
X*** test.rc.OLD	Tue Mar 26 11:35:44 1991
X--- test.rc	Mon Mar 25 09:47:08 1991
X***************
X*** 21,34 ****
X  yflag='TRUE'     ## set defaults (dir="."; count=1; sepch=',') ##
X  
X  ## parse command-line and save assignments in a temporary file ##
X! parseargs -s rc -e ARGUMENTS -u -- $^NAME "$@" >/tmp/tmp$$
X  if ( $status != 0 ) {
X!   rm -f /tmp/tmp$$;
X    exit 2  ## non-zero status (usage given)
X  }
X  
X  ## evaluate results from parseargs and remove temporary file
X! . /tmp/tmp$$;  rm -f /tmp/tmp$$
X  
X  ## echo  the parsed arguments (use defaults if not defined)
X  echo 'ARGUMENTS:'
X--- 21,34 ----
X  yflag='TRUE'     ## set defaults (dir="."; count=1; sepch=',') ##
X  
X  ## parse command-line and save assignments in a temporary file ##
X! parseargs -s rc -e ARGUMENTS -u -- $^NAME $@ >/tmp/tmp$pid
X  if ( $status != 0 ) {
X!   rm -f /tmp/tmp$pid;
X    exit 2  ## non-zero status (usage given)
X  }
X  
X  ## evaluate results from parseargs and remove temporary file
X! . /tmp/tmp$pid;  rm -f /tmp/tmp$pid
X  
X  ## echo  the parsed arguments (use defaults if not defined)
X  echo 'ARGUMENTS:'
X*** xparse.c.OLD	Tue Mar 26 11:36:41 1991
X--- xparse.c	Tue Mar 26 11:12:58 1991
X***************
X*** 63,69 ****
X  **    When a non-multivalued argument appears more than once on the
X  **    command-line then only the last value supplied is used. A problem
X  **    occurs however in the following scenario: suppose `-s' is an option
X! **    that takes an optional string argument (nd suppose `-x' is some
X  **    boolean flag). Then if the following command-line is issued:
X  **
X  **         command  -s string  -x  -s
X--- 63,69 ----
X  **    When a non-multivalued argument appears more than once on the
X  **    command-line then only the last value supplied is used. A problem
X  **    occurs however in the following scenario: suppose `-s' is an option
X! **    that takes an optional string argument (and suppose `-x' is some
X  **    boolean flag). Then if the following command-line is issued:
X  **
X  **         command  -s string  -x  -s
X***************
X*** 1143,1149 ****
X  **                       command-line arguments and continue execution of
X  **                       the program. Normally, if an argument is unmatched
X  **                       (or is improperly specified), a usage message is
X! **                       printed program execution is terminated.
X  **
X  **         "OptsOnly"    Under UNIX, setting this flag will disable the
X  **                       parsing of long-option syntax. This will cause all
X--- 1143,1149 ----
X  **                       command-line arguments and continue execution of
X  **                       the program. Normally, if an argument is unmatched
X  **                       (or is improperly specified), a usage message is
X! **                       printed and program execution is terminated.
X  **
X  **         "OptsOnly"    Under UNIX, setting this flag will disable the
X  **                       parsing of long-option syntax. This will cause all
X***************
X*** 1171,1182 ****
X  **                       examples are considered to consist of one option
X  **                       and one positional argument.
X  **
X! **         "CaseIgnore"  Setting this flag cause character-case to be
X  **                       ignored when attempting to match single-character
X  **                       argument names (i.e. causes "-i" and "-I" will be
X  **                       considered equivalent).
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--- 1171,1182 ----
X  **                       examples are considered to consist of one option
X  **                       and one positional argument.
X  **
X! **         "CaseIgnore"  Setting this flag causes character-case to be
X  **                       ignored when attempting to match single-character
X  **                       argument names (i.e. causes "-i" and "-I" will be
X  **                       considered equivalent).
X  **
X! **    If the environment variable "PARSECNTL" is empty or undefined, then the
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***************
X*** 1997,2003 ****
X    
X  /* ^DESCRIPTION:
X  **    Given an ArgList and an argdesc array, lparseargs will parse arguments
X! **    in a file in much the same manner as parseargs.
X  **
X  ** ^REQUIREMENTS:
X  **    <argls> should be an ArgList of strings
X--- 1997,2003 ----
X    
X  /* ^DESCRIPTION:
X  **    Given an ArgList and an argdesc array, lparseargs will parse arguments
X! **    in an ArgList in much the same manner as parseargs.
X  **
X  ** ^REQUIREMENTS:
X  **    <argls> should be an ArgList of strings
END_OF_FILE
if test 38200 -ne `wc -c <'PATCH'`; then
    echo shar: \"'PATCH'\" unpacked with wrong size!
fi
# end of 'PATCH'
fi
echo shar: End of shell archive.
exit 0

exit 0 # Just in case...
-- 
Kent Landfield                   INTERNET: kent at 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 at uunet.uu.net.



More information about the Comp.sources.misc mailing list