home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume41 / cmdline / patch04 next >
Encoding:
Internet Message Format  |  1994-03-06  |  30.3 KB

  1. From: brad@amber.ssd.csd.harris.com (Brad Appleton)
  2. Newsgroups: comp.sources.misc
  3. Subject: v41i161:  cmdline - C++ Library for parsing command-line arguments, Patch04
  4. Date: 6 Mar 1994 22:58:27 -0600
  5. Organization: Harris Computer Systems
  6. Sender: kent@sparky.sterling.com
  7. Approved: kent@sparky.sterling.com
  8. Message-ID: <2lec9j$ho4@sparky.sterling.com>
  9. Reply-To: brad@travis.csd.harris.com
  10. X-Md4-Signature: 3b9547bc42116732c19b423cc7a3d12e
  11.  
  12. Submitted-by: brad@amber.ssd.csd.harris.com (Brad Appleton)
  13. Posting-number: Volume 41, Issue 161
  14. Archive-name: cmdline/patch04
  15. Environment: C++
  16. Patch-To: cmdline: Volume 31, Issue 47-54
  17.  
  18. This is patch-level 4 of "CmdLine":  a C++ library for parsing
  19. command arguments and assigning the corresponding values to program
  20. variables. "CmdLine" includes "cmdparse", a program to provide an
  21. interface to CmdLine for shell-scripts.
  22.  
  23.  To apply this patch:
  24.  --------------------
  25.    0) save this article to a file in your "CmdLine" source directory
  26.  
  27.    1) "cd" to your CmdLine source directory
  28.  
  29.    2) Remove all lines in the sharfile (the file you saved in #0)
  30.       that precede the line that starts with "#! /bin/sh".
  31.  
  32.    3) Run the command "sh sharfile" (or whatever you named your sharfile).
  33.       This will create a file named "PATCH04" in your current directory,
  34.  
  35.    4) Run "patch -p0 < PATCH04"
  36.  
  37. For those of you who are unfamiliar with "CmdLine" and "cmdparse",
  38. an overview is included later on in this article. You can send
  39. e-mail to me at brad@ssd.csd.harris.com if you want the complete
  40. C++ source.
  41.  
  42.  Changes in this release:
  43.  ------------------------
  44.  
  45.  - fixed a slight bug in keyword matching which only reared its ugly head
  46.    in unusual situations. The problem was an uninitialized variable.
  47.  
  48.  - removed the PRINT/NOPRINT enum constants to CmdLine::error() use the
  49.    existing constant CmdLine::QUIET instead.
  50.  
  51.  - beefed up some of the comments in the public header files and updated
  52.    the man page with some of the interface changes.
  53.  
  54.  ------------------------------------------------------------------------------
  55.  
  56.  
  57.                     An overview of CmdLine and cmdparse
  58.                     ===================================
  59.  
  60.                  by Brad Appleton <brad@ssd.csd.harris.com>
  61.  
  62.  
  63.  
  64.  Introduction
  65.  ------------
  66.  CmdLine is a C++ Library for parsing command-line arguments. It is 
  67.  approximately 2000 lines of C++ code (excluding comments).
  68.  
  69.  Cmdparse is a command-line interface to CmdLine for Unix shell-scripts.
  70.  It is approximately 1200 lines of C++ code (excluding comments).
  71.  
  72.  
  73.  CmdLine(3C++)
  74.  -------------
  75.  CmdLine is a set of classes to parse command-line arguments.  Unlike
  76.  getopt() and its variants, CmdLine does more than just split up the
  77.  command-line into some canonical form.  CmdLine will actually parse
  78.  the command-line, assigning the appropriate command-line values to
  79.  the corresponding objects, and will verify the command-line syntax
  80.  (and print a usage message if necessary) all in one member function
  81.  call.  Furthermore, many features of CmdLine's parsing behavior are
  82.  configurable at run-time.  These features include the following:
  83.  
  84.      o  Prompting the user for missing arguments.
  85.      o  Allowing keywords (-count=4) and/or options (-c4).
  86.      o  Ignoring bad syntax instead of terminating.
  87.      o  Ignoring upper/lower case on the command-line.
  88.      o  Suppressing the printing of syntax error messages.
  89.      o  Controlling the verboseness of usage messages.
  90.      o  Controlling whether or not options may be processed
  91.           after positional parameters have been seen.
  92.  
  93.  CmdLine also allows for options that take an optional argument, options
  94.  that take a (possibly optional) list of one or more arguments, sticky
  95.  options (options whose argument must reside in the same token as the
  96.  option itself), and options whose argument must reside in a separate
  97.  token from the option itself.
  98.  
  99.  CmdLine consists of a set of C++ classes to parse arguments from an
  100.  input source called a CmdLineArgIter (which is a base class for iterating
  101.  over arguments from an arbitrary input source).  Argument iterators are
  102.  defined for an argv[] array (with or without a corresponding argc), for
  103.  a string of tokens that are separated by a given set of delimiters, and
  104.  for an input-stream.  Users can easily extend CmdLine to parse arguments
  105.  from other input sources simply by creating their own argument iterator
  106.  classes derived from the CmdLineArgIter class defined in <cmdline.h>.
  107.  
  108.  Command-line arguments are themselves objects that contain a specific
  109.  command-line interface, and a function that performs the desired actions
  110.  when its corresponding argument is seen on the command line.  Predefined
  111.  command-line argument types (derived from the abstract class CmdArg in
  112.  <cmdline.h>) exist for boolean, integer, floating-point, character, and
  113.  string arguments, and for lists of integers, floats, and strings.  These
  114.  predefined subclasses of CmdArg may be found in <cmdargs.h>.  Users can
  115.  also create their own command-argument types on the fly by defining and
  116.  implementing an appropriate subclass of the CmdArg class.
  117.  
  118.  Using CmdLine is relatively easy - you need to construct your arguments,
  119.  your command-line, and your argument iterator.  Then all that is left to
  120.  do is call the "parse" member function of your CmdLine object.  The
  121.  following is a simple example:
  122.  
  123.     #include <stdlib.h>
  124.     #include <iostream.h>
  125.     #include <cmdargs.h>
  126.  
  127.     int  main(int argc, char * argv[])
  128.     {
  129.           // Declare arguments
  130.        CmdArgInt  count('c', "count", "number", "number of copies to print.");
  131.        CmdArgBool xflag('x', "xmode", "turn on 'x'-mode.");
  132.        CmdArgChar fdsep('s', "separator", "char", "field-separator to use.");
  133.        CmdArgStr  input("input-file",  "input file to read.");
  134.        CmdArgStrList  output("[output-file ...]",  "where to print output.");
  135.  
  136.           // Declare command object and its argument-iterator
  137.        CmdLine  cmd(*argv, &count, &xflag, &fdsep, &input, &output, NULL);
  138.        CmdArgvIter  arg_iter(--argc, ++argv);
  139.  
  140.           // Initialize arguments to appropriate default values.
  141.        count = 1;
  142.        xflag = 0;
  143.        fdsep = ',';
  144.  
  145.           // Parse arguments
  146.        cmd.parse(arg_iter);
  147.  
  148.           // Print arguments
  149.        cout << "count=" << count << endl ;
  150.        cout << "xflag=" << (xflag ? "ON" : "OFF") << endl ;
  151.        cout << "fdsep='" << (char) fdsep << "'" << endl ;
  152.        cout << "input=\"" << input << "\"" << endl ;
  153.        
  154.        for (int i = 0 ; i < output.count() ; i++) {
  155.           cout << "output[" << i << "]=" << output[i] << endl ;
  156.        }
  157.  
  158.        return  0;
  159.     }
  160.  
  161.  
  162.  The Unix command-line syntax for the above program would be as follows:
  163.  
  164.     Usage: progname [-c number] [-x] [-s char] input-file [output-file ...]
  165.  
  166.     Options/Arguments:
  167.             -c number        number of copies to print.
  168.             -x               turn on 'x'-mode.
  169.             -s char          field-separator to use.
  170.             input-file       input file to read.
  171.             output-file ...  where to print output.
  172.  
  173.  
  174.  The Unix command-line syntax using long-options (keywords) for the above
  175.  program would be as follows:
  176.  
  177.     Usage: progname [--count number] [--xmode] [--separator char]
  178.                     input-file [output-file ...]
  179.  
  180.     Options/Arguments:
  181.             --count number    number of copies to print.
  182.             --xmode           turn on 'x'-mode.
  183.             --separator char  field-separator to use.
  184.             input-file        input file to read.
  185.             output-file ...   where to print output.
  186.  
  187.  If desired, one can set a configuration flag at run-time to allow "+"
  188.  to also be recognized (in addition to "--") as a long-option prefix.
  189.  
  190.  By default, CmdLine allows both options and long-options to appear on the
  191.  command-line. You can instruct CmdLine to disallow one or the other however.
  192.  As an "extra", when options are disallowed, the "-" prefix is assumed to
  193.  denote a long-option instead of an option (hence either "-" or "--" denotes
  194.  a keyword in this case).  Using this feature, CmdLine can be used to supply
  195.  the type of long-option syntax that is now becoming quite popular in the
  196.  Unix world. Using this "new" syntax, the command-line syntax for the above
  197.  command would be the following:
  198.  
  199.     Usage: progname [-count number] [-xmode] [-separator char]
  200.                     input-file [output-file ...]
  201.  
  202.     Options/Arguments:
  203.             -count number    number of copies to print.
  204.             -xmode           turn on 'x'-mode.
  205.             -separator char  field-separator to use.
  206.             input-file       input file to read.
  207.             output-file ...  where to print output.
  208.  
  209.  
  210.  It should be mentioned that, when long-options are used, only a unique
  211.  prefix of the keyword needs to be given (and character-case is ignored).
  212.  Hence, in the above example, "-x", "-X", and "-xm" will match "-xmode".
  213.  
  214.  
  215.  cmdparse(1)
  216.  -----------
  217.   Using "cmdparse" is even easier than using CmdLine. You declare your
  218.   arguments in a string and then you invoke cmdparse with the command
  219.  line of your shell-script and cmdparse will output a script of variable
  220.  settings for you to evaluate.  The following is an example (using the
  221.  same arguments as in our sample program):
  222.  
  223.     #!/bin/sh
  224.     NAME="`/bin/basename $0`"
  225.  
  226.     ARGS='
  227.        ArgInt   count  "[c|count number]"    "number of copies to print."
  228.        ArgBool  xflag  "[x|xmode]"           "turn on x-mode."
  229.        ArgChar  fdsep  "[s|separator char]"  "field-separator to use."
  230.        ArgStr   input  "input-file"          "input file to read."
  231.        ArgStr   output "[output-file ...]"   "where to print output."
  232.     '
  233.  
  234.     if  cmdparse -shell=sh -decls="$ARGS" -- $NAME "$@" > tmp$$
  235.     then
  236.        . tmp$$
  237.        /bin/rm -f tmp$$
  238.     else
  239.        EXITVAL=$?
  240.        /bin/rm -f tmp$$
  241.        exit $EXITVAL
  242.     fi
  243.  
  244.     echo "xflag=" $xflag
  245.     echo "count=" $count
  246.     echo "fdsep=" $fdsep
  247.     echo "input=" $input
  248.     if [ "$output" ] ; then
  249.        echo "output=" $output
  250.     fi
  251.  
  252.  
  253.  Note that you declare the syntax of an argument differently for cmdparse
  254.  than for CmdLine. The syntax for a single argument for cmdparse looks like
  255.  the following:
  256.  
  257.     <arg-type>  <arg-name>  <syntax>  <description>
  258.  
  259.  Where <arg-type> is one of the following:
  260.  
  261.     ArgInt     --  an integer value (or list of values)
  262.     ArgFloat   --  a floating-point value (or list of values)
  263.     ArgChar    --  a character value (or list of values)
  264.     ArgStr     --  a string value (or list of values)
  265.     ArgBool    --  a boolean flag that is turned ON
  266.     ArgClear   --  a boolean flag that is turned OFF
  267.     ArgToggle  --  a boolean flag that is toggled
  268.     ArgUsage   --  print usage and exit
  269.     ArgDummy   --  a dummy argument
  270.  
  271.  If desired, the leading "Arg" portion may be omitted from the type-name.
  272.  
  273.  <arg-name> is simply the name of the variable in your script that you wish
  274.  to contain the resultant value from the command-line.  Any default value
  275.  must be assigned to the variable before invoking cmdparse.
  276.  
  277.  <syntax> and <description> *MUST* be enclosed in either single or double
  278.  quotes! <description> is simply that, the description of the argument.
  279.  
  280.  <syntax> is a little trickier, there are three basic forms of syntax:
  281.  
  282.    1)  "c|keyword"        -- an option that takes no value
  283.    2)  "c|keyword value"  -- an option that takes a value
  284.    3)  "value"            -- a positional parameter
  285.  
  286.  Note that the option-character MUST precede the keyword-name and that
  287.  there must be NO spaces surrounding the '|' in "c|keyword"!
  288.  
  289.  Any "optional" parts of the argument should appear inside square-brackets
  290.  ('[' and ']') and a list of values is denoted by an ellipsis (" ...").
  291.  Most options will be inside of square brackets to reflect the fact that
  292.  they are "optional".
  293.  
  294.  Some example <syntax> strings follow:
  295.  
  296.     "c|keyword"                -- a required option
  297.     "[c|keyword]"              -- an option with no value
  298.     "[c|keyword value]"        -- an option that takes a value
  299.     "[c|keyword [value]]"      -- an option that takes an optional value
  300.     "[c|keyword value ...]"    -- an option that takes 1 or more values
  301.     "[c|keyword [value ...]]"  -- an option that takes 0 or more values
  302.     "value"                    -- a required positional parameter
  303.     "[value]"                  -- an optional positional-parameter
  304.     "[c|keyword] value"        -- a required argument that may be matched
  305.                                   either positionally or by keyword!
  306.  
  307.  
  308.   Further Information
  309.   -------------------
  310.  This is just a brief overview of what the CmdLine package can do. Please
  311.  read the documentation for a more thorough explanation of this products'
  312.  capabilities and limitations!
  313.  
  314.  _______________________"And miles to go before I sleep."_______________________
  315.  Brad Appleton, Senior Software Engineer    Harris Computer Systems Division
  316.    E-mail: brad@ssd.csd.harris.com          2101 W. Cypress Creek Rd., M/S 161
  317.    Phone : (305) 973-5190                   Fort Lauderdale, FL USA 33309-1892
  318.  ~~~~~~~~~~~~~~~~~~~~Disclaimer: I said it, not my employer!~~~~~~~~~~~~~~~~~~~~
  319. #! /bin/sh
  320. # This is a shell archive.  Remove anything before this line, then unpack
  321. # it by saving it into a file and typing "sh file".  To overwrite existing
  322. # files, type "sh file -c".  You can also feed this as standard input via
  323. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  324. # will see the following message at the end:
  325. #        "End of shell archive."
  326. # Contents:  PATCH04
  327. # Wrapped by brad@amber on Tue Mar  1 18:27:10 1994
  328. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  329. if test -f 'PATCH04' -a "${1}" != "-c" ; then 
  330.   echo shar: Will not clobber existing file \"'PATCH04'\"
  331. else
  332. echo shar: Extracting \"'PATCH04'\" \(16575 characters\)
  333. sed "s/^X//" >'PATCH04' <<'END_OF_FILE'
  334. X*** Overview.OLD    Tue Mar 01 18:25:50 1994
  335. X--- Overview    Fri Feb 04 15:12:19 1994
  336. X***************
  337. X*** 22,28 ****
  338. X   getopt() and its variants, CmdLine does more than just split up the
  339. X   command-line into some canonical form.  CmdLine will actually parse
  340. X   the command-line, assigning the appropriate command-line values to
  341. X!  the corresponding variables, and will verify the command-line syntax
  342. X   (and print a usage message if necessary) all in one member function
  343. X   call.  Furthermore, many features of CmdLine's parsing behavior are
  344. X   configurable at run-time.  These features include the following:
  345. X--- 22,28 ----
  346. X   getopt() and its variants, CmdLine does more than just split up the
  347. X   command-line into some canonical form.  CmdLine will actually parse
  348. X   the command-line, assigning the appropriate command-line values to
  349. X!  the corresponding objects, and will verify the command-line syntax
  350. X   (and print a usage message if necessary) all in one member function
  351. X   call.  Furthermore, many features of CmdLine's parsing behavior are
  352. X   configurable at run-time.  These features include the following:
  353. X***************
  354. X*** 225,231 ****
  355. X   
  356. X   <syntax> is a little trickier, there are three basic forms of syntax:
  357. X  
  358. X!    1)  "c|keyword"        -- an option the takes no value
  359. X     2)  "c|keyword value"  -- an option that takes a value
  360. X     3)  "value"            -- a positional parameter
  361. X  
  362. X--- 225,231 ----
  363. X   
  364. X   <syntax> is a little trickier, there are three basic forms of syntax:
  365. X  
  366. X!    1)  "c|keyword"        -- an option that takes no value
  367. X     2)  "c|keyword value"  -- an option that takes a value
  368. X     3)  "value"            -- a positional parameter
  369. X  
  370. X*** README.OLD    Tue Mar 01 18:25:53 1994
  371. X--- README    Tue Mar 01 18:24:21 1994
  372. X***************
  373. X*** 130,136 ****
  374. X  
  375. X   ACKNOWLEDGEMENTS
  376. X   ================
  377. X!  CmdLine is a C++ rewrite of ParseArgs.  The author of this software would
  378. X   like to thank Eric Allman and Peter da Silva for their great ideas.
  379. X  
  380. X  
  381. X--- 130,136 ----
  382. X  
  383. X   ACKNOWLEDGEMENTS
  384. X   ================
  385. X!  CmdLine is a C++ re-design of ParseArgs.  The author of this software would
  386. X   like to thank Eric Allman and Peter da Silva for their great ideas.
  387. X  
  388. X  
  389. X***************
  390. X*** 139,147 ****
  391. X   For an introduction -- look at the file "Overview" in the distribution!
  392. X  
  393. X   The documentation is in Unix manpage format (troff with the -man macros)
  394. X!  and may be found in the "doc" directory but you should be able to find
  395. X!  out quite a bit by reading the comments in the source files (especially
  396. X!  in <cmdline.h> and <cmdargs.h>) and by looking at the sample test-program(s).
  397. X  
  398. X  
  399. X   HISTORY
  400. X--- 139,150 ----
  401. X   For an introduction -- look at the file "Overview" in the distribution!
  402. X  
  403. X   The documentation is in Unix manpage format (troff with the -man macros)
  404. X!  and may be found in the "doc" directory. The man-pages only cover the most
  405. X!  commonly used features. If you want to become an advanced user or gain a
  406. X!  more thorough understanding of the package you should read the header files
  407. X!  <cmdline.h> and <cmdargs.h>. Ample comments are provided particularly for
  408. X!  this purpose. There is also a test-program provided which tests most of
  409. X!  the features of the package.
  410. X  
  411. X  
  412. X   HISTORY
  413. X***************
  414. X*** 211,216 ****
  415. X--- 214,220 ----
  416. X   10/26/93        Brad Appleton        <brad@ssd.csd.harris.com>
  417. X   -----------------------------------------------------------------------------
  418. X   - documented "secret" arguments in cmdparse(1)
  419. X+ 
  420. X   - fixed the following bug:
  421. X       CmdLine did not properly handle an "interrupted" positional-list.
  422. X       For example, If I have a program whose syntax is:
  423. X***************
  424. X*** 225,228 ****
  425. X--- 229,243 ----
  426. X       CmdLine was not correctly recognizing that "arg2" was part of
  427. X       the the previously specified positional list. This has been
  428. X       fixed!
  429. X+ 
  430. X+  02/10/94        Brad Appleton        <brad@ssd.csd.harris.com>
  431. X+  -----------------------------------------------------------------------------
  432. X+  - fixed a slight bug in keyword matching which only reared its ugly head
  433. X+    in unusual situations. The problem was an uninitialized variable.
  434. X+ 
  435. X+  - removed the PRINT/NOPRINT enum constants to CmdLine::error() use the
  436. X+    existing constant CmdLine::QUIET instead.
  437. X+ 
  438. X+  - beefed up some of the comments in the public header files and updated
  439. X+    the man page with some of the interface changes.
  440. X  
  441. X*** doc/classes.man.OLD    Tue Mar 01 18:25:58 1994
  442. X--- doc/classes.man    Thu Feb 10 11:23:27 1994
  443. X***************
  444. X*** 350,358 ****
  445. X  .sp 2p
  446. X     OPTS_FIRST    = 0x008, // No options after positional parameters
  447. X  .sp 2p
  448. X!    OPTS_ONLY     = 0x010, // Don't accept short-options
  449. X  .sp 2p
  450. X!    KWDS_ONLY     = 0x020, // Don't accept long-options
  451. X  .sp 2p
  452. X     TEMP          = 0x040, // Assume all arg-strings are temporary
  453. X  .sp 2p
  454. X--- 350,358 ----
  455. X  .sp 2p
  456. X     OPTS_FIRST    = 0x008, // No options after positional parameters
  457. X  .sp 2p
  458. X!    OPTS_ONLY     = 0x010, // Don't accept long-options
  459. X  .sp 2p
  460. X!    KWDS_ONLY     = 0x020, // Don't accept short-options
  461. X  .sp 2p
  462. X     TEMP          = 0x040, // Assume all arg-strings are temporary
  463. X  .sp 2p
  464. X***************
  465. X*** 363,368 ****
  466. X--- 363,371 ----
  467. X                               // when we see an unmatched option,
  468. X                               // we will try to see if it matches
  469. X                               // a keyword (and vice-versa).
  470. X+ .sp 2p
  471. X+    ALLOW_PLUS    = 0x200, // Allow "+" (as well as "--") as a prefix
  472. X+                                 // indicating long-options.
  473. X  } ;
  474. X  
  475. X     // Get the current set of command-flags
  476. X*** src/cmd/syntax.c.OLD    Tue Mar 01 18:26:14 1994
  477. X--- src/cmd/syntax.c    Thu Feb 17 09:44:12 1994
  478. X***************
  479. X*** 31,37 ****
  480. X  //    const char * & dest;
  481. X  //    -- where to house the duplicated token
  482. X  //
  483. X! //    SyntaxFSM::token_t src;
  484. X  //    -- the token to copy.
  485. X  //
  486. X  // ^DESCRIPTION:
  487. X--- 31,37 ----
  488. X  //    const char * & dest;
  489. X  //    -- where to house the duplicated token
  490. X  //
  491. X! //    const SyntaxFSM::token_t & src;
  492. X  //    -- the token to copy.
  493. X  //
  494. X  // ^DESCRIPTION:
  495. X***************
  496. X*** 50,56 ****
  497. X  //    Trivial.
  498. X  //-^^----------------
  499. X  void
  500. X! copy_token(const char * & dest, SyntaxFSM::token_t src)
  501. X  {
  502. X     char * tok = new char[src.len + 1] ;
  503. X     ::strncpy(tok, src.start, src.len);
  504. X--- 50,56 ----
  505. X  //    Trivial.
  506. X  //-^^----------------
  507. X  void
  508. X! copy_token(const char * & dest, const SyntaxFSM::token_t & src)
  509. X  {
  510. X     char * tok = new char[src.len + 1] ;
  511. X     ::strncpy(tok, src.start, src.len);
  512. X*** src/lib/argiter.c.OLD    Tue Mar 01 18:26:18 1994
  513. X--- src/lib/argiter.c    Thu Feb 10 14:33:25 1994
  514. X***************
  515. X*** 107,112 ****
  516. X--- 107,118 ----
  517. X     delete  tok_iter;
  518. X  }
  519. X  
  520. X+ #ifdef vms
  521. X+    enum { c_COMMENT = '#' } ;
  522. X+ #else
  523. X+    enum { c_COMMENT = '!' } ;
  524. X+ #endif
  525. X+ 
  526. X     // Iterator function -- operator()
  527. X     //
  528. X     // What we do is this: for each line of text in the istream, we use
  529. X***************
  530. X*** 129,135 ****
  531. X        is.getline(buf, sizeof(buf));
  532. X        char * ptr = buf;
  533. X        while (isspace(*ptr)) ++ptr;
  534. X!       if (*ptr && (*ptr != CmdIstreamIter::c_COMMENT)) {
  535. X           if (tok_iter) {
  536. X              tok_iter->reset(ptr);
  537. X           } else {
  538. X--- 135,141 ----
  539. X        is.getline(buf, sizeof(buf));
  540. X        char * ptr = buf;
  541. X        while (isspace(*ptr)) ++ptr;
  542. X!       if (*ptr && (*ptr != c_COMMENT)) {
  543. X           if (tok_iter) {
  544. X              tok_iter->reset(ptr);
  545. X           } else {
  546. X*** src/lib/cmdargs.h.OLD    Tue Mar 01 18:26:23 1994
  547. X--- src/lib/cmdargs.h    Fri Feb 11 16:46:47 1994
  548. X***************
  549. X*** 141,147 ****
  550. X  
  551. X     // Look under "List Arguments" for a CmdArg that is a list of ints
  552. X  
  553. X!    // CmdArgIntCompiler is the base class for all arguments need to
  554. X     // convert the string given on the command-line into an integer.
  555. X     //
  556. X  class  CmdArgIntCompiler : public CmdArg {
  557. X--- 141,147 ----
  558. X  
  559. X     // Look under "List Arguments" for a CmdArg that is a list of ints
  560. X  
  561. X!    // CmdArgIntCompiler is the base class for all arguments that need to
  562. X     // convert the string given on the command-line into an integer.
  563. X     //
  564. X  class  CmdArgIntCompiler : public CmdArg {
  565. X*** src/lib/cmdline.c.OLD    Tue Mar 01 18:26:27 1994
  566. X--- src/lib/cmdline.c    Thu Feb 10 14:45:06 1994
  567. X***************
  568. X*** 285,294 ****
  569. X     // Print an error message prefix and return a reference to the
  570. X     // error output stream for this command
  571. X  ostream &
  572. X! CmdLine::error(int  print) const
  573. X  {
  574. X     ostream * os = (cmd_err) ? cmd_err : &cerr ;
  575. X!    if (print && cmd_name && *cmd_name)  *os << cmd_name << ": " ;
  576. X     return  *os;
  577. X  }
  578. X  
  579. X--- 285,294 ----
  580. X     // Print an error message prefix and return a reference to the
  581. X     // error output stream for this command
  582. X  ostream &
  583. X! CmdLine::error(unsigned  quiet) const
  584. X  {
  585. X     ostream * os = (cmd_err) ? cmd_err : &cerr ;
  586. X!    if (cmd_name && *cmd_name && !quiet)  *os << cmd_name << ": " ;
  587. X     return  *os;
  588. X  }
  589. X  
  590. X*** src/lib/cmdline.h.OLD    Tue Mar 01 18:26:31 1994
  591. X--- src/lib/cmdline.h    Fri Feb 11 16:48:53 1994
  592. X***************
  593. X*** 99,107 ****
  594. X        //
  595. X        // Some examples:
  596. X        //
  597. X!       //    CmdArg('c', "count", "number", "specify the # of copies to use);
  598. X        //
  599. X!       //    CmdArg('d', "debug", "[level]". "turn on debugging and optionally"
  600. X        //                                    "specify the debug level");
  601. X        //
  602. X        //    CmdArg('l', "list", "items ...", "specify a list of items.");
  603. X--- 99,107 ----
  604. X        //
  605. X        // Some examples:
  606. X        //
  607. X!       //    CmdArg('c', "count", "number", "specify the # of copies to use");
  608. X        //
  609. X!       //    CmdArg('d', "debug", "[level]", "turn on debugging and optionally "
  610. X        //                                    "specify the debug level");
  611. X        //
  612. X        //    CmdArg('l', "list", "items ...", "specify a list of items.");
  613. X***************
  614. X*** 197,203 ****
  615. X        // After we have done our "magic" and set the reference parameter
  616. X        // "arg", this function should return a value of 0 if everything
  617. X        // is A-OK and "arg" was a correctly specified value for this type of
  618. X!       // of argument. If something went wrong (like a syntax error in "arg"),
  619. X        // then we should return a non-zero value.
  620. X        //
  621. X     virtual  int
  622. X--- 197,203 ----
  623. X        // After we have done our "magic" and set the reference parameter
  624. X        // "arg", this function should return a value of 0 if everything
  625. X        // is A-OK and "arg" was a correctly specified value for this type of
  626. X!       // argument. If something went wrong (like a syntax error in "arg"),
  627. X        // then we should return a non-zero value.
  628. X        //
  629. X     virtual  int
  630. X***************
  631. X*** 413,424 ****
  632. X  public:
  633. X     static const unsigned  MAX_LINE_LEN ;
  634. X  
  635. X- #ifdef vms
  636. X-    enum { c_COMMENT = '!' } ;
  637. X- #else
  638. X-    enum { c_COMMENT = '#' } ;
  639. X- #endif
  640. X- 
  641. X     CmdIstreamIter(istream & input);
  642. X  
  643. X     virtual ~CmdIstreamIter(void);
  644. X--- 413,418 ----
  645. X***************
  646. X*** 455,462 ****
  647. X        PROMPT_USER   = 0x002, // Prompt the user for missing required args
  648. X        NO_ABORT      = 0x004, // Dont quit upon syntax error
  649. X        OPTS_FIRST    = 0x008, // No options after positional parameters
  650. X!       OPTS_ONLY     = 0x010, // Dont accept short-options
  651. X!       KWDS_ONLY     = 0x020, // Dont accept long-options
  652. X        TEMP          = 0x040, // Assume all arg-strings are temporary
  653. X        QUIET         = 0x080, // Dont print syntax error messages
  654. X        NO_GUESSING   = 0x100, // Dont guess if cant match an option. 
  655. X--- 449,456 ----
  656. X        PROMPT_USER   = 0x002, // Prompt the user for missing required args
  657. X        NO_ABORT      = 0x004, // Dont quit upon syntax error
  658. X        OPTS_FIRST    = 0x008, // No options after positional parameters
  659. X!       OPTS_ONLY     = 0x010, // Dont accept long-options
  660. X!       KWDS_ONLY     = 0x020, // Dont accept short-options
  661. X        TEMP          = 0x040, // Assume all arg-strings are temporary
  662. X        QUIET         = 0x080, // Dont print syntax error messages
  663. X        NO_GUESSING   = 0x100, // Dont guess if cant match an option. 
  664. X***************
  665. X*** 578,590 ****
  666. X        //
  667. X        //    my_cmd.error() << "This is what went wrong!" << endl;
  668. X        //
  669. X!       // If NOPRINT is given as a parameter, then nothing
  670. X!       // is printed.
  671. X        //
  672. X-    enum { NOPRINT = 0, PRINT = 1 } ;
  673. X- 
  674. X     ostream &
  675. X!    error(int  print =PRINT) const;
  676. X  
  677. X        // If the QUIET-flag is not set, then we need to know where
  678. X        // to print any error messages (the default is cerr).
  679. X--- 572,584 ----
  680. X        //
  681. X        //    my_cmd.error() << "This is what went wrong!" << endl;
  682. X        //
  683. X!       // If QUIET (or for that matter, any non-zero value) is given
  684. X!       // as a parameter, then nothing is printed on the ostream
  685. X!       // (which may be useful if you wish only to obtain a reference
  686. X!       // this CmdLine's error-outstream).
  687. X        //
  688. X     ostream &
  689. X!    error(unsigned  quiet =0) const;
  690. X  
  691. X        // If the QUIET-flag is not set, then we need to know where
  692. X        // to print any error messages (the default is cerr).
  693. X***************
  694. X*** 672,681 ****
  695. X  
  696. X     typedef  void (* quit_func_t)(int);
  697. X  
  698. X!       // When a fatal error is encounteredi or when parsing needs to
  699. X        // terminate immediately, the quit() member function is called.
  700. X        // If the programmer has used quit_handler() to setup his own
  701. X!       // handler-function, that that function is called; otherwise
  702. X        // exit() is called with the given status.
  703. X        // 
  704. X     void
  705. X--- 666,675 ----
  706. X  
  707. X     typedef  void (* quit_func_t)(int);
  708. X  
  709. X!       // When a fatal error is encountered or when parsing needs to
  710. X        // terminate immediately, the quit() member function is called.
  711. X        // If the programmer has used quit_handler() to setup his own
  712. X!       // handler-function, then that function is called; otherwise
  713. X        // exit() is called with the given status.
  714. X        // 
  715. X     void
  716. X***************
  717. X*** 749,755 ****
  718. X     strmatch(const char * src, const char * attempt, unsigned  len =0);
  719. X  
  720. X        // Print a hanging indented paragraph on an outstream. Long lines
  721. X!       // are broken at word boundaries and are warpped to line up with
  722. X        // the rest of the paragraph.  The format looks like the following
  723. X        // (text starts on a new line is the strlen(title) >= indent):
  724. X        //
  725. X--- 743,749 ----
  726. X     strmatch(const char * src, const char * attempt, unsigned  len =0);
  727. X  
  728. X        // Print a hanging indented paragraph on an outstream. Long lines
  729. X!       // are broken at word boundaries and are wrapped to line up with
  730. X        // the rest of the paragraph.  The format looks like the following
  731. X        // (text starts on a new line is the strlen(title) >= indent):
  732. X        //
  733. X*** src/lib/patchlevel.c.OLD    Tue Mar 01 18:26:38 1994
  734. X--- src/lib/patchlevel.c    Tue Jan 11 10:49:01 1994
  735. X***************
  736. X*** 18,23 ****
  737. X--- 18,26 ----
  738. X  //
  739. X  //    10/08/93    Brad Appleton    <brad@ssd.csd.harris.com>
  740. X  //    - Modified for patch 3
  741. X+ //
  742. X+ //    01/11/94    Brad Appleton    <brad@ssd.csd.harris.com>
  743. X+ //    - Modified for patch 4
  744. X  //-^^---------------------------------------------------------------------
  745. X  
  746. X  #include "cmdline.h"
  747. X***************
  748. X*** 30,42 ****
  749. X     // file that makes up this version of the project.
  750. X     //
  751. X  static const char ident[] =
  752. X!    "@(#)SMS  task: cmdline-1.03" ;
  753. X  
  754. X  
  755. X     // Release and patchlevel information
  756. X  #define  CMDLINE_RELEASE     1
  757. X! #define  CMDLINE_PATCHLEVEL  3
  758. X! #define  CMDLINE_IDENT       "@(#)CmdLine    1.03"
  759. X  
  760. X  unsigned
  761. X  CmdLine::release(void)  { return  CMDLINE_RELEASE; }
  762. X--- 33,45 ----
  763. X     // file that makes up this version of the project.
  764. X     //
  765. X  static const char ident[] =
  766. X!    "@(#)SMS  task: cmdline-1.04" ;
  767. X  
  768. X  
  769. X     // Release and patchlevel information
  770. X  #define  CMDLINE_RELEASE     1
  771. X! #define  CMDLINE_PATCHLEVEL  4
  772. X! #define  CMDLINE_IDENT       "@(#)CmdLine    1.04"
  773. X  
  774. X  unsigned
  775. X  CmdLine::release(void)  { return  CMDLINE_RELEASE; }
  776. X*** src/lib/private.c.OLD    Tue Mar 01 18:26:41 1994
  777. X--- src/lib/private.c    Tue Jan 11 10:49:21 1994
  778. X***************
  779. X*** 580,586 ****
  780. X           if (cmdarg->is_dummy())  continue;
  781. X  
  782. X           // attempt to match this keyword
  783. X!          strmatch_t  result ;
  784. X           const char * source = cmdarg->keyword_name();
  785. X           if (source && *source) {
  786. X              result = strmatch(source, kwd, len) ;
  787. X--- 580,586 ----
  788. X           if (cmdarg->is_dummy())  continue;
  789. X  
  790. X           // attempt to match this keyword
  791. X!          strmatch_t  result  = str_NONE ;
  792. X           const char * source = cmdarg->keyword_name();
  793. X           if (source && *source) {
  794. X              result = strmatch(source, kwd, len) ;
  795. END_OF_FILE
  796. if test 16575 -ne `wc -c <'PATCH04'`; then
  797.     echo shar: \"'PATCH04'\" unpacked with wrong size!
  798. fi
  799. # end of 'PATCH04'
  800. fi
  801. echo shar: End of shell archive.
  802. exit 0
  803.  
  804. exit 0 # Just in case...
  805.