home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume26 / parseargs / patch10 / PATCH10
Encoding:
Text File  |  1991-12-27  |  15.4 KB  |  461 lines

  1. *** MANIFEST.OLD    Thu Dec  5 09:54:30 1991
  2. --- MANIFEST    Tue Nov 26 16:39:21 1991
  3. ***************
  4. *** 47,53 ****
  5.    parseargs.c                8    C source for parseargs(1)
  6.    parseargs.h                7    include file for parseargs library
  7.    parseargs.pl               2    parseargs for perl
  8. !  patchlevel.h               2    list of patches (most recent first)
  9.    pgopen.c                   4    pipe output to a pager
  10.    pgopen.h                   1    include file for pgopen.c
  11.    stest.c                    4    test program for parseargs(3)
  12. --- 47,53 ----
  13.    parseargs.c                8    C source for parseargs(1)
  14.    parseargs.h                7    include file for parseargs library
  15.    parseargs.pl               2    parseargs for perl
  16. !  patchlevel.h               3    list of patches (most recent first)
  17.    pgopen.c                   4    pipe output to a pager
  18.    pgopen.h                   1    include file for pgopen.c
  19.    stest.c                    4    test program for parseargs(3)
  20. ***************
  21. *** 62,68 ****
  22.    test.sh                    1    Bourne shell test program for parseargs(1)
  23.    test.zsh                   2    Z shell test program for parseargs(1)
  24.    unix_args.c                5    parse Unix command-lines
  25. !  unix_man.c                 3    print Unix manual-page templates
  26.    useful.h                   3    common include file for the library
  27.    vms_args.c                 6    parse VAX/VMS DCL command-lines
  28.    vprintf.c                  3    portable vfprintf, vprintf, and vsprintf
  29. --- 62,68 ----
  30.    test.sh                    1    Bourne shell test program for parseargs(1)
  31.    test.zsh                   2    Z shell test program for parseargs(1)
  32.    unix_args.c                5    parse Unix command-lines
  33. !  unix_man.c                 4    print Unix manual-page templates
  34.    useful.h                   3    common include file for the library
  35.    vms_args.c                 6    parse VAX/VMS DCL command-lines
  36.    vprintf.c                  3    portable vfprintf, vprintf, and vsprintf
  37. *** README.OLD    Thu Dec  5 09:54:39 1991
  38. --- README    Thu Dec  5 09:54:03 1991
  39. ***************
  40. *** 628,633 ****
  41. --- 628,636 ----
  42.    I also provided extensive updating to the manual pages so that they
  43.    now reflect the current capabilities of parseargs!
  44.   
  45. +  Since the FSF has decided to change the use of '+' as a long-option prefix
  46. +  to '--' (in order to be POSIX conformant), I added some #ifdef POSIX_SOURCE
  47. +  code to unix_args.c to use '--' instead of '+' as the long option prefix.
  48.   
  49.    MODIFICATIONS TO parseargs.h
  50.    ============================
  51. ***************
  52. *** 770,776 ****
  53.    If any of the following macros are #defined at compile time then they will
  54.    have the following effect:
  55.   
  56. !     USE_PAGER    --  for Unix systems only. Parseargs will include the code
  57.                        which pipes usage messages to a paging program
  58.   
  59.       NOFLOAT      --  Parseargs will NOT include the code for the predefined
  60. --- 773,779 ----
  61.    If any of the following macros are #defined at compile time then they will
  62.    have the following effect:
  63.   
  64. !     USE_PAGER    --  For Unix systems only. Parseargs will include the code
  65.                        which pipes usage messages to a paging program
  66.   
  67.       NOFLOAT      --  Parseargs will NOT include the code for the predefined
  68. ***************
  69. *** 783,788 ****
  70. --- 786,794 ----
  71.       USE_TERMINFO
  72.       USE_TERMCAP  --  Parseargs will use curses/terminfo/termcap when trying
  73.                        to figure out the size of the screen.
  74. +     POSIX_SOURCE --  For unix_style only. Parseargs will use '--' instead of
  75. +                      '+' as the long-option prefix.
  76.   
  77.    IBM-PC VERSION OF parseargs(3)
  78.    ==============================
  79. *** amiga_args.c.OLD    Thu Dec  5 09:54:49 1991
  80. --- amiga_args.c    Tue Nov 26 16:31:18 1991
  81. ***************
  82. *** 518,524 ****
  83.   
  84.         if ( description  &&  *description ) {
  85.            fprintf( fp, "Description:\n" );
  86. !          indent_para(fp, max_cols, 8, "", 0, description);
  87.            fputc( '\n', fp );
  88.         }
  89.      }/*if*/
  90. --- 518,524 ----
  91.   
  92.         if ( description  &&  *description ) {
  93.            fprintf( fp, "Description:\n" );
  94. !          indent_para(fp, max_cols, 8, "", 0, description, 0);
  95.            fputc( '\n', fp );
  96.         }
  97.      }/*if*/
  98. *** doc/parseargs.man3.OLD    Thu Dec  5 09:55:16 1991
  99. --- doc/parseargs.man3    Thu Dec  5 09:41:33 1991
  100. ***************
  101. *** 197,203 ****
  102.   Under \s-1UNIX\s+1, \s-1MS-DOS\s+1, and \s-1OS\s+1/2,
  103.   \fIparseargs\fP also allows for long
  104.   options in addition to single character options.
  105. ! Under \s-1UNIX\s+1, long options are denoted by a `\fB+\fP' character.
  106.   Under \s-1MS-DOS\s+1, and \s-1OS\s+1/2, long options are denoted by the second
  107.   character in the \s-1SWITCHAR\s+1 environment variable. If there is no second
  108.   character, then if the first character is `\-', then a `\fB+\fP' is used,
  109. --- 197,205 ----
  110.   Under \s-1UNIX\s+1, \s-1MS-DOS\s+1, and \s-1OS\s+1/2,
  111.   \fIparseargs\fP also allows for long
  112.   options in addition to single character options.
  113. ! Under \s-1UNIX\s+1, long options are denoted by a `\fB+\fP' character 
  114. ! (unless \fIparseargs\fP was compiled for conformance with POSIX, inc which
  115. ! case the long option prefix is `\fB\-\|\-\fP').
  116.   Under \s-1MS-DOS\s+1, and \s-1OS\s+1/2, long options are denoted by the second
  117.   character in the \s-1SWITCHAR\s+1 environment variable. If there is no second
  118.   character, then if the first character is `\-', then a `\fB+\fP' is used,
  119. *** ibm_args.c.OLD    Thu Dec  5 09:55:31 1991
  120. --- ibm_args.c    Tue Nov 26 16:31:27 1991
  121. ***************
  122. *** 764,770 ****
  123.   
  124.         if ( description  &&  *description ) {
  125.            fprintf( fp, "Description:\n" );
  126. !          indent_para(fp, max_cols, 8, "", 0, description);
  127.            fputc( '\n', fp );
  128.         }
  129.      }/*if*/
  130. --- 764,770 ----
  131.   
  132.         if ( description  &&  *description ) {
  133.            fprintf( fp, "Description:\n" );
  134. !          indent_para(fp, max_cols, 8, "", 0, description, 0);
  135.            fputc( '\n', fp );
  136.         }
  137.      }/*if*/
  138. *** patchlevel.h.OLD    Thu Dec  5 09:55:41 1991
  139. --- patchlevel.h    Thu Dec  5 09:10:23 1991
  140. ***************
  141. *** 2,7 ****
  142. --- 2,17 ----
  143.   ** ^FILE: patchlevel.h - current patchlevel for parseargs
  144.   **
  145.   ** ^HISTORY:
  146. + **    12/05/91    Brad Appleton    <brad@ssd.csd.harris.com>
  147. + **    Patch10
  148. + **    - Fix bug that was introduced in last patch. Pgopen() was not
  149. + **      using $USAGE_PAGER, it was only using $PAGER.
  150. + **    - When Earl added the extra argument to indent_para(), he forgot to
  151. + **      include the argument when printing the command description. I added
  152. + **      this into *_args.c
  153. + **    - Added #ifdef POSIX_SOURCE stuff to unix_args.c to allow the use 
  154. + **      of '--' instead of '+' as the long option prefix.
  155. + **
  156.   **    08/27/91    Brad Appleton    <brad@ssd.csd.harris.com>
  157.   **    08/27/91    Earl Chew    <cechew@bruce.cs.monash.edu.au>
  158.   **    Patch09
  159. ***************
  160. *** 19,25 ****
  161.   **      at odds with the documentation and requires (int *) on reads.
  162.   **      Also, should check for NULL cmd-name before passing it to strdup().
  163.   **    - vms_args.c/is_cmdline():
  164. ! **      Mike Level pointed out to me that if lib$get_foreing returns a
  165.   **      zero-length string then the proper actions are not taken. This
  166.   **      has been fixed.
  167.   **    - vms_args.c, parseargs.h, xparse.c
  168. --- 29,35 ----
  169.   **      at odds with the documentation and requires (int *) on reads.
  170.   **      Also, should check for NULL cmd-name before passing it to strdup().
  171.   **    - vms_args.c/is_cmdline():
  172. ! **      Mike Levin pointed out to me that if lib$get_foreign returns a
  173.   **      zero-length string then the proper actions are not taken. This
  174.   **      has been fixed.
  175.   **    - vms_args.c, parseargs.h, xparse.c
  176. ***************
  177. *** 132,138 ****
  178.   
  179.   #define  VERSION     2
  180.   #define  REVISION    0
  181. ! #define  PATCHLEVEL  9
  182.   
  183.   #ifdef __STDC__
  184.      static const char
  185. --- 142,148 ----
  186.   
  187.   #define  VERSION     2
  188.   #define  REVISION    0
  189. ! #define  PATCHLEVEL  10
  190.   
  191.   #ifdef __STDC__
  192.      static const char
  193. ***************
  194. *** 139,142 ****
  195.   #else
  196.      static char
  197.   #endif
  198. !    _Ident[] = "@(#)parseargs  2.0  patchlevel 9";
  199. --- 149,152 ----
  200.   #else
  201.      static char
  202.   #endif
  203. !    _Ident[] = "@(#)parseargs  2.0  patchlevel 10";
  204. *** pgopen.c.OLD    Thu Dec  5 09:55:48 1991
  205. --- pgopen.c    Wed Nov 27 11:07:35 1991
  206. ***************
  207. *** 32,38 ****
  208.   #include <useful.h>
  209.   
  210.   /* get #defines for access() call */
  211. ! #include <sys/file.h>
  212.   #ifndef X_OK
  213.   #  define X_OK  0x01
  214.   #endif
  215. --- 32,40 ----
  216.   #include <useful.h>
  217.   
  218.   /* get #defines for access() call */
  219. ! #ifndef SYSV
  220. ! # include <sys/file.h>
  221. ! #endif
  222.   #ifndef X_OK
  223.   #  define X_OK  0x01
  224.   #endif
  225. ***************
  226. *** 418,424 ****
  227.      if ( Pager_Type != PG_NONE )   pg_type = Pager_Type;
  228.   
  229.         /* see if the given pager is okay */
  230. !    if ( !pg_name  ||  !*pg_name  ||  !access(pg_name, X_OK) ) {
  231.         pg_name = getenv("PAGER");
  232.      }
  233.      else {
  234. --- 420,426 ----
  235.      if ( Pager_Type != PG_NONE )   pg_type = Pager_Type;
  236.   
  237.         /* see if the given pager is okay */
  238. !    if ( !pg_name  ||  !*pg_name  ||  access(pg_name, X_OK) ) {
  239.         pg_name = getenv("PAGER");
  240.      }
  241.      else {
  242. *** strfuncs.c.OLD    Thu Dec  5 09:56:00 1991
  243. --- strfuncs.c    Wed Nov 27 11:08:42 1991
  244. ***************
  245. *** 32,43 ****
  246.   **       indent_para() -- print an indented hanging paragraph
  247.   **
  248.   ** ^HISTORY:
  249.   **    08/27/91     Earl Chew     <cechew@bruce.cs.monash.edu.au>
  250.   **    - add extra length argument to indent_para().
  251.   **    - add FORCE_KWDCASE() macro
  252.   **    - add non-writable strings support to get_argname() and
  253.   **      get_kwdname()
  254. - **    08/27/91    Earl Chew    <cechew@bruce.cs.monash.edu.au>
  255.   **    - add get_argpfx() and get_argdesc() for non-writable strings
  256.   **      support
  257.   **    - allow zero length string for strsplit()
  258. --- 32,47 ----
  259.   **       indent_para() -- print an indented hanging paragraph
  260.   **
  261.   ** ^HISTORY:
  262. + **
  263. + **    11/26/91     Brad Appleton     <brad@ssd.csd.harris.com>
  264. + **    - added the following to indent_para(). If last arg is 0,
  265. + **      then the whole length is used.
  266. + **
  267.   **    08/27/91     Earl Chew     <cechew@bruce.cs.monash.edu.au>
  268.   **    - add extra length argument to indent_para().
  269.   **    - add FORCE_KWDCASE() macro
  270.   **    - add non-writable strings support to get_argname() and
  271.   **      get_kwdname()
  272.   **    - add get_argpfx() and get_argdesc() for non-writable strings
  273.   **      support
  274.   **    - allow zero length string for strsplit()
  275. ***************
  276. *** 650,660 ****
  277.            do {
  278.               *pwrite++ = c;
  279.            } while ( (c = *pread++) && !strchr(separators, c) );
  280. -          *pwrite++ = '\0';
  281. -          ++count;
  282. -          do {
  283. -             *pwrite++ = c;
  284. -          } while ( (c = *pread++) && !strchr(separators, c) );
  285.           *pwrite++ = '\0';
  286.           ++count;
  287.         }/*if*/
  288. --- 654,659 ----
  289. ***************
  290. *** 1370,1375 ****
  291. --- 1369,1376 ----
  292.      register int idx = 0;
  293.      BOOL first_line = TRUE;
  294.      char ch;
  295. +    if ( ! textlen )  textlen = strlen( text );
  296.   
  297.      /* print the title */
  298.      fprintf( fp, "%*s%-*s", margin, "", indent, title );
  299. *** unix_args.c.OLD    Thu Dec  5 09:56:18 1991
  300. --- unix_args.c    Thu Dec  5 09:21:48 1991
  301. ***************
  302. *** 6,12 ****
  303.   **    vectors and to print Unix usage messages.
  304.   **
  305.   ** ^HISTORY:
  306. ! **    27/08/91     Earl Chew     <cechew@bruce.cs.monash.edu.au>
  307.   **    - Use ProgNameLen when accessing ProgName
  308.   **    - Use get_argdesc() to access description
  309.   **
  310. --- 6,16 ----
  311.   **    vectors and to print Unix usage messages.
  312.   **
  313.   ** ^HISTORY:
  314. ! **    12/05/91     Brad Appleton     <brad@ssd.csd.harris.com>
  315. ! **    - added #ifdef POSIX_SOURCE to use "--" instead of "+" as
  316. ! **      GNU conformant prefix for long options.
  317. ! **
  318. ! **    08/27/91     Earl Chew     <cechew@bruce.cs.monash.edu.au>
  319.   **    - Use ProgNameLen when accessing ProgName
  320.   **    - Use get_argdesc() to access description
  321.   **
  322. ***************
  323. *** 54,67 ****
  324.   #define isOPT(s)  \
  325.      ( !BTEST(cmd_flags(cmd), pa_KWDSONLY)  && \
  326.        !BTEST(cmd_state(cmd), ps_NOFLAGS)  && \
  327. !      *s == c_OPT_PFX  &&  *(s+1) \
  328.      )
  329.   
  330.   #define isKWD(s)  \
  331.      ( !BTEST(cmd_flags(cmd), pa_OPTSONLY)  && \
  332.        !BTEST(cmd_state(cmd), ps_NOFLAGS)  && \
  333. !      *s == c_KWD_PFX  &&  *(s+1) \
  334.      )
  335.   
  336.   
  337.   /***************************************************************************
  338. --- 58,79 ----
  339.   #define isOPT(s)  \
  340.      ( !BTEST(cmd_flags(cmd), pa_KWDSONLY)  && \
  341.        !BTEST(cmd_state(cmd), ps_NOFLAGS)  && \
  342. !      (*s == c_OPT_PFX)  &&  *(s+1) \
  343.      )
  344.   
  345. + #ifndef POSIX_SOURCE
  346.   #define isKWD(s)  \
  347.      ( !BTEST(cmd_flags(cmd), pa_OPTSONLY)  && \
  348.        !BTEST(cmd_state(cmd), ps_NOFLAGS)  && \
  349. !      (*s == c_KWD_PFX)  &&  *(s+1) \
  350.      )
  351. + #else
  352. + #define isKWD(s)  \
  353. +    ( !BTEST(cmd_flags(cmd), pa_OPTSONLY)  && \
  354. +      !BTEST(cmd_state(cmd), ps_NOFLAGS)  && \
  355. +      (*s == c_OPT_PFX)  &&  (*(s+1) == c_OPT_PFX)  &&  *(s+2) \
  356. +    )
  357. + #endif
  358.   
  359.   
  360.   /***************************************************************************
  361. ***************
  362. *** 135,140 ****
  363. --- 147,153 ----
  364.         if ( isKWD(p) ) {  /* we have a keyword here */
  365.            char *s, c = '\0';
  366.   
  367. + #ifndef POSIX_SOURCE
  368.            /* check for `++' to end flags */
  369.            if ( *(p+1) == c_KWD_PFX  &&  !*(p+2) ) {
  370.               BSET( cmd_state(cmd), ps_NOFLAGS );
  371. ***************
  372. *** 141,148 ****
  373. --- 154,165 ----
  374.               cmd_list(cmd) = ARGDESCNULL;
  375.               continue;
  376.            }
  377. + #endif
  378.   
  379.               /* get past prefix and look for possible argument */
  380. + #ifdef POSIX_SOURCE
  381. +          ++p;
  382. + #endif
  383.            s = strpbrk(++p, s_ARG_SEP);
  384.            if(s) {
  385.               c = *s;
  386. ***************
  387. *** 164,170 ****
  388. --- 181,191 ----
  389.            if ( c )  *(s-1) = c;  /* restore the equal sign */
  390.   
  391.            if ( !is_match ) {
  392. + #ifndef POSIX_SOURCE
  393.               usrerr("option %c%s unknown", c_KWD_PFX, p);
  394. + #else
  395. +             usrerr("option %c%c%s unknown", c_OPT_PFX, c_OPT_PFX, p);
  396. + #endif
  397.               parse_error = pe_SYNTAX;
  398.               cmd_list(cmd) = ARGDESCNULL;
  399.               continue;
  400. ***************
  401. *** 525,535 ****
  402. --- 546,565 ----
  403.            sprintf( buf, "%c%c", c_OPT_PFX, arg_cname(ad) );
  404.         }
  405.         else if ( !(usgflags & usg_OPTS) ) {
  406. + #ifndef POSIX_SOURCE
  407.            sprintf( buf, "%c%s", c_KWD_PFX, keyword );
  408. + #else
  409. +          sprintf( buf, "%c%c%s", c_OPT_PFX, c_OPT_PFX, keyword );
  410. + #endif
  411.         }
  412.         else  {  /* use both */
  413. + #ifndef POSIX_SOURCE
  414.            sprintf( buf, "%c%c|%c%s", c_OPT_PFX, arg_cname(ad),
  415.                                       c_KWD_PFX, keyword );
  416. + #else
  417. +          sprintf( buf, "%c%c|%c%c%s", c_OPT_PFX, arg_cname(ad),
  418. +                                       c_OPT_PFX, c_OPT_PFX, keyword );
  419. + #endif
  420.         }
  421.   
  422.         pos = buf + strlen(buf);
  423. ***************
  424. *** 680,686 ****
  425.   
  426.         if ( description  &&  *description ) {
  427.            fprintf( fp, "Description:\n" );
  428. !          indent_para(fp, max_cols, 8, "", 0, description);
  429.            fputc( '\n', fp );
  430.         }
  431.      }/*if*/
  432. --- 710,716 ----
  433.   
  434.         if ( description  &&  *description ) {
  435.            fprintf( fp, "Description:\n" );
  436. !          indent_para(fp, max_cols, 8, "", 0, description, 0);
  437.            fputc( '\n', fp );
  438.         }
  439.      }/*if*/
  440. *** vms_args.c.OLD    Thu Dec  5 09:56:28 1991
  441. --- vms_args.c    Tue Nov 26 16:35:15 1991
  442. ***************
  443. *** 1027,1033 ****
  444.   
  445.         if ( description  &&  *description ) {
  446.            fprintf( fp, "Description:\n" );
  447. !          indent_para(fp, max_cols, 8, "", 0, description);
  448.            fputc( '\n', fp );
  449.         }
  450.      }/*if*/
  451. --- 1027,1033 ----
  452.   
  453.         if ( description  &&  *description ) {
  454.            fprintf( fp, "Description:\n" );
  455. !          indent_para(fp, max_cols, 8, "", 0, description, 0);
  456.            fputc( '\n', fp );
  457.         }
  458.      }/*if*/
  459.