home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume18 / parseargs / patch04d < prev    next >
Internet Message Format  |  1991-04-25  |  12KB

  1. From: brad@hcx1.ssd.csd.harris.com (Brad Appleton)
  2. Newsgroups: comp.sources.misc
  3. Subject: v18i104:  parseargs - functions to parse command line arguments, Patch04d/4
  4. Message-ID: <1991Apr26.040454.18895@sparky.IMD.Sterling.COM>
  5. Date: 26 Apr 91 04:04:54 GMT
  6. Approved: kent@sparky.imd.sterling.com
  7. X-Checksum-Snefru: b8a5edf7 e56c9272 ef1d84a2 28c57b7c
  8.  
  9. Submitted-by: Brad Appleton <brad@hcx1.ssd.csd.harris.com>
  10. Posting-number: Volume 18, Issue 104
  11. Archive-name: parseargs/patch04d
  12. Patch-To: parseargs: Volume 17, Issue 45-57
  13.  
  14. #!/bin/sh
  15. # This is part 4 of a multipart archive
  16. # do not concatenate these parts, unpack them in order with /bin/sh
  17. # file PATCH 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" != 4; 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 PATCH'
  32. sed 's/^X//' << 'SHAR_EOF' >> 'PATCH' &&
  33. X  
  34. X        /* scan for missing required args */
  35. X     if ( SYNTAX_ERROR(rc, argd) ) {
  36. ***************
  37. *** 1971,1976 ****
  38. --- 2003,2011 ----
  39. X        exit( 2 );
  40. X     }
  41. X  
  42. +       /* reset previous parse flags */
  43. +    cmd_flags(argd)  =  saveflags;
  44. X     return  rc;
  45. X  }
  46. X  
  47. ***************
  48. *** 1997,2003 ****
  49. X    
  50. X  /* ^DESCRIPTION:
  51. X  **    Given an ArgList and an argdesc array, lparseargs will parse arguments
  52. ! **    in an ArgList in much the same manner as parseargs.
  53. X  **
  54. X  ** ^REQUIREMENTS:
  55. X  **    <argls> should be an ArgList of strings
  56. --- 2032,2038 ----
  57. X    
  58. X  /* ^DESCRIPTION:
  59. X  **    Given an ArgList and an argdesc array, lparseargs will parse arguments
  60. ! **    in an ArgList in the same manner as parseargs.
  61. X  **
  62. X  ** ^REQUIREMENTS:
  63. X  **    <argls> should be an ArgList of strings
  64. ***************
  65. *** 2055,2063 ****
  66. X     BSET(cmd_flags(argd), pa_ARGV0);
  67. X     rc = parse_argv_style( argv, parse_init( &argd ) );
  68. X  
  69. -       /* reset previous parse-flags */
  70. -    cmd_flags(argd) = saveflags;
  71. X        /* scan for missing required arguments */
  72. X     if ( SYNTAX_ERROR(rc, argd) ) {
  73. X        fputc( '\n', stderr );
  74. --- 2090,2095 ----
  75. ***************
  76. *** 2065,2070 ****
  77. --- 2097,2105 ----
  78. X        exit( 2 );
  79. X     }
  80. X  
  81. +       /* reset previous parse-flags */
  82. +    cmd_flags(argd) = saveflags;
  83. X     return   rc;
  84. X  }
  85. X  
  86. ***************
  87. *** 2093,2099 ****
  88. X  /* ^DESCRIPTION:
  89. X  **    Vparseargs takes an argdesc array, the number of arguments to parse,
  90. X  **    and a (possibly NULL terminated) list of argument-strings and parses
  91. ! **    them in much the same manner as parseargs.  Unlike sparseargs,
  92. X  **    vparseargs assumes that all parameters are already split up into
  93. X  **    tokens, hence any whitespace characters contained in any of the
  94. X  **    string-parameters are used as is (and will be considered a part of
  95. --- 2128,2134 ----
  96. X  /* ^DESCRIPTION:
  97. X  **    Vparseargs takes an argdesc array, the number of arguments to parse,
  98. X  **    and a (possibly NULL terminated) list of argument-strings and parses
  99. ! **    them in the same manner as parseargs.  Unlike sparseargs,
  100. X  **    vparseargs assumes that all parameters are already split up into
  101. X  **    tokens, hence any whitespace characters contained in any of the
  102. X  **    string-parameters are used as is (and will be considered a part of
  103. ***************
  104. *** 2158,2166 ****
  105. X  
  106. X     rc = parse_argv_style( argv, parse_init( &argd ) );
  107. X  
  108. -       /* reset previous parse-flags */
  109. -    cmd_flags(argd) = saveflags;
  110. X        /* scan for missing required arguments */
  111. X     if ( SYNTAX_ERROR(rc, argd) ) {
  112. X        fputc( '\n', stderr );
  113. --- 2193,2198 ----
  114. ***************
  115. *** 2168,2173 ****
  116. --- 2200,2208 ----
  117. X        exit( 2 );
  118. X     }
  119. X  
  120. +       /* reset previous parse-flags */
  121. +    cmd_flags(argd) = saveflags;
  122. X     return   rc;
  123. X  }
  124. X  
  125. ***************
  126. *** 2241,2249 ****
  127. X  
  128. X     rc = parse_argv_style( av, parse_init( &argd ) );
  129. X  
  130. -       /* reset previous parse-flags */
  131. -    cmd_flags(cmd) = saveflags;
  132. X        /* scan for missing required arguments */
  133. X     if ( SYNTAX_ERROR(rc, argd) ) {
  134. X        fputc( '\n', stderr );
  135. --- 2276,2281 ----
  136. ***************
  137. *** 2250,2255 ****
  138. --- 2282,2290 ----
  139. X        usage( argd );
  140. X        exit( 2 );
  141. X     }
  142. +       /* reset previous parse-flags */
  143. +    cmd_flags(cmd) = saveflags;
  144. X  
  145. X     return  rc;
  146. X  }
  147. SHAR_EOF
  148. echo 'File PATCH is complete' &&
  149. chmod 0664 PATCH ||
  150. echo 'restore of PATCH failed'
  151. Wc_c="`wc -c < 'PATCH'`"
  152. test 79034 -eq "$Wc_c" ||
  153.     echo 'PATCH: original size 79034, current size' "$Wc_c"
  154. # ============= doc/Makefile ==============
  155. if test ! -d 'doc'; then
  156.     echo 'x - creating directory doc'
  157.     mkdir 'doc'
  158. fi
  159. echo 'x - extracting doc/Makefile (Text)'
  160. sed 's/^X//' << 'SHAR_EOF' > 'doc/Makefile' &&
  161. # $Header: Man.mk,v 1.0 90/03/05 09:21:28 brad Exp $
  162. X
  163. ###
  164. # target directories
  165. ###
  166. MAN1=    man1
  167. MAN3=    man3
  168. LOCALMAN=    local_man
  169. MANDIR=    /usr/man/${LOCALMAN}
  170. CATMANDIR=    /usr/catman/${LOCALMAN}
  171. X
  172. ###
  173. # commands
  174. ###
  175. COL=    col
  176. COLFLAGS=    -b
  177. SOELIM=    /usr/ucb/soelim
  178. MANTOCATMAN=    /usr/ucb/mantocatman
  179. TROFF=    roff
  180. TRFLAGS=    -man -dimagen1
  181. NROFF=    nroff
  182. NRFLAGS=    -man
  183. SPELL=    spell
  184. COPY=    /bin/cp
  185. DEL=    /bin/rm -f
  186. X
  187. ###
  188. # files used
  189. ###
  190. INCS=    *.inc
  191. SRCS=    argtype.man3  parseargs.man1  parseargs.man3  parsecntl.man3
  192. MANIFEST=    Manifest
  193. MAN3FILES=    argtype.3  parseargs.3  parsecntl.3
  194. MAN1FILES=    parseargs.1
  195. CATMAN3FILES=    argtype.3.z  parseargs.3.z  parsecntl.3.z
  196. CATMAN1FILES=    parseargs.1.z
  197. X
  198. ###
  199. # target dependencies
  200. ###
  201. .SUFFIXES: .man1 .man3 .1 .3
  202. X
  203. .man1.1:
  204. X    ${SOELIM} $< >$*.1
  205. X    ${MANTOCATMAN} $*.1
  206. X
  207. .man3.3:
  208. X    ${SOELIM} $< >$*.3
  209. X    ${MANTOCATMAN} $*.3
  210. X
  211. ###
  212. # give a usage message if no target is given
  213. ###
  214. usage:
  215. X    @echo "Usage: make <target>"
  216. X    @echo " "
  217. X    @echo "where <target> is one of the following: "
  218. X    @echo " "
  219. X    @echo "   install  -- to install the documentation"
  220. X    @echo "   installman  -- to install the unpacked documentation"
  221. X    @echo "   installcatman  -- to install the packed documentation"
  222. X    @echo "   print  -- to print the documentation"
  223. X    @echo "   view   -- to view the documentation"
  224. X    @echo "   text   -- to build text copies of the documentation"
  225. X    @echo "   spell  -- to spell check the documentation"
  226. X    @echo "   clean  -- to remove all intermediate files"
  227. X    @echo "   clobber  -- to remove all created files"
  228. X
  229. ###
  230. # installation dependencies
  231. ###
  232. install: installman installcatman
  233. X
  234. installman: installman1 installman3
  235. X
  236. installcatman: installcatman1 installcatman3
  237. X
  238. installman1: ${MAN1FILES}
  239. X    ${COPY} ${MAN1FILES} ${MANDIR}/${MAN1}
  240. X
  241. installcatman1: ${CATMAN1FILES}
  242. X    ${COPY} ${CATMAN1FILES} ${CATMANDIR}/${MAN1}
  243. X
  244. installman3: ${MAN3FILES}
  245. X    ${COPY} ${MAN3FILES} ${MANDIR}/${MAN3}
  246. X
  247. installcatman3: ${CATMAN3FILES}
  248. X    ${COPY} ${CATMAN3FILES} ${CATMANDIR}/${MAN3}
  249. X
  250. ###
  251. # include dependencies
  252. ###
  253. argtype.3:
  254. parseargs.1:
  255. parseargs.3:
  256. parsecntl.3:
  257. X
  258. X
  259. ###
  260. # maintenance dependencies
  261. ###
  262. clean:
  263. X    ${DEL} ${MAN1FILES} ${MAN3FILES} ${CATMAN1FILES} ${CATMAN3FILES}
  264. X
  265. clobber: clean
  266. X    ${DEL} *.txt
  267. X
  268. spell: ${INCS} ${SRCS}}
  269. X    ${SPELL} ${SPELLFLAGS} ${INCS} ${SRCS}
  270. X
  271. print: ${MANFILES} ${INCS}
  272. X    ${TROFF} ${TRFLAGS} ${SRCS}
  273. X
  274. text: ascii
  275. txt: ascii
  276. ascii:
  277. X    ${NROFF} ${NRFLAGS} argtype.man3 | ${COL} ${COLFLAGS} >argtype3.txt
  278. X    ${NROFF} ${NRFLAGS} parseargs.man1 | ${COL} ${COLFLAGS} >parseargs1.txt
  279. X    ${NROFF} ${NRFLAGS} parseargs.man3 | ${COL} ${COLFLAGS} >parseargs3.txt
  280. X    ${NROFF} ${NRFLAGS} parsecntl.man3 | ${COL} ${COLFLAGS} >parsecntl3.txt
  281. X
  282. view: ${MANFILES} ${INCS}
  283. X    ${NROFF} ${NRFLAGS} ${SRCS}
  284. X
  285. SHAR_EOF
  286. chmod 0664 doc/Makefile ||
  287. echo 'restore of doc/Makefile failed'
  288. Wc_c="`wc -c < 'doc/Makefile'`"
  289. test 2667 -eq "$Wc_c" ||
  290.     echo 'doc/Makefile: original size 2667, current size' "$Wc_c"
  291. # ============= doc/effects.inc ==============
  292. echo 'x - extracting doc/effects.inc (Text)'
  293. sed 's/^X//' << 'SHAR_EOF' > 'doc/effects.inc' &&
  294. .\"----------------------------------------------------------------------------
  295. .\"-- This text was extracted using the following command:
  296. .\"--   xdoc -man -n -p '[ \t]*' -I SIDE-EFFECTS  ../xparse.c
  297. .\"----------------------------------------------------------------------------
  298. .SH "SIDE EFFECTS"
  299. .PP
  300. Each of the functions in the \fIparseargs\fP library will set the external
  301. character string \fIProgName\fP to be the name of the last command that
  302. was operated upon by any of the library routines.
  303. .PP
  304. When an argument-descriptor array is first encountered by any of the
  305. parseargs library routines, it is initially compiled into an intermediate
  306. form that is more convenient to manipulate. As a direct result, it is not
  307. advisable to attempt to index directly into the array to manipulate one
  308. of the argument descriptors (because the argdesc that you thought was there
  309. may actually be somewhere else). After the array has been given its initial
  310. value(s), only \fIparsecntl\fP(3) should be used to manipulate or query the
  311. attributes of an argument descriptor.
  312. SHAR_EOF
  313. chmod 0664 doc/effects.inc ||
  314. echo 'restore of doc/effects.inc failed'
  315. Wc_c="`wc -c < 'doc/effects.inc'`"
  316. test 1060 -eq "$Wc_c" ||
  317.     echo 'doc/effects.inc: original size 1060, current size' "$Wc_c"
  318. # ============= patchlevel.h ==============
  319. echo 'x - extracting patchlevel.h (Text)'
  320. sed 's/^X//' << 'SHAR_EOF' > 'patchlevel.h' &&
  321. /*************************************************************************
  322. ** ^FILE: patchlevel.h - current patchlevel for parseargs
  323. **
  324. ** ^HISTORY:
  325. **    04/10/91    Brad Appleton    <brad@ssd.csd.harris.com>
  326. **    Patch04
  327. **    - fixed problem with prompting in xparse.c:prompt_user()
  328. **    - under vms, getenv was defined to be 'getsymbol', it should be
  329. **      'get_symbol' (note the underscore).
  330. **    - now uses <errno.h>
  331. **    - parseargs no longer included <fcntl.h>
  332. **    - fix bug in vms_args.c printing '[]' for required args and vis-a-vis
  333. **    - fixed bug in argInput and argOutput in argtype.c
  334. **    - fixed bug in <os>_args.c where ARGVALGIVEN was improperly being
  335. **      cleared if the argument was a list or a vector. This was causing
  336. **      parseargs(1) to screw up on optional lists.
  337. **    - fixed bug in strfuncs.c:strnicmp()
  338. **    - changed strfuncs.[ch] so that my version of strdup is always used
  339. **      (my version dies if malloc failed, others return NULL).
  340. **    - Added some changes for SUN and VAX
  341. **    - Added -1 option to parseargs(1)
  342. **    - Unhid the -# option to parseargs(1)
  343. **    - More documentation fixes
  344. **
  345. **    04/04/91    Brad Appleton    <brad@ssd.csd.harris.com>
  346. **    Patch04 (continued)
  347. **    - fixed bug in xparse.c with PARSECNTL='Prompt' being ignored.
  348. **    - added test.pl to test.all and added options to test.all
  349. **    - fixed newline printing error in perl-scripts for parseargs(1)
  350. **    - added -C option to parseargs(1) and to the docs
  351. **    - added "patchlevel.h" to distribution
  352. **    - added "what" string with version and patch level for parseargs(1)
  353. **    - added hidden -# option to parseargs(1)
  354. **    - add "doc/effects.inc" to distribution
  355. **    - fix docs
  356. **    - fix test.rc for Plan 9 shell
  357. **    - fix parseargs(1) quoting for perl
  358. **
  359. **    03/22/91    Brad Appleton    <brad@ssd.csd.harris.com>
  360. **    Patch03
  361. **    - ascii docs fix
  362. **
  363. **    03/21/91    Brad Appleton    <brad@ssd.csd.harris.com>
  364. **    Patch02
  365. **    - documentation fix
  366. **
  367. **    03/12/91    Brad Appleton    <brad@ssd.csd.harris.com>
  368. **    Patch01
  369. **    - documentation fix
  370. **
  371. **    03/02/91    Brad Appleton    <brad@ssd.csd.harris.com>    Created
  372. ***^^********************************************************************/
  373. X
  374. #define  VERSION     2
  375. #define  REVISION    0
  376. #define  PATCHLEVEL  4
  377. X
  378. #ifdef __STDC__
  379. X   static const char
  380. #else
  381. X   static char
  382. #endif
  383. X   _Ident[] = "@(#)parseargs  2.0  patchlevel 4";
  384. SHAR_EOF
  385. chmod 0664 patchlevel.h ||
  386. echo 'restore of patchlevel.h failed'
  387. Wc_c="`wc -c < 'patchlevel.h'`"
  388. test 2409 -eq "$Wc_c" ||
  389.     echo 'patchlevel.h: original size 2409, current size' "$Wc_c"
  390. rm -f _shar_seq_.tmp
  391. echo You have unpacked the last part
  392. exit 0
  393. exit 0 # Just in case...
  394. -- 
  395. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  396. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  397. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  398. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  399.