home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / unix / volume26 / kit / pch20 < prev    next >
Encoding:
Text File  |  1993-05-04  |  9.4 KB  |  395 lines

  1. Newsgroups: comp.sources.unix
  2. From: ram@acri.fr (Raphael Manfredi)
  3. Subject: v26i223: kit - the ultimate mailing kit, Patch20
  4. Sender: unix-sources-moderator@efficacy.home.vix.com
  5. Approved: WhoAmI@efficacy.home.vix.com
  6.  
  7. Submitted-By: ram@acri.fr (Raphael Manfredi)
  8. Posting-Number: Volume 26, Issue 223
  9. Archive-Name: kit/pch20
  10.  
  11. [The latest patch for kit version 2.0 is #28.]
  12.  
  13. System: kit version 2.0
  14. Patch #: 20
  15. Priority: HIGH
  16. Subject: added getopt-style option parsing
  17. Date: Sun Nov  1 15:08:30 PST 1992
  18. From: Raphael Manfredi <ram@eiffel.com>
  19.  
  20. Description:
  21.     Added getopt-style option parsing for kit, mailkit and unkit. This
  22.     makes it possible to specify an argument for an option directly
  23.     after the option letter, or specify more than one argument-free
  24.     option, as in -cdv (instead of -c -d -v) or -afoo (for -a foo).
  25.  
  26.  
  27. Fix:    From rn, say "| patch -p -N -d DIR", where DIR is your kit source
  28.     directory.  Outside of rn, say "cd DIR; patch -p -N <thisarticle".
  29.     If you don't have the patch program, apply the following by hand,
  30.     or get patch (version 2.0, latest patchlevel).
  31.  
  32.     After patching:
  33.         Configure -d
  34.         make
  35.  
  36.     If patch indicates that patchlevel is the wrong version, you may need
  37.     to apply one or more previous patches, or the patch may already
  38.     have been applied.  See the patchlevel.h file to find out what has or
  39.     has not been applied.  In any event, don't continue with the patch.
  40.  
  41.     If you are missing previous patches they can be obtained from me:
  42.  
  43.         Raphael Manfredi <ram@eiffel.com>
  44.  
  45.     If you send a mail message of the following form it will greatly speed
  46.     processing:
  47.  
  48.         Subject: Command
  49.         @SH mailpatch PATH kit 2.0 LIST
  50.                ^ note the c
  51.  
  52.     where PATH is a return path FROM ME TO YOU either in Internet notation,
  53.     or in bang notation from some well-known host, and LIST is the number
  54.     of one or more patches you need, separated by spaces, commas, and/or
  55.     hyphens.  Saying 35- says everything from 35 to the end.
  56.  
  57.     To get some more detailed instructions, send me the following mail:
  58.  
  59.         Subject: Command
  60.         @SH mailhelp PATH
  61.  
  62.  
  63. Index: patchlevel.h
  64. Prereq: 19
  65. 2c2
  66. < #define PATCHLEVEL 19
  67. ---
  68. > #define PATCHLEVEL 20
  69.  
  70. Index: kit/mailkit.SH
  71. Prereq: 2.0.1.9
  72. *** kit/mailkit.SH.old    Sun Nov  1 15:08:23 1992
  73. --- kit/mailkit.SH    Sun Nov  1 15:08:24 1992
  74. ***************
  75. *** 18,26 ****
  76.   # @(#) Mailer for kit files
  77.   # @(#) (c) R. Manfredi, 1990 1991
  78.   
  79. ! # $Id: mailkit.SH,v 2.0.1.9 92/08/17 17:55:16 ram Exp $
  80.   #
  81.   # $Log:    mailkit.SH,v $
  82.   # Revision 2.0.1.9  92/08/17  17:55:16  ram
  83.   # patch18: recipient file was wrongly reported as missing
  84.   # patch18: instruction message now saved in case of error
  85. --- 18,29 ----
  86.   # @(#) Mailer for kit files
  87.   # @(#) (c) R. Manfredi, 1990 1991
  88.   
  89. ! # $Id: mailkit.SH,v 2.0.1.10 92/11/01 15:08:10 ram Exp $
  90.   #
  91.   # $Log:    mailkit.SH,v $
  92. + # Revision 2.0.1.10  92/11/01  15:08:10  ram
  93. + # patch20: added getopt-style option parsing
  94. + # 
  95.   # Revision 2.0.1.9  92/08/17  17:55:16  ram
  96.   # patch18: recipient file was wrongly reported as missing
  97.   # patch18: instruction message now saved in case of error
  98. ***************
  99. *** 93,98 ****
  100. --- 96,110 ----
  101.   unsent=''                # Parts which could not be sent
  102.   error=''                # True when error occurred
  103.   
  104. + # Ensure proper MAILER and EDITOR variables. I cannot use the ${MAILER:-def}
  105. + # construct since some shells do not recognize that (/bin/sh on the DEC 3100).
  106. + case "$MAILER" in
  107. + '') MAILER="$mailer";;
  108. + esac
  109. + case "$EDITOR" in
  110. + '') EDITOR="$editor";;
  111. + esac
  112.   # Old Bourne shells do not have functions
  113.   usage='
  114.   echo "Usage: mailkit [-EFVcefhp] [-n base] [-l file] [-r range]";
  115. ***************
  116. *** 111,116 ****
  117. --- 123,175 ----
  118.   exit 1;
  119.   '
  120.   
  121. + # Process the command line options
  122. + set X `for arg in $*; do echo $arg; done | awk '
  123. + BEGIN {
  124. +     optstr = "EFVcefhpn:l:r:";    # getopt-style specification
  125. +     len = length(optstr);
  126. +     for (i = 1; i <= len; i++) {
  127. +         c = substr(optstr, i, 1);
  128. +         if (i < len) a = substr(optstr, i + 1, 1); else a = "";
  129. +         if (a == ":") {
  130. +             arg[c] = 1;
  131. +             i++;
  132. +         }
  133. +         opt[c] = 1;
  134. +     }
  135. + }
  136. + {
  137. +     expect = 0;
  138. +     str = $0;
  139. +     if (substr(str, 1, 1) != "-") {
  140. +         print str;
  141. +         next;
  142. +     }
  143. +     len = length($0);
  144. +     for (i = 2; i <= len; i++) {
  145. +         c = substr(str, i, 1);
  146. +         if (!opt[c]) {
  147. +             print sprintf("-%s", substr(str, i));
  148. +             next;
  149. +         }
  150. +         print sprintf("-%s", c);
  151. +         if (arg[c]) {
  152. +             if (i < len)
  153. +                 print substr(str, i + 1);
  154. +             else
  155. +                 expect = 1;
  156. +             next;
  157. +         }
  158. +     }
  159. + }
  160. + END {
  161. +     if (expect)
  162. +         print "?";
  163. + }
  164. + '`
  165. + shift
  166.   # Argument parsing
  167.   while test $# -gt 0
  168.   do
  169. ***************
  170. *** 254,260 ****
  171.       fi
  172.   
  173.       # Call the editor
  174. !     ${EDITOR:-$editor} $message
  175.   
  176.       # Now remove the 4 lines at the top
  177.       # Do not use tail +5, as this may not exist on every system
  178. --- 313,319 ----
  179.       fi
  180.   
  181.       # Call the editor
  182. !     $EDITOR $message
  183.   
  184.       # Now remove the 4 lines at the top
  185.       # Do not use tail +5, as this may not exist on every system
  186. ***************
  187. *** 325,331 ****
  188.           fi
  189.           cat $part >> $topmsg
  190.           # Remove part sucessfully sent unless '-p' was used
  191. !         if ${MAILER:-$mailer} $address < $topmsg; then
  192.               test "$preserve" = no && rm -f $part
  193.           else
  194.               echo "mailkit: could not send $part." >&2
  195. --- 384,390 ----
  196.           fi
  197.           cat $part >> $topmsg
  198.           # Remove part sucessfully sent unless '-p' was used
  199. !         if $MAILER $address < $topmsg; then
  200.               test "$preserve" = no && rm -f $part
  201.           else
  202.               echo "mailkit: could not send $part." >&2
  203. ***************
  204. *** 355,361 ****
  205.   EOM
  206.       cat >>$topmsg <$message
  207.       echo "Mailing instructions..."
  208. !     if ${MAILER:-$mailer} $address < $topmsg; then
  209.           rm -f $topmsg
  210.       else
  211.           echo "mailkit: could not send instructions." >&2
  212. --- 414,420 ----
  213.   EOM
  214.       cat >>$topmsg <$message
  215.       echo "Mailing instructions..."
  216. !     if $MAILER $address < $topmsg; then
  217.           rm -f $topmsg
  218.       else
  219.           echo "mailkit: could not send instructions." >&2
  220.  
  221. Index: kit/unkit.SH
  222. Prereq: 2.0.1.12
  223. *** kit/unkit.SH.old    Sun Nov  1 15:08:28 1992
  224. --- kit/unkit.SH    Sun Nov  1 15:08:29 1992
  225. ***************
  226. *** 19,27 ****
  227.   # @(#) (c) E. Mogenet April 1990
  228.   # @(#) (c) R. Manfredi, 1990 1991
  229.   
  230. ! # $Id: unkit.SH,v 2.0.1.12 92/09/04 19:28:28 ram Exp $
  231.   #
  232.   # $Log:    unkit.SH,v $
  233.   # Revision 2.0.1.12  92/09/04  19:28:28  ram
  234.   # patch19: unkit will use perl instead of awk, if available
  235.   # patch19: now smart enough to deal with multiple parts from stdin
  236. --- 19,30 ----
  237.   # @(#) (c) E. Mogenet April 1990
  238.   # @(#) (c) R. Manfredi, 1990 1991
  239.   
  240. ! # $Id: unkit.SH,v 2.0.1.13 92/11/01 15:08:15 ram Exp $
  241.   #
  242.   # $Log:    unkit.SH,v $
  243. + # Revision 2.0.1.13  92/11/01  15:08:15  ram
  244. + # patch20: added getopt-style option parsing
  245. + # 
  246.   # Revision 2.0.1.12  92/09/04  19:28:28  ram
  247.   # patch19: unkit will use perl instead of awk, if available
  248.   # patch19: now smart enough to deal with multiple parts from stdin
  249. ***************
  250. *** 127,132 ****
  251. --- 130,182 ----
  252.   echo " "" -V : print current version and patch-level.";
  253.   exit 1
  254.   '
  255. + # Process the command line options
  256. + set X `for arg in $*; do echo $arg; done | awk '
  257. + BEGIN {
  258. +     optstr = "bhlprVk:";    # getopt-style specification
  259. +     len = length(optstr);
  260. +     for (i = 1; i <= len; i++) {
  261. +         c = substr(optstr, i, 1);
  262. +         if (i < len) a = substr(optstr, i + 1, 1); else a = "";
  263. +         if (a == ":") {
  264. +             arg[c] = 1;
  265. +             i++;
  266. +         }
  267. +         opt[c] = 1;
  268. +     }
  269. + }
  270. + {
  271. +     expect = 0;
  272. +     str = $0;
  273. +     if (substr(str, 1, 1) != "-") {
  274. +         print str;
  275. +         next;
  276. +     }
  277. +     len = length($0);
  278. +     for (i = 2; i <= len; i++) {
  279. +         c = substr(str, i, 1);
  280. +         if (!opt[c]) {
  281. +             print sprintf("-%s", substr(str, i));
  282. +             next;
  283. +         }
  284. +         print sprintf("-%s", c);
  285. +         if (arg[c]) {
  286. +             if (i < len)
  287. +                 print substr(str, i + 1);
  288. +             else
  289. +                 expect = 1;
  290. +             next;
  291. +         }
  292. +     }
  293. + }
  294. + END {
  295. +     if (expect)
  296. +         print "?";
  297. + }
  298. + '`
  299. + shift
  300.   
  301.   # Option parsing
  302.   while test $# -gt 0
  303.  
  304. Index: kit/kit.SH
  305. Prereq: 2.0.1.10
  306. *** kit/kit.SH.old    Sun Nov  1 15:08:19 1992
  307. --- kit/kit.SH    Sun Nov  1 15:08:20 1992
  308. ***************
  309. *** 26,34 ****
  310.   !GROK!THIS!
  311.   $spitshell >>kit <<'!NO!SUBS!'
  312.   
  313. ! # $Id: kit.SH,v 2.0.1.10 92/05/02 14:13:45 ram Exp $
  314.   #
  315.   # $Log:    kit.SH,v $
  316.   # Revision 2.0.1.10  92/05/02  14:13:45  ram
  317.   # patch16: new option -S to set maximum part size
  318.   # 
  319. --- 26,37 ----
  320.   !GROK!THIS!
  321.   $spitshell >>kit <<'!NO!SUBS!'
  322.   
  323. ! # $Id: kit.SH,v 2.0.1.11 92/11/01 15:08:04 ram Exp $
  324.   #
  325.   # $Log:    kit.SH,v $
  326. + # Revision 2.0.1.11  92/11/01  15:08:04  ram
  327. + # patch20: added getopt-style option parsing
  328. + # 
  329.   # Revision 2.0.1.10  92/05/02  14:13:45  ram
  330.   # patch16: new option -S to set maximum part size
  331.   # 
  332. ***************
  333. *** 124,129 ****
  334. --- 127,179 ----
  335.   echo " "" -x : use Cipher Block Chaining DES encryption (default).";
  336.   exit 1
  337.   '
  338. + # Process the command line options
  339. + set X `for arg in $*; do echo $arg; done | awk '
  340. + BEGIN {
  341. +     optstr = "BEFHMVXefhpxS:a:d:k:l:m:n:s:";    # getopt-style specification
  342. +     len = length(optstr);
  343. +     for (i = 1; i <= len; i++) {
  344. +         c = substr(optstr, i, 1);
  345. +         if (i < len) a = substr(optstr, i + 1, 1); else a = "";
  346. +         if (a == ":") {
  347. +             arg[c] = 1;
  348. +             i++;
  349. +         }
  350. +         opt[c] = 1;
  351. +     }
  352. + }
  353. + {
  354. +     expect = 0;
  355. +     str = $0;
  356. +     if (substr(str, 1, 1) != "-") {
  357. +         print str;
  358. +         next;
  359. +     }
  360. +     len = length($0);
  361. +     for (i = 2; i <= len; i++) {
  362. +         c = substr(str, i, 1);
  363. +         if (!opt[c]) {
  364. +             print sprintf("-%s", substr(str, i));
  365. +             next;
  366. +         }
  367. +         print sprintf("-%s", c);
  368. +         if (arg[c]) {
  369. +             if (i < len)
  370. +                 print substr(str, i + 1);
  371. +             else
  372. +                 expect = 1;
  373. +             next;
  374. +         }
  375. +     }
  376. + }
  377. + END {
  378. +     if (expect)
  379. +         print "?";
  380. + }
  381. + '`
  382. + shift
  383.   
  384.   while test $# -gt 0
  385.   do
  386.  
  387. *** End of Patch 20 ***
  388.