home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume18 / parseargs / patch04b < prev    next >
Encoding:
Internet Message Format  |  1991-04-26  |  50.1 KB

  1. From: brad@hcx1.ssd.csd.harris.com (Brad Appleton)
  2. Newsgroups: comp.sources.misc
  3. Subject: v18i102:  parseargs - functions to parse command line arguments, Patch04b/4
  4. Message-ID: <1991Apr26.040231.18775@sparky.IMD.Sterling.COM>
  5. Date: 26 Apr 91 04:02:31 GMT
  6. Approved: kent@sparky.imd.sterling.com
  7. X-Checksum-Snefru: 4aa525d0 1f549e4d 8ed6ed4e 4087294b
  8.  
  9. Submitted-by: Brad Appleton <brad@hcx1.ssd.csd.harris.com>
  10. Posting-number: Volume 18, Issue 102
  11. Archive-name: parseargs/patch04b
  12. Patch-To: parseargs: Volume 17, Issue 45-57
  13.  
  14. #!/bin/sh
  15. # This is part 2 of a multipart archive
  16. # do not concatenate these parts, unpack them in order with /bin/sh
  17. # file DOCPATCH continued
  18. #
  19. if test ! -r _shar_seq_.tmp; then
  20.     echo 'Please unpack part 1 first!'
  21.     exit 1
  22. fi
  23. (read Scheck
  24.  if test "$Scheck" != 2; then
  25.     echo Please unpack part "$Scheck" next!
  26.     exit 1
  27.  else
  28.     exit 0
  29.  fi
  30. ) < _shar_seq_.tmp || exit 1
  31. echo 'x - continuing file DOCPATCH'
  32. sed 's/^X//' << 'SHAR_EOF' >> 'DOCPATCH' &&
  33. !      non-string    types are copied implicitly (for example, integer
  34. !      arguments are stored in binary form, so the original string
  35. !      value need    not be saved), so this argument    can usually be
  36. !      ignored.  Put simply, this    flag is    TRUE when vp points to a
  37. !      temporary buffer area.
  38. X  
  39. X       If    the type function successfully converts    the value, and
  40. X       uses the entire value, it should return TRUE.  If the type
  41. ***************
  42. *** 915,920 ****
  43. --- 914,920 ----
  44. X        #define REALLOC(ptr,size)  ((! ptr) ?    malloc(size) : realloc(ptr, size))
  45. X        typedef ARGVEC_T(FILE    *)  FILEvec_t;
  46. X  
  47. +       BOOL    argReadFile(  ARGDESC *ad,  char *vp,  BOOL copyf  )
  48. X  
  49. X  
  50. X  
  51. ***************
  52. *** 929,935 ****
  53. X  
  54. X  
  55. X  
  56. -       BOOL    argReadFile(  ARGDESC *ad,  char *vp,  BOOL copyf  )
  57. X        {
  58. X             register    FILE *fp;
  59. X             fp = fopen(vp, "r");
  60. --- 929,934 ----
  61. ***************
  62. *** 958,969 ****
  63. X        }
  64. X  
  65. X  LONG OPTIONS
  66. !      Under UNIX, Parseargs also    allows for long    options    in addi-
  67. !      tion to single character options. Long options are    denoted
  68. !      by    a `+' character    (which may be changed using keywordpre-
  69. !      fix). The keyword that is used is the first word in the
  70. !      prompt field of an    argument descriptor entry.  Long options
  71. !      are case insensitive! An argument to a long option    may be
  72. X       separated from the    long option by an equal    sign (`=') or by
  73. X       one or more whitespace characters.     Thus, if an entry looks
  74. X       like:
  75. --- 957,972 ----
  76. X        }
  77. X  
  78. X  LONG OPTIONS
  79. !      Under UNIX, MS-DOS, and OS/2, parseargs also allows for long
  80. !      options in    addition to single character options.  Under
  81. !      UNIX, long    options    are denoted by a `+' character.     Under
  82. !      MS-DOS, and OS/2, long options are    denoted    by the second
  83. !      character in the SWITCHAR environment variable. If    there is
  84. !      no    second character, then if the first character is `-',
  85. !      then a `+'    is used, otherwise a `/' is used.  The keyword
  86. !      that is used is the first word in the prompt field    of an
  87. !      argument descriptor entry.    Long options are case insensi-
  88. !      tive!  Under UNIX,    an argument to a long option may be
  89. X       separated from the    long option by an equal    sign (`=') or by
  90. X       one or more whitespace characters.     Thus, if an entry looks
  91. X       like:
  92. ***************
  93. *** 973,989 ****
  94. X  
  95. X       The long option names for ``-?'' in the default argument
  96. X       descriptor    are ``+help'' and ``+?'' (respectively). In addi-
  97. !      tion, ``++'' or ``+endopts'' may be used to indicate the end
  98. !      of    options    so that    all remaining arguments    will be    inter-
  99. !      preted as positional parameters (even if one begins with a
  100. !      `+' or a `-').
  101. X  
  102. -      Under VAX/VMS and AmigaDOS, single-character options are not
  103. -      used and the ``long'' name    (in the    prompt field of    an argu-
  104. -      ment descriptor) is always    used to    match for possible
  105. X  
  106. X  
  107. X  
  108. X  Page 15
  109. X  
  110. X  
  111. --- 976,989 ----
  112. X  
  113. X       The long option names for ``-?'' in the default argument
  114. X       descriptor    are ``+help'' and ``+?'' (respectively). In addi-
  115. !      tion, ``++'' may be used to indicate the end of options so
  116. !      that all remaining    arguments will be interpreted as posi-
  117. !      tional parameters (even if    one begins with    a `+' or a `-').
  118. X  
  119. X  
  120. X  
  121. X  
  122. X  Page 15
  123. X  
  124. X  
  125. ***************
  126. *** 995,1002 ****
  127. X  
  128. X  
  129. X  
  130. !      arguments (or keywords, or    qualifiers).
  131. X  
  132. X       For all supported operating systems, a long option    may be
  133. X       matched in    one of two ways: it may    match all uppercase char-
  134. X       acters in the prompt field, or it may match all characters
  135. --- 995,1012 ----
  136. X  
  137. X  
  138. X  
  139. !      Under MS-DOS, and OS/2, an    argument to a long-option must be
  140. !      separated from the    long option by an equal    sign (`=')
  141. !      (unless the first character of $SWITCHAR is a `-',    in which
  142. !      case UNIX syntax is used).     The long option names for ``/?''
  143. !      in    the default argument descriptor    are ``/help'' and ``/?''
  144. !      (respectively).
  145. X  
  146. +      Under VAX/VMS and AmigaDOS, single-character options are not
  147. +      used and the ``long'' name    (in the    prompt field of    an argu-
  148. +      ment descriptor) is always    used to    match for possible argu-
  149. +      ments (or keywords, or qualifiers).
  150. X       For all supported operating systems, a long option    may be
  151. X       matched in    one of two ways: it may    match all uppercase char-
  152. X       acters in the prompt field, or it may match all characters
  153. ***************
  154. *** 1003,1016 ****
  155. X       in    the prompt field (as in    ``+count=4'' and ``+rep-
  156. X       count=4'').
  157. X  
  158. !      Under UNIX    and VAX/VMS, only the number of    characters
  159. !      required to uniquely identify the desired argument    are
  160. !      needed, but at least two characters must be given (unless
  161. !      the prompt    field is itself    less than two characters long).
  162. !      This means    that using the above example, that ``+rep=4'' and
  163. !      ``+cou=4''    would also work    but ``+c=4'' would NOT (in other
  164. !      words, if you only    want to    use one    character, use ``-c4''
  165. !      instead).
  166. X  
  167. X       Under VAX/VMS, the    possibilities using the    above example
  168. X       would be:    ``/REPCOUNT=4'', ``/COUNT=4'', ``/REP=4'', and
  169. --- 1013,1026 ----
  170. X       in    the prompt field (as in    ``+count=4'' and ``+rep-
  171. X       count=4'').
  172. X  
  173. !      Under all systems except AmigaDOS,    only the number    of char-
  174. !      acters required to    uniquely identify the desired argument
  175. !      are needed, but at    least two characters must be given
  176. !      (unless the prompt    field is itself    less than two characters
  177. !      long). This means that using the above example, that
  178. !      ``+rep=4''    and ``+cou=4'' would also work but ``+c=4'' would
  179. !      NOT (in other words, if you only want to use one character,
  180. !      use ``-c4'' instead).
  181. X  
  182. X       Under VAX/VMS, the    possibilities using the    above example
  183. X       would be:    ``/REPCOUNT=4'', ``/COUNT=4'', ``/REP=4'', and
  184. ***************
  185. *** 1037,1055 ****
  186. X        A command-line syntax    error was encountered
  187. X  
  188. X       pe_DEFARGS
  189. -       An attempt (using parsecntl) was made    to change the
  190. -       default arg-search list of a command to point    to an
  191. -       argdesc-array    which already has the given command on
  192. -       its default arg-search list (which would cause an
  193. -       infinite loop    when attempting    to match an unknown
  194. -       command-line argument).
  195. X  
  196. -      pe_NOMATCH
  197. -       Unable to match the named argument. This occurs when
  198. -       the argument keyword name passed to parsecntl    (using
  199. X  
  200. X  
  201. X  Page 16
  202. X  
  203. X  
  204. --- 1047,1055 ----
  205. ***************
  206. *** 1061,1066 ****
  207. --- 1061,1076 ----
  208. X  
  209. X  
  210. X  
  211. +       An attempt (using parsecntl) was made    to change the
  212. +       default arg-search list of a command to point    to an
  213. +       argdesc-array    which already has the given command on
  214. +       its default arg-search list (which would cause an
  215. +       infinite loop    when attempting    to match an unknown
  216. +       command-line argument).
  217. +      pe_NOMATCH
  218. +       Unable to match the named argument. This occurs when
  219. +       the argument keyword name passed to parsecntl    (using
  220. X        the pc_ARGFLAGS functions code) was found in the given
  221. X        argdesc-array    or in its default-list.
  222. X  
  223. ***************
  224. *** 1074,1081 ****
  225. X        Bad command for parsecntl. This occurs if an unknown
  226. X        function-code    was passed to parsecntl.
  227. X  
  228. X  SEE ALSO
  229. !      argtype(3), parseargs(1), syserr(3)
  230. X       The ``C Advisor'' column in UNIX Review Vol. 7 No.    11.
  231. X  
  232. X  CAVEATS
  233. --- 1084,1144 ----
  234. X        Bad command for parsecntl. This occurs if an unknown
  235. X        function-code    was passed to parsecntl.
  236. X  
  237. + SIDE EFFECTS
  238. +      Each of the functions in the parseargs library will set the
  239. +      external character    string ProgName    to be the name of the
  240. +      last command that was operated upon by any    of the library
  241. +      routines.
  242. +      When an argument-descriptor array is first    encountered by
  243. +      any of the    parseargs library routines, it is initially com-
  244. +      piled into    an intermediate    form that is more convenient to
  245. +      manipulate. As a direct result, it    is not advisable to
  246. +      attempt to    index directly into the    array to manipulate one
  247. +      of    the argument descriptors (because the argdesc that you
  248. +      thought was there may actually be somewhere else).    After the
  249. +      array has been given its initial value(s),    only parsecntl(3)
  250. +      should be used to manipulate or query the attributes of an
  251. +      argument descriptor.
  252. + DOCUMENTING YOUR COMMANDS
  253. +      The commands that you write with parseargs(3) may be docu-
  254. +      mented using parseargs(1).    Just copy the argument descriptor
  255. +      array into    a separate file, and invoke parseargs(1) with the
  256. +      -M    option and pass    it the command-name (dont forget to
  257. +      redirect input to come from your newly created file). It is
  258. +      important to note that the    only portion of    that argdesc
  259. +      array to insert into your file is the portion starting with
  260. +      the very first command-line argument, all the way down to
  261. +      (and including) the ENDOFARGS or END_ARGUMENTS entry.
  262. + Page 17
  263. + PARSEARGS(3)                         PARSEARGS(3)
  264. + FILES
  265. +      /usr/local/lib/libparse.a
  266. +       Link library for parseargs.
  267. +      /usr/local/include/parseargs.h
  268. +       Include file for parseargs.
  269. +      /usr/local/include/useful.h
  270. +       Include file for portability.
  271. X  SEE ALSO
  272. !      argtype(3), parseargs(1), parsecntl(3)
  273. X       The ``C Advisor'' column in UNIX Review Vol. 7 No.    11.
  274. X  
  275. X  CAVEATS
  276. ***************
  277. *** 1113,1134 ****
  278. X       Hence multiple ``leading dash'' arguments may specified as
  279. X       follows:
  280. X  
  281. X  
  282. X  
  283. X  
  284. - Page 17
  285. X  
  286. X  
  287. X  
  288. X  
  289. X  
  290. X  
  291. - PARSEARGS(3)                         PARSEARGS(3)
  292. X  
  293. X  
  294. X  
  295. -       -f-dash_arg1 -f-dash_arg2  ...
  296. X  
  297. X  BUGS
  298. X       When a non-multivalued argument appears more than once on
  299. X       the command-line then only    the last value supplied    is used.
  300. --- 1176,1198 ----
  301. X       Hence multiple ``leading dash'' arguments may specified as
  302. X       follows:
  303. X  
  304. +       -f-dash_arg1 -f-dash_arg2  ...
  305. X  
  306. X  
  307. X  
  308. X  
  309. X  
  310. + Page 18
  311. X  
  312. X  
  313. X  
  314. X  
  315. X  
  316. X  
  317. + PARSEARGS(3)                         PARSEARGS(3)
  318. X  
  319. X  
  320. X  BUGS
  321. X       When a non-multivalued argument appears more than once on
  322. X       the command-line then only    the last value supplied    is used.
  323. ***************
  324. *** 1182,1188 ****
  325. X  
  326. X  
  327. X  
  328. ! Page 18
  329. X  
  330. X  
  331. X  
  332. --- 1246,1254 ----
  333. X  
  334. X  
  335. X  
  336. ! Page 19
  337. X  
  338. X  
  339. X  
  340. *** /hx1d3/lp/brad/parseargs_patch03/parseargs/parsecntl3.txt    Wed Apr 10 09:47:48 1991
  341. --- parsecntl3.txt    Mon Apr 15 08:31:38 1991
  342. ***************
  343. *** 12,18 ****
  344. X  SYNOPSIS
  345. X       #include <parseargs.h>
  346. X  
  347. !      int  parsecntl( ARGDESC argd[],  parsecntl_t func,     parsemode_t mode,  ...    )
  348. X  
  349. X  
  350. X  DESCRIPTION
  351. --- 12,18 ----
  352. X  SYNOPSIS
  353. X       #include <parseargs.h>
  354. X  
  355. !      int  parsecntl( ARGDESC argd[],  parsecntl_t func,     parsemode_t mode,  ...    );
  356. X  
  357. X  
  358. X  DESCRIPTION
  359. ***************
  360. *** 210,217 ****
  361. X  PARSE MODES
  362. X       Parsecntl may be used to read current command attributes,
  363. X       write (assign) new    command    attributes, or both. The mode
  364. !      argument to parsecntl determines the which    of these three
  365. !      alternatives are desired. If the programmer merely    wishes to
  366. X       assign new    attributes, then invoking parsecntl in pc_WRITE
  367. X       mode and passing the new attributes will do the job. If the
  368. X       programmer    wishes simply to query attributes, then    invoking
  369. --- 210,217 ----
  370. X  PARSE MODES
  371. X       Parsecntl may be used to read current command attributes,
  372. X       write (assign) new    command    attributes, or both. The mode
  373. !      argument to parsecntl determines which of these three alter-
  374. !      natives are desired. If the programmer merely wishes to
  375. X       assign new    attributes, then invoking parsecntl in pc_WRITE
  376. X       mode and passing the new attributes will do the job. If the
  377. X       programmer    wishes simply to query attributes, then    invoking
  378. ***************
  379. *** 227,233 ****
  380. X       ing it returns 0) the desired attributes will have    been
  381. X       assigned and the object that contained the    new attribute
  382. X       settings will now contain the attribute settings that were
  383. !      in    effect before parsecntl    was invoked.
  384. X  
  385. X  PARSE FLAGS
  386. X       The following bitmasks may    be combined in order to    modify
  387. --- 227,233 ----
  388. X       ing it returns 0) the desired attributes will have    been
  389. X       assigned and the object that contained the    new attribute
  390. X       settings will now contain the attribute settings that were
  391. !      in    effect immediately before parsecntl was    invoked.
  392. X  
  393. X  PARSE FLAGS
  394. X       The following bitmasks may    be combined in order to    modify
  395. ***************
  396. *** 246,254 ****
  397. X       pa_IGNORE
  398. X        Ignore any unrecognized or improperly    specified
  399. X        command-line arguments and continue execution    of the
  400. !       program. Normally, if    an argument is unmatched (or is
  401. !       improperly specified), a usage message is printed pro-
  402. !       gram execution is terminated.
  403. X  
  404. X       pa_OPTSONLY
  405. X        Under    UNIX, setting this flag    will disable the parsing
  406. --- 246,254 ----
  407. X       pa_IGNORE
  408. X        Ignore any unrecognized or improperly    specified
  409. X        command-line arguments and continue execution    of the
  410. !       program. Normally, if    a required argument is unmatched
  411. !       (or an argument is improperly    specified), a usage mes-
  412. !       sage is printed program execution is terminated.
  413. X  
  414. X       pa_OPTSONLY
  415. X        Under    UNIX, setting this flag    will disable the parsing
  416. ***************
  417. *** 292,299 ****
  418. X       pa_ANYCASE
  419. X        Setting this flag will cause character-case to be
  420. X        ignored when attempting to match single-character argu-
  421. !       ment names (i.e. causes "-i" and "-I"    will be    con-
  422. !       sidered equivalent).
  423. X  
  424. X       pa_ARGV0
  425. X        Normally, the    parseargs library will assume that the
  426. --- 292,299 ----
  427. X       pa_ANYCASE
  428. X        Setting this flag will cause character-case to be
  429. X        ignored when attempting to match single-character argu-
  430. !       ment names (i.e. causes "-i" and "-I"    to be considered
  431. !       equivalent).
  432. X  
  433. X       pa_ARGV0
  434. X        Normally, the    parseargs library will assume that the
  435. ***************
  436. *** 314,326 ****
  437. X        Keeping this flag on until the final set of arguments
  438. X        is parsed will cause parseargs to not    check for missing
  439. X        arguments until the last set of arguments has    been
  440. !       parsed (by the final call to *parseargs).
  441. X  
  442. X       pa_CONTINUE
  443. X        Setting this flag will cause subsequent calls    to the
  444. X        parseargs library to NOT reset the current command-
  445. X        state. Hence,    all arguments will not be initially set
  446. -       to "NOT GIVEN" and other (normal) initializations are
  447. X  
  448. X  
  449. X  
  450. --- 314,326 ----
  451. X        Keeping this flag on until the final set of arguments
  452. X        is parsed will cause parseargs to not    check for missing
  453. X        arguments until the last set of arguments has    been
  454. !       parsed (by the final call to one of the functions in
  455. !       the parseargs    library).
  456. X  
  457. X       pa_CONTINUE
  458. X        Setting this flag will cause subsequent calls    to the
  459. X        parseargs library to NOT reset the current command-
  460. X        state. Hence,    all arguments will not be initially set
  461. X  
  462. X  
  463. X  
  464. ***************
  465. *** 335,340 ****
  466. --- 335,341 ----
  467. X  
  468. X  
  469. X  
  470. +       to "NOT GIVEN" and other (normal) initializations are
  471. X        not be performed.  This is useful in conjunction with
  472. X        the pa_NOCHECK flag when more    than one call to par-
  473. X        seargs is required to    parse all the command arguments.
  474. ***************
  475. *** 386,392 ****
  476. X  
  477. X       ARGNOVAL
  478. X        The associated command argument takes    no value (as in
  479. -       "-x value"); Its mere    presence (or lack thereof) on the
  480. X  
  481. X  
  482. X  
  483. --- 387,392 ----
  484. ***************
  485. *** 401,406 ****
  486. --- 401,407 ----
  487. X  
  488. X  
  489. X  
  490. +       "-x value"); Its mere    presence (or lack thereof) on the
  491. X        command-line is sufficient to    determine the necessary
  492. X        action(s) to take (as    in "-x").  Boolean argument types
  493. X        and Pseudo-argument types automatically default to ARG-
  494. ***************
  495. *** 452,458 ****
  496. X        The argument WAS given on the    command-line.
  497. X  
  498. X       ARGVALGIVEN
  499. -       The value for    this argument was given    on the command-
  500. X  
  501. X  
  502. X  
  503. --- 453,458 ----
  504. ***************
  505. *** 467,472 ****
  506. --- 467,473 ----
  507. X  
  508. X  
  509. X  
  510. +       The value for    this argument was given    on the command-
  511. X        line.
  512. X  
  513. X       ARGVALSEP
  514. ***************
  515. *** 521,527 ****
  516. X  
  517. X  
  518. X  
  519. X  Page 8
  520. X  
  521. X  
  522. --- 522,527 ----
  523. ***************
  524. *** 543,571 ****
  525. X        Bad command for parsecntl. This occurs if an unknown
  526. X        function-code    was passed to parsecntl.
  527. X  
  528. X  SEE ALSO
  529. !      argtype(3),
  530. !      parseargs(3),
  531. !      parseargs(1)
  532. X  
  533. X  AUTHOR
  534. X       Brad Appleton  (brad@ssd.csd.harris.com)
  535. X       Harris Computer Systems, Fort Lauderdale, FL USA
  536. X  
  537. X  
  538. X  
  539. --- 543,571 ----
  540. X        Bad command for parsecntl. This occurs if an unknown
  541. X        function-code    was passed to parsecntl.
  542. X  
  543. + SIDE EFFECTS
  544. +      Each of the functions in the parseargs library will set the
  545. +      external character    string ProgName    to be the name of the
  546. +      last command that was operated upon by any    of the library
  547. +      routines.
  548. +      When an argument-descriptor array is first    encountered by
  549. +      any of the    parseargs library routines, it is initially com-
  550. +      piled into    an intermediate    form that is more convenient to
  551. +      manipulate. As a direct result, it    is not advisable to
  552. +      attempt to    index directly into the    array to manipulate one
  553. +      of    the argument descriptors (because the argdesc that you
  554. +      thought was there may actually be somewhere else).    After the
  555. +      array has been given its initial value(s),    only parsecntl(3)
  556. +      should be used to manipulate or query the attributes of an
  557. +      argument descriptor.
  558. X  SEE ALSO
  559. !      argtype(3), parseargs(3), parseargs(1)
  560. X  
  561. X  AUTHOR
  562. X       Brad Appleton  (brad@ssd.csd.harris.com)
  563. X       Harris Computer Systems, Fort Lauderdale, FL USA
  564. X  
  565. X  
  566. X  
  567. SHAR_EOF
  568. echo 'File DOCPATCH is complete' &&
  569. chmod 0664 DOCPATCH ||
  570. echo 'restore of DOCPATCH failed'
  571. Wc_c="`wc -c < 'DOCPATCH'`"
  572. test 66103 -eq "$Wc_c" ||
  573.     echo 'DOCPATCH: original size 66103, current size' "$Wc_c"
  574. # ============= Makefile ==============
  575. echo 'x - extracting Makefile (Text)'
  576. sed 's/^X//' << 'SHAR_EOF' > 'Makefile' &&
  577. # $Header: Makefile,v 2.1 89/12/30 20:59:01 eric Exp $
  578. X
  579. ###
  580. # operating-system dependent stuff
  581. ###
  582. .UNIVERSE =    att
  583. #.UNIVERSE =    ucb
  584. OS_TYPE =    unix
  585. # OS_DEFS =    -D${OS_TYPE} -D${.UNIVERSE}_universe
  586. X
  587. ###
  588. # targets
  589. ###
  590. NAME =    parseargs
  591. PROGRAM =    ${NAME}
  592. LIBRARY =    ${NAME}
  593. STYLE =    unix
  594. X
  595. ###
  596. # target directories
  597. ###
  598. LOCAL =  /usr/local
  599. LIBDIR = ${LOCAL}/lib
  600. INCDIR = ${LOCAL}/include
  601. X
  602. ###
  603. # compilation options
  604. ###
  605. INCLUDES =    -I.
  606. # MODEL =    -Ms
  607. # MODELNAME =    S
  608. OPT =    -O
  609. # OPT =    -g
  610. TEST_DEFS =    
  611. USR_DEFS =    -DUSE_PAGER
  612. DEFINES =    ${OS_DEFS} ${USR_DEFS} ${TEST_DEFS} -D${STYLE}_style
  613. OPTIONS =
  614. CFLAGS =    ${OPT} ${MODEL} ${INCLUDES} ${DEFINES} ${OPTIONS}
  615. LINTFLAGS =    ${INCLUDES} ${DEFINES} ${OPTIONS}
  616. X
  617. ###
  618. # libraries
  619. ###
  620. LIBARGS =    ${MODELNAME}lib${STYLE}_args.a
  621. LIBFILE =    ${MODELNAME}libparse.a
  622. LOCLIBS =    ${LIBARGS}
  623. # SYSLIBS =    -lm -lcurses -ltermcap
  624. LIBS =    ${LOCLIBS} ${SYSLIBS}
  625. X
  626. ###
  627. # commands
  628. ###
  629. AR =    ar rvu
  630. DEL =    rm -f
  631. COPY =    cp
  632. CHDIR =    cd
  633. LINT =    lint
  634. MKTAGS =    ctags
  635. PRINT =    pr
  636. RANLIB =    ranlib
  637. SHAR =    shar
  638. SQZ =    compress -v
  639. STRIP =    strip
  640. X
  641. ###
  642. # files used
  643. ###
  644. DOCS=    doc/Makefile \
  645. X        doc/argtype.man3 \
  646. X        doc/parseargs.man1 \
  647. X        doc/parseargs.man3 \
  648. X        doc/parsecntl.man3 \
  649. X        doc/arg_macros.inc \
  650. X        doc/argdesc.inc \
  651. X        doc/argflags.inc \
  652. X        doc/argvalopt.inc \
  653. X        doc/bugs.inc \
  654. X        doc/caveats.inc \
  655. X        doc/cmd_macros.inc \
  656. X        doc/defargs.inc \
  657. X        doc/effects.inc \
  658. X        doc/env_args.inc \
  659. X        doc/env_parse.inc \
  660. X        doc/env_usage.inc \
  661. X        doc/fparseargs3.inc \
  662. X        doc/lib_bugs.inc \
  663. X        doc/lparseargs3.inc \
  664. X        doc/multivals.inc \
  665. X        doc/parseargs1.inc \
  666. X        doc/parseargs3.inc \
  667. X        doc/parsecntl3.inc \
  668. X        doc/parsecntls.inc \
  669. X        doc/parseflags.inc \
  670. X        doc/parsemodes.inc \
  671. X        doc/returns.inc \
  672. X        doc/sh_arrays.inc \
  673. X        doc/shells.inc \
  674. X        doc/sparseargs3.inc \
  675. X        doc/usage3.inc \
  676. X        doc/vparseargs3.inc
  677. SCRIPTS =    test.sh  test.csh  test.ksh  test.rc  test.awk  test.pl
  678. TEMPLATES =    ${NAME}.pl  ${NAME}.awk
  679. XXXFILES =    Intro  README  MANIFEST  Makefile  Makefile.cpp
  680. X
  681. HDRS =    ${NAME}.h \
  682. X        patchlevel.h \
  683. X        pgopen.h \
  684. X        strfuncs.h \
  685. X        useful.h
  686. X
  687. SRCS =    ${NAME}.c \
  688. X        argtype.c \
  689. X        arglist.c \
  690. X        amiga_args.c \
  691. X        ibm_args.c \
  692. X        pgopen.c \
  693. X        stest.c \
  694. X        strfuncs.c \
  695. X        syserr.c \
  696. X        unix_args.c \
  697. X        unix_man.c \
  698. X        vms_args.c \
  699. X        vprintf.c \
  700. X        winsize.c \
  701. X        xparse.c
  702. X
  703. OBJS =  ${STYLE}_args.o \
  704. X         arglist.o \
  705. X         argtype.o \
  706. X         pgopen.o \
  707. X         strfuncs.o \
  708. X         syserr.o \
  709. X         vprintf.o \
  710. X         winsize.o \
  711. X         xparse.o
  712. X
  713. PROG_OBJS =  ${NAME}.o   unix_man.o
  714. TEST_OBJS =  stest.o
  715. X
  716. FILES =    ${XXFILES} ${DOCS} ${HDRS} ${SRCS} ${TEMPLATES} ${SCRIPTS}
  717. X
  718. ###
  719. # target dependencies
  720. ###
  721. all: ${LIBARGS} test ${PROGRAM}
  722. X
  723. test: ${STYLE}_test
  724. X
  725. ${STYLE}_test :  stest.o ${LOCLIBS}
  726. X    ${CC} ${CFLAGS} -o ${STYLE}_test  stest.o ${LOCLIBS} ${SYSLIBS}
  727. X
  728. ${LIBARGS}: ${OBJS}
  729. X    ${AR} $@ ${OBJS}
  730. X    ${RANLIB} $@
  731. X
  732. ${PROGRAM}: ${PROG_OBJS} ${LOCLIBS}
  733. X    ${CC} ${CFLAGS} -o $@ ${PROG_OBJS} ${LOCLIBS} ${SYSLIBS}
  734. X
  735. ###
  736. # object dependencies
  737. ###
  738. ${NAME}.o:    ${NAME}.c ${NAME}.h patchlevel.h strfuncs.h useful.h
  739. amiga_args.o:    amiga_args.c ${NAME}.h pgopen.h strfuncs.h useful.h
  740. arglist.o:    arglist.c ${NAME}.h strfuncs.h useful.h
  741. argtype.o:    argtype.c ${NAME}.h strfuncs.h useful.h
  742. ibm_args.o:    ibm_args.c ${NAME}.h pgopen.h strfuncs.h useful.h
  743. pgopen.o:    pgopen.c useful.h
  744. stest.o:    stest.c ${NAME}.h useful.h
  745. strfuncs.o:    strfuncs.c useful.h
  746. syserr.o:    syserr.c useful.h
  747. unix_args.o:    unix_args.c ${NAME}.h pgopen.h strfuncs.h useful.h
  748. unix_man.o:    unix_man.c ${NAME}.h strfuncs.h useful.h
  749. vms_args.o:    vms_args.c ${NAME}.h pgopen.h strfuncs.h useful.h
  750. vprintf.o:    vprintf.c useful.h
  751. winsize.o:    winsize.c useful.h
  752. xparse.o:    xparse.c ${NAME}.h strfuncs.h useful.h
  753. X
  754. ###
  755. # installation dependencies
  756. ###
  757. install:  ${INCDIR}/${NAME}.h \
  758. X         ${LIBDIR}/${LIBFILE} \
  759. X         ${LOCAL}/${PROGRAM}
  760. X
  761. X ${INCDIR}/${NAME}.h: ${NAME}.h useful.h
  762. X    ( ${CHDIR} ${INCDIR}; ${DEL} ${NAME}.h useful.h )
  763. X    ${COPY} ${NAME}.h useful.h ${INCDIR}
  764. X
  765. X ${LIBDIR}/${LIBFILE}: ${LIBARGS}
  766. X    ${DEL}   ${LIBDIR}/${LIBFILE}
  767. X    ${COPY} ${LIBARGS}   ${LIBDIR}/${LIBFILE}
  768. X    ${RANLIB}   ${LIBDIR}/${LIBFILE}
  769. X
  770. X ${LOCAL}/${PROGRAM}: ${PROGRAM} ${TEMPLATES}
  771. X    ( ${CHDIR} ${LOCAL} ; ${DEL} ${PROGRAM} ${TEMPLATES} )
  772. X    ${COPY} ${PROGRAM} ${TEMPLATES} ${LOCAL}
  773. X    ${STRIP} ${LOCAL}/${PROGRAM}
  774. X
  775. ###
  776. # maintenance dependencies
  777. ###
  778. lint: ${SRCS}
  779. X    ${LINT} ${LINTFLAGS} ${SRCS}
  780. X
  781. shar: ${NAME}.shar
  782. X
  783. ${NAME}.shar: ${FILES}
  784. X    ${DEL} ${NAME}.shar
  785. X    ${SHAR} ${FILES}  >${NAME}.shar
  786. X
  787. clean:
  788. X    ${DEL} ${OBJS} ${PROG_OBJS} ${TEST_OBJS}
  789. X    ${DEL} tags core .exrc
  790. X
  791. clobber: clean
  792. X    ${DEL} ${LIBARGS}  ${PROGRAM}  ${STYLE}_test
  793. X
  794. tags: ${SRCS} ${HDRS}
  795. X    ${MKTAGS} ${SRCS} ${HDRS}
  796. X
  797. collapse: clobber shar
  798. X    ${SQZ} ${NAME}.shar
  799. X    ${DEL} ${FILES}
  800. X
  801. print: ${SRCS} ${HDRS}
  802. X    @${PRINT} ${SRCS} ${HDRS}
  803. X
  804. SHAR_EOF
  805. chmod 0664 Makefile ||
  806. echo 'restore of Makefile failed'
  807. Wc_c="`wc -c < 'Makefile'`"
  808. test 4610 -eq "$Wc_c" ||
  809.     echo 'Makefile: original size 4610, current size' "$Wc_c"
  810. # ============= PATCH ==============
  811. echo 'x - extracting PATCH (Text)'
  812. sed 's/^X//' << 'SHAR_EOF' > 'PATCH' &&
  813. *** /hx1d3/lp/brad/parseargs_patch03/parseargs/MANIFEST    Wed Apr 10 09:46:29 1991
  814. --- MANIFEST    Thu Apr 11 11:04:22 1991
  815. ***************
  816. *** 8,14 ****
  817. X   amiga_args.c               4    parse AmigaDOS command-lines
  818. X   arglist.c                  2    implement the listXxxx functions for arglists
  819. X   argtype.c                  5    implement the argXxxx argument type functions
  820. !  doc/                       1    directory containing documentation
  821. X   doc/Makefile               2    makefile for the documentation
  822. X   doc/arg_macros.inc         2    describe arg-xxx and ARG_XXX macros
  823. X   doc/argdesc.inc            2    describe an ARGDESC structure
  824. --- 8,14 ----
  825. X   amiga_args.c               4    parse AmigaDOS command-lines
  826. X   arglist.c                  2    implement the listXxxx functions for arglists
  827. X   argtype.c                  5    implement the argXxxx argument type functions
  828. !  doc                        1    directory containing documentation
  829. X   doc/Makefile               2    makefile for the documentation
  830. X   doc/arg_macros.inc         2    describe arg-xxx and ARG_XXX macros
  831. X   doc/argdesc.inc            2    describe an ARGDESC structure
  832. ***************
  833. *** 19,25 ****
  834. X   doc/caveats.inc            1    CAVEATS section for parseargs(1) and (3)
  835. X   doc/cmd_macros.inc         1    describe CMD_XXX macros
  836. X   doc/defargs.inc            1    describe the default argdesc-array
  837. !  doc/env_args.inc           1    describe use of $CMD_ARGS
  838. X   doc/env_parse.inc          2    describe use of $PARSECNTL
  839. X   doc/env_usage.inc          2    describe use of $USAGECNTL
  840. X   doc/fparseargs3.inc        1    describe fparseargs(3)
  841. --- 19,26 ----
  842. X   doc/caveats.inc            1    CAVEATS section for parseargs(1) and (3)
  843. X   doc/cmd_macros.inc         1    describe CMD_XXX macros
  844. X   doc/defargs.inc            1    describe the default argdesc-array
  845. !  doc/effects.inc            1    describe the side-effects of parseargs(3)
  846. !  doc/env_args.inc           2    describe use of $CMD_ARGS
  847. X   doc/env_parse.inc          2    describe use of $PARSECNTL
  848. X   doc/env_usage.inc          2    describe use of $USAGECNTL
  849. X   doc/fparseargs3.inc        1    describe fparseargs(3)
  850. ***************
  851. *** 46,51 ****
  852. --- 47,53 ----
  853. X   parseargs.c                7    C source for parseargs(1)
  854. X   parseargs.h                6    include file for parseargs library
  855. X   parseargs.pl               2    parseargs for perl
  856. +  patchlevel.h               1    list of patches (most recent first)
  857. X   pgopen.c                   4    pipe output to a pager
  858. X   pgopen.h                   1    include file for pgopen.c
  859. X   stest.c                    3    test progarm for parseargs(3)
  860. *** /hx1d3/lp/brad/parseargs_patch03/parseargs/Makefile.cpp    Wed Apr 10 09:46:32 1991
  861. --- Makefile.cpp    Thu Apr 11 11:04:27 1991
  862. ***************
  863. *** 24,29 ****
  864. --- 24,30 ----
  865. X  # define RANLIB_CMD ranlib
  866. X  # define SHAR_CMD shar
  867. X  # define SQZ_CMD compress -v
  868. + # define STRIP_CMD strip
  869. X  #endif
  870. X  
  871. X  #ifdef vms
  872. ***************
  873. *** 47,52 ****
  874. --- 48,54 ----
  875. X  # define RANLIB_CMD ranlib
  876. X  # define SHAR_CMD shar
  877. X  # define SQZ_CMD compress/file
  878. + # define STRIP_CMD strip
  879. X  #endif
  880. X  
  881. X  #if ( defined(AZTEC) || defined(MANX) )
  882. ***************
  883. *** 70,75 ****
  884. --- 72,78 ----
  885. X  # define RANLIB_CMD ranlib
  886. X  # define SHAR_CMD shar
  887. X  # define SQZ_CMD compress -v
  888. + # define STRIP_CMD strip
  889. X  #endif
  890. X  
  891. X  #ifdef MS_DOS
  892. ***************
  893. *** 93,98 ****
  894. --- 96,102 ----
  895. X  # define RANLIB_CMD ranlib
  896. X  # define SHAR_CMD shar
  897. X  # define SQZ_CMD arc -c
  898. + # define STRIP_CMD strip
  899. X  #endif
  900. X  
  901. X  #ifdef OS2
  902. ***************
  903. *** 116,121 ****
  904. --- 120,126 ----
  905. X  # define RANLIB_CMD ranlib
  906. X  # define SHAR_CMD shar
  907. X  # define SQZ_CMD arc -c
  908. + # define STRIP_CMD strip
  909. X  #endif
  910. X  
  911. X  REM $Header: Makefile,v 2.1 89/12/30 20:59:01 eric Exp $
  912. ***************
  913. *** 179,184 ****
  914. --- 184,190 ----
  915. X  RANLIB =    RANLIB_CMD
  916. X  SHAR =    SHAR_CMD
  917. X  SQZ =    SQZ_CMD
  918. + STRIP =    STRIP_CMD
  919. X  
  920. X  REMLINE
  921. X  REM files used
  922. ***************
  923. *** 196,201 ****
  924. --- 202,208 ----
  925. X          doc/caveats.inc \
  926. X          doc/cmd_macros.inc \
  927. X          doc/defargs.inc \
  928. +         doc/effects.inc \
  929. X          doc/env_args.inc \
  930. X          doc/env_parse.inc \
  931. X          doc/env_usage.inc \
  932. ***************
  933. *** 275,281 ****
  934. X  REMLINE
  935. X  REM object dependencies
  936. X  REMLINE
  937. ! ${NAME}.o:    ${NAME}.c ${NAME}.h strfuncs.h useful.h
  938. X  amiga_args.o:    amiga_args.c ${NAME}.h pgopen.h strfuncs.h useful.h
  939. X  arglist.o:    arglist.c ${NAME}.h strfuncs.h useful.h
  940. X  argtype.o:    argtype.c ${NAME}.h strfuncs.h useful.h
  941. --- 282,288 ----
  942. X  REMLINE
  943. X  REM object dependencies
  944. X  REMLINE
  945. ! ${NAME}.o:    ${NAME}.c ${NAME}.h patchlevel.h strfuncs.h useful.h
  946. X  amiga_args.o:    amiga_args.c ${NAME}.h pgopen.h strfuncs.h useful.h
  947. X  arglist.o:    arglist.c ${NAME}.h strfuncs.h useful.h
  948. X  argtype.o:    argtype.c ${NAME}.h strfuncs.h useful.h
  949. ***************
  950. *** 310,315 ****
  951. --- 317,323 ----
  952. X  _Pathname(${LOCAL},${PROGRAM}): ${PROGRAM} ${TEMPLATES}
  953. X      ( ${CHDIR} ${LOCAL} ; ${DEL} ${PROGRAM} ${TEMPLATES} )
  954. X      ${COPY} ${PROGRAM} ${TEMPLATES} ${LOCAL}
  955. +     ${STRIP} _Pathname(${LOCAL},${PROGRAM})
  956. X  
  957. X  REMLINE
  958. X  REM maintenance dependencies
  959. *** /hx1d3/lp/brad/parseargs_patch03/parseargs/amiga_args.c    Wed Apr 10 09:46:39 1991
  960. --- amiga_args.c    Thu Apr 11 11:04:36 1991
  961. ***************
  962. *** 156,163 ****
  963. X           }
  964. X  
  965. X           flags = arg_flags(ad);    /* save flags */
  966. !          if ( ARG_isGIVEN(ad) )    /* reset flags for this appearance */
  967. !             BCLEAR( arg_flags(ad), ARGVALGIVEN | ARGVALSEP );
  968. X  
  969. X           if ( p ) { /* matched NAME=VALUE */
  970. X              if ( ARG_isMULTIVAL(ad) )
  971. --- 156,165 ----
  972. X           }
  973. X  
  974. X           flags = arg_flags(ad);    /* save flags */
  975. !          if ( ARG_isGIVEN(ad) ) {
  976. !             BCLEAR( arg_flags(ad), ARGVALSEP | ARGKEYWORD );
  977. !             if ( !ARG_isMULTIVAL(ad) )  BCLEAR( arg_flags(ad), ARGVALGIVEN );
  978. !          }
  979. X  
  980. X           if ( p ) { /* matched NAME=VALUE */
  981. X              if ( ARG_isMULTIVAL(ad) )
  982. ***************
  983. *** 199,206 ****
  984. X        }
  985. X        else if (cmd_prev(cmd)) {
  986. X           flags = arg_flags(cmd_prev(cmd));    /* save flags */
  987. !          if ( ARG_isGIVEN(cmd_prev(cmd)) )    /* reset flags */
  988. !             BCLEAR( arg_flags(cmd_prev(cmd)), ARGVALGIVEN | ARGVALSEP );
  989. X  
  990. X              /* previous value may have required a keyword */
  991. X           BSET( arg_flags(cmd_prev(cmd)), ARGVALSEP );
  992. --- 201,210 ----
  993. X        }
  994. X        else if (cmd_prev(cmd)) {
  995. X           flags = arg_flags(cmd_prev(cmd));    /* save flags */
  996. !          if ( ARG_isGIVEN(cmd_prev(cmd)) ) {   /* reset flags */
  997. !             BCLEAR( arg_flags(cmd_prev(cmd)), ARGVALSEP );
  998. !             if ( !ARG_isMULTIVAL(ad) )  BCLEAR( arg_flags(ad), ARGVALGIVEN );
  999. !          }
  1000. X  
  1001. X              /* previous value may have required a keyword */
  1002. X           BSET( arg_flags(cmd_prev(cmd)), ARGVALSEP );
  1003. ***************
  1004. *** 223,233 ****
  1005. X           continue;
  1006. X        }
  1007. X        else {  /* it's a positional argument or a list item */
  1008. !          if (cmd_list(cmd)) { /* its a list item */
  1009. X              flags = arg_flags(cmd_list(cmd));    /* save flags */
  1010. !             if ( ARG_isGIVEN(cmd_list(cmd)) )    /* reset flags */
  1011. !                BCLEAR( arg_flags(cmd_list(cmd)), ARGVALGIVEN | ARGVALSEP );
  1012. X              BSET( arg_flags(cmd_list(cmd)), ARGVALSEP );
  1013. X  
  1014. X              if ( !HANDLE(cmd_list(cmd), *av, cmd_flags(cmd)) ) {
  1015. --- 227,237 ----
  1016. X           continue;
  1017. X        }
  1018. X        else {  /* it's a positional argument or a list item */
  1019. !          if ( cmd_list(cmd) ) { /* its a list item */
  1020. X              flags = arg_flags(cmd_list(cmd));    /* save flags */
  1021. !             if ( ARG_isGIVEN(cmd_list(cmd)) ) {   /* reset flags */
  1022. !                BCLEAR( arg_flags(cmd_list(cmd)), ARGVALSEP );
  1023. !             }
  1024. X              BSET( arg_flags(cmd_list(cmd)), ARGVALSEP );
  1025. X  
  1026. X              if ( !HANDLE(cmd_list(cmd), *av, cmd_flags(cmd)) ) {
  1027. ***************
  1028. *** 262,270 ****
  1029. X              }
  1030. X              else {
  1031. X                 flags = arg_flags(ad);    /* save flags */
  1032. !                if ( ARG_isGIVEN(ad) )    /* reset flags for this appearance */
  1033. !                   BCLEAR( arg_flags(ad), ARGVALGIVEN | ARGVALSEP );
  1034. X                 BSET( arg_flags(ad), ARGVALSEP );
  1035. X  
  1036. X                    /* try to convert */
  1037. --- 266,275 ----
  1038. X              }
  1039. X              else {
  1040. X                 flags = arg_flags(ad);    /* save flags */
  1041. !                if ( ARG_isGIVEN(ad) ) {   /* reset flags for this appearance */
  1042. !                   BCLEAR( arg_flags(ad), ARGVALSEP );
  1043. !                   if (! ARG_isMULTIVAL(ad))  BCLEAR(arg_flags(ad), ARGVALGIVEN);
  1044. !                }
  1045. X                 BSET( arg_flags(ad), ARGVALSEP );
  1046. X  
  1047. X                    /* try to convert */
  1048. *** /hx1d3/lp/brad/parseargs_patch03/parseargs/argtype.c    Wed Apr 10 09:52:05 1991
  1049. --- argtype.c    Thu Apr 11 11:04:44 1991
  1050. ***************
  1051. *** 40,47 ****
  1052. X  #define REALLOC(ptr,size)  (( ! ptr ) ? malloc(size) : realloc(ptr, size) )
  1053. X  EXTERN  VOID    syserr  ARGS((const char *, ...));
  1054. X  EXTERN  VOID    usrerr  ARGS((const char *, ...));
  1055. ! EXTERN  long    strtol  ARGS((char *, char **, int));
  1056. ! EXTERN  double  strtod  ARGS((const char *, char **));
  1057. X  
  1058. X  
  1059. X  /***************************************************************************
  1060. --- 40,47 ----
  1061. X  #define REALLOC(ptr,size)  (( ! ptr ) ? malloc(size) : realloc(ptr, size) )
  1062. X  EXTERN  VOID    syserr  ARGS((const char *, ...));
  1063. X  EXTERN  VOID    usrerr  ARGS((const char *, ...));
  1064. ! /* EXTERN  long    strtol  ARGS((char *, char **, int)); */
  1065. ! /* EXTERN  double  strtod  ARGS((const char *, char **)); */
  1066. X  
  1067. X  
  1068. X  /***************************************************************************
  1069. ***************
  1070. *** 82,90 ****
  1071. X  **    similarly. One of these routines is called when an argument of that
  1072. X  **    particular type is matched by one of the argument parsing function in
  1073. X  **    parseargs(3). When such an argument is matched, its argument transla-
  1074. ! **    tion routines is invoked and is passed (1) the address of the argument
  1075. X  **    descriptor for the matched argument, (2) the possible argument string
  1076. ! **    for that matched argument, and (3) a boolean filed that is TRUE only
  1077. X  **    if the second parameter points to temporary storage (indicating that
  1078. X  **    some copying may need to be done instead of just pointing to the same
  1079. X  **    object).
  1080. --- 82,90 ----
  1081. X  **    similarly. One of these routines is called when an argument of that
  1082. X  **    particular type is matched by one of the argument parsing function in
  1083. X  **    parseargs(3). When such an argument is matched, its argument transla-
  1084. ! **    tion routine is invoked and is passed (1) the address of the argument
  1085. X  **    descriptor for the matched argument, (2) the possible argument string
  1086. ! **    for that matched argument, and (3) a boolean field that is TRUE only
  1087. X  **    if the second parameter points to temporary storage (indicating that
  1088. X  **    some copying may need to be done instead of just pointing to the same
  1089. X  **    object).
  1090. ***************
  1091. *** 645,664 ****
  1092. X  **    ArgOutput attempts to redirect the file-pointer addressed by ad_valp
  1093. X  **    to the file named by the given value. The file is opened for writing.
  1094. X  **
  1095. ! **    In either case, ad_valp should be of type (FILE *) (and not a pointer
  1096. ! **    to a file pointer as in (FILE **)!!!
  1097. X  **
  1098. X  **    If the given files cannot be opened, then an error message is printed
  1099. X  **    and the associated input/output streams are closed.
  1100. X  ***^^**********************************************************************/
  1101. X  
  1102. X  /*ARGSUSED*/
  1103. X  BOOL argInput  PARMS(ad, vp, copyf)
  1104. X  {
  1105. !       /* note that ad_valp is a file pointer
  1106. !       ** (so dont use &fp in the arg-desc)
  1107. !       */
  1108. X     FILE *fp = (FILE *)arg_valp(ad);
  1109. X     BOOL error = FALSE;
  1110. X  
  1111. X     /* redirect file pointer to read from file */
  1112. --- 645,676 ----
  1113. X  **    ArgOutput attempts to redirect the file-pointer addressed by ad_valp
  1114. X  **    to the file named by the given value. The file is opened for writing.
  1115. X  **
  1116. ! **    In either case, ad_valp should be of type (FILE **) (a pointer to a
  1117. ! **    file pointer) and not a mere file pointer as in (FILE *)!!!
  1118. X  **
  1119. X  **    If the given files cannot be opened, then an error message is printed
  1120. X  **    and the associated input/output streams are closed.
  1121. X  ***^^**********************************************************************/
  1122. X  
  1123. +    /*
  1124. +    ** slight problem here - on VMS, as_valp should be of type FILE **
  1125. +    ** but on Unix (emulating VMS) it needs to be of type FILE *.
  1126. +    ** we get around this using the following:
  1127. +    */
  1128. + # ifdef vms
  1129. + #  define FP *fp
  1130. + # else
  1131. + #  define FP fp
  1132. + # endif
  1133. X  /*ARGSUSED*/
  1134. X  BOOL argInput  PARMS(ad, vp, copyf)
  1135. X  {
  1136. ! #ifdef vms
  1137. !    FILE **fp = (FILE **)arg_valp(ad);
  1138. ! #else
  1139. X     FILE *fp = (FILE *)arg_valp(ad);
  1140. + #endif
  1141. X     BOOL error = FALSE;
  1142. X  
  1143. X     /* redirect file pointer to read from file */
  1144. ***************
  1145. *** 667,675 ****
  1146. X        error = TRUE;
  1147. X     }
  1148. X  
  1149. !    if ( !error  &&  !fp )
  1150. X        error = TRUE;
  1151. !    else if ( !error  &&  !freopen(vp, "r", fp) )
  1152. X        error = TRUE;
  1153. X  
  1154. X     if ( error )  {
  1155. --- 679,687 ----
  1156. X        error = TRUE;
  1157. X     }
  1158. X  
  1159. !    if ( !error  &&  !FP )
  1160. X        error = TRUE;
  1161. !    else if ( !error  &&  !freopen(vp, "r", FP) )
  1162. X        error = TRUE;
  1163. X  
  1164. X     if ( error )  {
  1165. ***************
  1166. *** 683,692 ****
  1167. X  /*ARGSUSED*/
  1168. X  BOOL argOutput  PARMS(ad, vp, copyf)
  1169. X  {
  1170. !       /* note that ad_valp is a file pointer
  1171. !       ** (so dont use &fp in the arg-desc)
  1172. !       */
  1173. X     FILE *fp = (FILE *)arg_valp(ad);
  1174. X     BOOL error = FALSE;
  1175. X  
  1176. X     /* redirect file pointer to write to file */
  1177. --- 695,705 ----
  1178. X  /*ARGSUSED*/
  1179. X  BOOL argOutput  PARMS(ad, vp, copyf)
  1180. X  {
  1181. ! #ifdef vms
  1182. !    FILE **fp = (FILE **)arg_valp(ad);
  1183. ! #else
  1184. X     FILE *fp = (FILE *)arg_valp(ad);
  1185. + #endif
  1186. X     BOOL error = FALSE;
  1187. X  
  1188. X     /* redirect file pointer to write to file */
  1189. ***************
  1190. *** 695,703 ****
  1191. X        error = TRUE;
  1192. X     }
  1193. X  
  1194. !    if ( !error  &&  !fp )
  1195. X        error = TRUE;
  1196. !    else if ( !error  &&  !freopen(vp, "a", fp) )
  1197. X        error = TRUE;
  1198. X  
  1199. X     if ( error )  {
  1200. --- 708,716 ----
  1201. X        error = TRUE;
  1202. X     }
  1203. X  
  1204. !    if ( !error  &&  !FP )
  1205. X        error = TRUE;
  1206. !    else if ( !error  &&  !freopen(vp, "a", FP) )
  1207. X        error = TRUE;
  1208. X  
  1209. X     if ( error )  {
  1210. ***************
  1211. *** 707,710 ****
  1212. --- 720,724 ----
  1213. X     return (TRUE);
  1214. X  }
  1215. X  
  1216. + # undef FP
  1217. X  #endif  /* vms_style */
  1218. *** /hx1d3/lp/brad/parseargs_patch03/parseargs/ibm_args.c    Wed Apr 10 09:47:26 1991
  1219. --- ibm_args.c    Thu Apr 11 11:06:43 1991
  1220. ***************
  1221. *** 252,259 ****
  1222. X           }
  1223. X  
  1224. X           flags = arg_flags(ad);
  1225. !          if ( ARG_isGIVEN(ad) )
  1226. !             BCLEAR( arg_flags(ad), ARGVALSEP | ARGVALGIVEN | ARGKEYWORD );
  1227. X  
  1228. X           BSET( arg_flags(ad), ARGKEYWORD );
  1229. X  
  1230. --- 252,261 ----
  1231. X           }
  1232. X  
  1233. X           flags = arg_flags(ad);
  1234. !          if ( ARG_isGIVEN(ad) ) {
  1235. !             BCLEAR( arg_flags(ad), ARGVALSEP | ARGKEYWORD );
  1236. !             if ( !ARG_isMULTIVAL(ad) )  BCLEAR( arg_flags(ad), ARGVALGIVEN );
  1237. !          }
  1238. X  
  1239. X           BSET( arg_flags(ad), ARGKEYWORD );
  1240. X  
  1241. ***************
  1242. *** 362,369 ****
  1243. X              }/* if unknown-option */
  1244. X  
  1245. X              flags = arg_flags(ad);
  1246. !             if ( ARG_isGIVEN(ad) )
  1247. !                BCLEAR( arg_flags(ad), ARGVALSEP | ARGVALGIVEN | ARGKEYWORD );
  1248. X  
  1249. X              if ( ARG_isMULTIVAL(ad) ) {
  1250. X                 cmd_list(cmd) = ad;
  1251. --- 364,373 ----
  1252. X              }/* if unknown-option */
  1253. X  
  1254. X              flags = arg_flags(ad);
  1255. !             if ( ARG_isGIVEN(ad) ) {
  1256. !                BCLEAR( arg_flags(ad), ARGVALSEP | ARGKEYWORD );
  1257. !                if ( !ARG_isMULTIVAL(ad) )  BCLEAR( arg_flags(ad), ARGVALGIVEN );
  1258. !             }
  1259. X  
  1260. X              if ( ARG_isMULTIVAL(ad) ) {
  1261. X                 cmd_list(cmd) = ad;
  1262. ***************
  1263. *** 444,454 ****
  1264. X        }/*elif option*/
  1265. X        else {
  1266. X              /* parsing a list of arguments */
  1267. !          if( cmd_list(cmd) ) {
  1268. X              ad = cmd_list(cmd);
  1269. X              flags = arg_flags(ad);
  1270. !             if ( ARG_isGIVEN(ad) )
  1271. !                BCLEAR( arg_flags(ad), ARGVALSEP | ARGVALGIVEN | ARGKEYWORD );
  1272. X  
  1273. X              BSET( arg_flags(ad), ARGVALSEP );
  1274. X  
  1275. --- 448,459 ----
  1276. X        }/*elif option*/
  1277. X        else {
  1278. X              /* parsing a list of arguments */
  1279. !          if ( cmd_list(cmd) ) {
  1280. X              ad = cmd_list(cmd);
  1281. X              flags = arg_flags(ad);
  1282. !             if ( ARG_isGIVEN(ad) ) {
  1283. !                BCLEAR( arg_flags(ad), ARGVALSEP | ARGKEYWORD );
  1284. !             }
  1285. X  
  1286. X              BSET( arg_flags(ad), ARGVALSEP );
  1287. X  
  1288. ***************
  1289. *** 481,488 ****
  1290. X           }
  1291. X  
  1292. X           flags = arg_flags(ad);
  1293. !          if ( ARG_isGIVEN(ad) )
  1294. !             BCLEAR( arg_flags(ad), ARGVALSEP | ARGVALGIVEN | ARGKEYWORD );
  1295. X  
  1296. X           if ( ARG_isMULTIVAL(ad) ) {
  1297. X              cmd_list(cmd) = ad;
  1298. --- 486,495 ----
  1299. X           }
  1300. X  
  1301. X           flags = arg_flags(ad);
  1302. !          if ( ARG_isGIVEN(ad) ) {
  1303. !             BCLEAR( arg_flags(ad), ARGVALSEP | ARGKEYWORD );
  1304. !             if ( !ARG_isMULTIVAL(ad) )  BCLEAR( arg_flags(ad), ARGVALGIVEN );
  1305. !          }
  1306. X  
  1307. X           if ( ARG_isMULTIVAL(ad) ) {
  1308. X              cmd_list(cmd) = ad;
  1309. *** /hx1d3/lp/brad/parseargs_patch03/parseargs/parseargs.awk    Wed Apr 10 09:47:27 1991
  1310. --- parseargs.awk    Thu Apr 11 11:06:52 1991
  1311. ***************
  1312. *** 59,64 ****
  1313. --- 59,66 ----
  1314. X  ##    The exit code returned by parseargs(1).
  1315. X  ##
  1316. X  ## ^BUGS:
  1317. + ##    Assumes that short-options are NOT disabled by $PARSECNTL.
  1318. + ##
  1319. X  ##    Due to the limited ability of awk, scripts using parseargs(1) cannot
  1320. X  ##    use short-options (with a  dash '-') because awk will attempt to interpret
  1321. X  ##    any such arguments as options to awk and remove them from ARGV (regardless
  1322. ***************
  1323. *** 97,103 ****
  1324. X     if ( ! PARSEOUTPUT )  PARSEOUTPUT = TMPFILE "out";
  1325. X  
  1326. X        ## build the options and required arguments for parseargs(1)
  1327. !    PARSEARGS = sprintf( "parseargs -s awk %s -- '%s'", PARSEOPTS, PROGNAME );
  1328. X  
  1329. X        ## quote each elemnt in argv and append it to the parseargs-command
  1330. X     for ( i = 1 ; i <= argc ; i++ ) {
  1331. --- 99,106 ----
  1332. X     if ( ! PARSEOUTPUT )  PARSEOUTPUT = TMPFILE "out";
  1333. X  
  1334. X        ## build the options and required arguments for parseargs(1)
  1335. !    PARSEARGS = sprintf( "parseargs -s awk %s -S '\t' -- '%s'",
  1336. !                             PARSEOPTS, PROGNAME );
  1337. X  
  1338. X        ## quote each elemnt in argv and append it to the parseargs-command
  1339. X     for ( i = 1 ; i <= argc ; i++ ) {
  1340. *** /hx1d3/lp/brad/parseargs_patch03/parseargs/parseargs.c    Wed Apr 10 09:54:07 1991
  1341. --- parseargs.c    Thu Apr 11 11:07:09 1991
  1342. ***************
  1343. *** 7,12 ****
  1344. --- 7,13 ----
  1345. X  **    to parse command-line arguments for shell scripts.  At the present,
  1346. X  **    time, VMS/DCL is not yet supported (nor are MS-DOS Batch-files).
  1347. X  **
  1348. + **
  1349. X  **    Given a command name, a vector of string-valued arguments such as that
  1350. X  **    passed to a shell script, and a specification string describing the
  1351. X  **    possible arguments, parseargs matches actual arguments to possible
  1352. ***************
  1353. *** 18,34 ****
  1354. X  **    through the use of the "PARSECNTL" environment variable.
  1355. X  **
  1356. X  **    Given the command name and the argument specification string,
  1357. ! **       parsearg -U
  1358. ! **    prints a reasonably friendly version of the usage of the
  1359. ! **    calling program on standard diagnostic output. The "verbosity" of
  1360. ! **    the usage message may be controlled through the use of the
  1361. ! **    "USAGECNTL" environment variable.
  1362. X  **
  1363. X  **    Given the command name and the argument specification string,
  1364. ! **       parsearg -M
  1365. X  **    prints a template of the command-syntax on standard output that is
  1366. X  **    suitable for input to nroff or troff using the -man macro package.
  1367. X  **
  1368. X  ** ^SEE_ALSO:
  1369. X  **    argtype(3), parseargs(1), parseargs(3), parsecntl(3),
  1370. X  **    parseargs.pl, parseargs.awk
  1371. --- 19,39 ----
  1372. X  **    through the use of the "PARSECNTL" environment variable.
  1373. X  **
  1374. X  **    Given the command name and the argument specification string,
  1375. ! **       parseargs -U
  1376. ! **    prints a reasonably friendly version of the usage of the calling program
  1377. ! **    on standard diagnostic output. The "verbosity" of the usage message may
  1378. ! **    be controlled through the use of the "USAGECNTL" environment variable.
  1379. X  **
  1380. X  **    Given the command name and the argument specification string,
  1381. ! **       parseargs -M
  1382. X  **    prints a template of the command-syntax on standard output that is
  1383. X  **    suitable for input to nroff or troff using the -man macro package.
  1384. X  **
  1385. + **    Given no other arguments,
  1386. + **       parseargs -#
  1387. + **    prints on standard output, the current version and patchlevel of the
  1388. + **    running version of parseargs.
  1389. + **
  1390. X  ** ^SEE_ALSO:
  1391. X  **    argtype(3), parseargs(1), parseargs(3), parsecntl(3),
  1392. X  **    parseargs.pl, parseargs.awk
  1393. ***************
  1394. *** 64,84 ****
  1395. X  **    newlines will be translated into spaces, or characters following a
  1396. X  **    newline may be lost, in any variables that are set by parseargs.
  1397. X  **
  1398. - **    Parseargs(1) is subject to the same caveats as parseargs(3).
  1399. - **    Refer to the CAVEATS section of the parseargs(3) for more information.
  1400. - **
  1401. X  ** ^HISTORY:
  1402. X  **    07/18/90     Brad Appleton     <brad@ssd.csd.harris.com>     Created
  1403. X  ***^^**********************************************************************/
  1404. X  
  1405. - #include <fcntl.h>
  1406. X  #include <stdio.h>
  1407. X  #include <useful.h>
  1408. X  #include "strfuncs.h"
  1409. X  
  1410. X  #define PARSEARGS_PRIVATE   /* include private definitions */
  1411. X  #include "parseargs.h"
  1412. X  
  1413. X  /*************************************************************************
  1414. X  ** ^SECTION: RETURN-CODES
  1415. X  **
  1416. --- 69,98 ----
  1417. X  **    newlines will be translated into spaces, or characters following a
  1418. X  **    newline may be lost, in any variables that are set by parseargs.
  1419. X  **
  1420. X  ** ^HISTORY:
  1421. X  **    07/18/90     Brad Appleton     <brad@ssd.csd.harris.com>     Created
  1422. + **
  1423. + **    02/--/91     Brad Appleton     <brad@ssd.csd.harris.com>
  1424. + **    - Added awk, perl, and rc to the list of shells to generate output for
  1425. + **    - added calls to vecFree in cleanup()
  1426. + **
  1427. + **    03/31/91     Brad Appleton     <brad@ssd.csd.harris.com>
  1428. + **    - fixed bug in cleanup for SunOS (added free_vectors())
  1429. + **    - fixed printing of single quotes for perl scripts
  1430. + **    - added -C option for case-insensitivity
  1431. + **    - added hidden -# option to print current version and patchlevel
  1432. X  ***^^**********************************************************************/
  1433. X  
  1434. X  #include <stdio.h>
  1435. + #include <errno.h>
  1436. X  #include <useful.h>
  1437. X  #include "strfuncs.h"
  1438. + #include "patchlevel.h"
  1439. X  
  1440. X  #define PARSEARGS_PRIVATE   /* include private definitions */
  1441. X  #include "parseargs.h"
  1442. X  
  1443. X  /*************************************************************************
  1444. X  ** ^SECTION: RETURN-CODES
  1445. X  **
  1446. ***************
  1447. *** 91,97 ****
  1448. X  /*    -- No errors, success!!
  1449. X  */
  1450. X  #define  e_USAGE     1
  1451. ! /*    -- No errors were encountered. A usage-message (or manual-page-template)
  1452. X  **       was explicitly requested (and printed) by the user.
  1453. X  */
  1454. X  #define  e_SYNTAX    2
  1455. --- 105,111 ----
  1456. X  /*    -- No errors, success!!
  1457. X  */
  1458. X  #define  e_USAGE     1
  1459. ! /*    -- No errors were encountered. A usage-message, or manual-page-template
  1460. X  **       was explicitly requested (and printed) by the user.
  1461. X  */
  1462. X  #define  e_SYNTAX    2
  1463. ***************
  1464. *** 233,239 ****
  1465. X     { "ARGV", "%s\n",    "",   "\n\n",  "'\034'",   "\n" },
  1466. X  
  1467. X     /* PERL : Positional parms in ARGV; Assignment Syntax: $name=value\n; */
  1468. !    { "ARGV", "$%s = ",  "",   ";\n",  "'.\"%c\".'",   "'" }
  1469. X  };
  1470. X  /*************************************************************************/
  1471. X  
  1472. --- 247,253 ----
  1473. X     { "ARGV", "%s\n",    "",   "\n\n",  "'\034'",   "\n" },
  1474. X  
  1475. X     /* PERL : Positional parms in ARGV; Assignment Syntax: $name=value\n; */
  1476. !    { "ARGV", "$%s = ",  "'",   "';\n",  "\\'",   "'" }
  1477. X  };
  1478. X  /*************************************************************************/
  1479. X  
  1480. ***************
  1481. *** 281,289 ****
  1482. X  EXTERN  VOID  manpage   ARGS((const ARGDESC *));
  1483. X  EXTERN  VOID  perror    ARGS((const char *));
  1484. X  
  1485. - extern  int  errno;  /* system wide error level */
  1486. X  /*************************************************************************/
  1487. X     /*
  1488. X     ** variables that are set via command-line arguments
  1489. X     */
  1490. --- 295,316 ----
  1491. X  EXTERN  VOID  manpage   ARGS((const ARGDESC *));
  1492. X  EXTERN  VOID  perror    ARGS((const char *));
  1493. X  
  1494. X  /*************************************************************************/
  1495. + /*ARGSUSED*/
  1496. + #ifdef __ANSI_C__
  1497. +    static BOOL argVers( register ARGDESC *ad,  register char *vp,  BOOL copyf )
  1498. + #else
  1499. +    static BOOL argVers( ad, vp, copyf )
  1500. +    register ARGDESC *ad;
  1501. +    register char *vp;
  1502. +    BOOL copyf;
  1503. + #endif
  1504. + {
  1505. +   printf( "%s\n", _Ident );
  1506. +   exit( e_USAGE );
  1507. + }
  1508. X     /*
  1509. X     ** variables that are set via command-line arguments
  1510. X     */
  1511. ***************
  1512. *** 312,317 ****
  1513. --- 339,346 ----
  1514. X  static  BOOL    PrManual   = FALSE;     /* ?just print manual page(s)? */
  1515. X  static  BOOL    Prompt     = FALSE;     /* ?prompt for missing args? */
  1516. X  static  BOOL    Ignore     = FALSE;     /* ?ignore bad syntax and continue? */
  1517. + static  BOOL    AnyCase    = FALSE;     /* ?case-insensitivity? */
  1518. + static  BOOL    Flags1st   = FALSE;     /* ?non-positionals first? */
  1519. X  
  1520. X  /*************************************************************************/
  1521. X     /* now we are ready to define the command-line */
  1522. ***************
  1523. *** 329,334 ****
  1524. --- 358,366 ----
  1525. X  shell assignment statements."
  1526. X  
  1527. X  CMD_ARGUMENTS
  1528. +    '#', ARGNOVAL,  argVers,  __ NULL,
  1529. +    "VERsion : just print program version, dont parse command-line",
  1530. X     'U', ARGOPT,  argBool,  __ &PrUsage,
  1531. X     "usage : just print program usage, dont parse command-line",
  1532. X  
  1533. ***************
  1534. *** 341,346 ****
  1535. --- 373,381 ----
  1536. X     'F', ARGOPT,  argStr,  __ &StrFalse,
  1537. X     "FALSEstr : string to use for FALSE Booleans  (default=\"\")",
  1538. X  
  1539. +    'C', ARGOPT,  argBool,  __ &AnyCase,
  1540. +    "caseignore : parse options using case-insensitivity",
  1541. X     'A', ARGOPT,  argBool,  __ &ModArr,
  1542. X     "array : modify the behavior of arrays",
  1543. X  
  1544. ***************
  1545. *** 376,381 ****
  1546. --- 411,419 ----
  1547. X     "ignore : ignore bad command-line syntax and continue processing \
  1548. X  (instead of aborting)",
  1549. X  
  1550. +    '1', ARGOPT,  argBool,  __ &Flags1st,
  1551. +    "1st : force non-positional arguments to precede all positional arguments",
  1552. X     '-', ARGOPT,  argDummy, __ NULL,
  1553. X     "+ : end of options - all remaining arguments are interpreted as \
  1554. SHAR_EOF
  1555. true || echo 'restore of PATCH failed'
  1556. echo 'End of  part 2'
  1557. echo 'File PATCH is continued in part 3'
  1558. echo 3 > _shar_seq_.tmp
  1559. exit 0
  1560. exit 0 # Just in case...
  1561. -- 
  1562. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  1563. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  1564. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  1565. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  1566.