home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / mail / elm / 3355 < prev    next >
Encoding:
Internet Message Format  |  1992-11-17  |  53.4 KB

  1. Xref: sparky comp.mail.elm:3355 comp.sources.bugs:273
  2. Newsgroups: comp.mail.elm,comp.sources.bugs
  3. Path: sparky!uunet!ukma!cs.widener.edu!dsinc!syd
  4. From: syd@dsinc.DSI.COM (Syd Weinstein)
  5. Subject: elm 2.4 Patch #9
  6. Message-ID: <1992Nov17.191856.8050@DSI.COM>
  7. Followup-To: poster
  8. Summary: This is an official patch for elm 2.4 system.  Please apply it.
  9. Sender: syd@DSI.COM (Syd Weinstein)
  10. Priority: HIGH
  11. Organization: Datacomp Systems, Inc., Huntingdon Valley, PA 19006
  12. Date: Tue, 17 Nov 1992 19:18:56 GMT
  13. Lines: 1977
  14.  
  15. part 1 of a 2 part patch
  16.  
  17. I think that the code in 'newmbox.c' which handles bad 'Content-length'
  18. entries is incomplete. The file-ptr for the mail file is
  19. backed up, but the file-ptr of the temp file WAS LEFT UNMODIFIED !
  20. From langesw.ssw.de!root Wed Nov 11 14:28:57 1992
  21.  
  22. When elm copies the temp mailbox back to the mail spool to resync or
  23. quit, it changes to the mailgroup before attempting to diddle in the
  24. mail spool, but when it copies the temp mailbox back to the mail spool
  25. after editing, it forgets to change to mailgroup.  This patch appears
  26. to work, but I haven't exhaustively checked for some path that leaves
  27. the gid set
  28. wrong.  From: dwolfe@pffft.sps.mot.com (Dave Wolfe)
  29.  
  30. There's an error in two messages in s_aliases.m which causes elm2.4
  31. to core dump when resyncronize aliases. (%s/%s) should be (%c/%c).
  32.  
  33. This bug doesn't show up unless you use message cataloges, since the default
  34. message in a_quit.c is correct.
  35. From: Jan Djarv <Jan.Djarv@sa.erisoft.se>
  36.  
  37. Fix how nls emulation lib gencat links prev pointers
  38. From: Jan Djarv <Jan.Djarv@sa.erisoft.se>
  39.  
  40. The alias message_count isn't set to zero if the last alias has
  41. been deleted from the alias table. As no aliases are reread from
  42. the aliases database the message_count is left as it was before.
  43.  
  44. Fixed that the function do_newalias() sometimes returns without freeing
  45. the buffer allocated before. The patch adds these free calls.
  46.  
  47. When you erroneously type a number in your folder elm asks you for
  48. a new current message number. But now if you erase this one number
  49. and leave the string empty elm will set the new current message to
  50. the second message on our sun4! The patch adds a check for an empty
  51. string and returns the current number if no number was entered.
  52. From: vogt@isa.de (Gerald Vogt)
  53.  
  54. The situation is that the .elm/aliases file is missing, but
  55. .elm/aliases.dir and .elm/aliases.pag exist (isn't serendipity
  56. wonderful?).  The ndbz functions tolerate this and just put a NULL
  57. pointer in the db structure for the data file FILE pointer.  However,
  58. get_one_alias() in listalias and elm doesn't account for the db_open()
  59. succeeding but the dbz_basef field being NULL, so it passes the NULL
  60. pointer to fread().  Detect null and return 0
  61. From: dwolfe@pffft.sps.mot.com (Dave Wolfe)
  62.  
  63. Clear the screen before displaying MIME:
  64. From: marius@rhi.hi.is (Marius Olafsson)
  65.  
  66. Add regexp processing to filter.
  67. Add execc operator
  68. From: Jan Djarv <Jan.Djarv@sa.erisoft.se>
  69.  
  70. Fix:    From rn, say "| patch -p -N -d DIR", where DIR is your elm source
  71.     directory.  Outside of rn, say "cd DIR; patch -p -N <thisarticle".
  72.     If you don't have the patch program, apply the following by hand,
  73.     or get patch (version 2.0, latest patchlevel).
  74.  
  75.     After patching:
  76.         Do nothing, apply patch 10 next
  77.  
  78.     If patch indicates that patchlevel is the wrong version, you may need
  79.     to apply one or more previous patches, or the patch may already
  80.     have been applied.  See the patchlevel.h file to find out what has or
  81.     has not been applied.  In any event, don't continue with the patch.
  82.  
  83.     If you are missing previous patches they can be obtained from our:
  84.     archive server.
  85.  
  86.     Syd Weinstein
  87.     elm@DSI.COM
  88.  
  89.     The patches are available from the dsinc archive server
  90.     Send the following message to archive-server@DSI.COM for
  91.     a list of available patches:
  92.  
  93.     Subject: patch list
  94.     send index elm
  95.  
  96. Index: hdrs/patchlevel.h
  97. Prereq: "8"
  98. *** ../elm2.4/hdrs/patchlevel.h    Tue Nov 10 15:20:28 1992
  99. --- hdrs/patchlevel.h    Sat Nov 14 16:40:24 1992
  100. ***************
  101. *** 1 ****
  102. ! #define PATCHLEVEL "8"
  103. --- 1 ----
  104. ! #define PATCHLEVEL "9"
  105.  
  106. Index: Configure
  107. Prereq: 5.6
  108. *** ../elm2.4/Configure    Tue Oct 27 11:17:21 1992
  109. --- Configure    Tue Nov 17 13:19:52 1992
  110. ***************
  111. *** 8,14 ****
  112.   # and edit it to reflect your system.  Some packages may include samples
  113.   # of config.h for certain machines, so you might look for one of those.)
  114.   #
  115. ! # $Header: /home/syd/elm.rel/RCS/Configure,v 5.6 1992/10/25 02:18:36 syd Exp $
  116.   #
  117.   # Yes, you may rip this off to use in other distribution packages.
  118.   # (Note: this Configure script was generated automatically.  Rather than
  119. --- 8,14 ----
  120.   # and edit it to reflect your system.  Some packages may include samples
  121.   # of config.h for certain machines, so you might look for one of those.)
  122.   #
  123. ! # $Header: /home/syd/elm.rel/RCS/Configure,v 5.9 1992/11/17 18:19:47 syd Exp $
  124.   #
  125.   # Yes, you may rip this off to use in other distribution packages.
  126.   # (Note: this Configure script was generated automatically.  Rather than
  127. ***************
  128. *** 205,210 ****
  129. --- 205,211 ----
  130.   d_termio=''
  131.   d_termios=''
  132.   d_tz_min=''
  133. + d_tzname=''
  134.   d_useembed=''
  135.   d_utimbuf=''
  136.   d_vfork=''
  137. ***************
  138. *** 303,309 ****
  139.   attrlist="$attrlist $mc68k __STDC__ UTS M_I8086 M_I186 M_I286 M_I386"
  140.   attrlist="$attrlist i186 __m88k__ m88k DGUX __DGUX__ NeXT _AIX"
  141.   pth="/bin /usr/bin /usr/ucb /sbin /usr/sbin /usr/local /usr/local/bin /usr/lbin"
  142. ! pth="$pth /usr/5bin /vol/local/bin /etc /usr/bsd /usr/lib /usr/css/lib /lib"
  143.   pth="$pth /usr/local/lib /sys5.3/bin /sys5.3/usr/bin /bsd4.3/bin /bsd4.3/usr/bin /bsd4.3/usr/ucb"
  144.   pth="$pth /usr/convex /usr/mmdf/bin /usr/mmdf/lib ${BSDBASE-/bsd}/usr/ucb ${BSDBASE-/bsd}/bin ${BSDBASE-/bsd}/usr/bin"
  145.   
  146. --- 304,310 ----
  147.   attrlist="$attrlist $mc68k __STDC__ UTS M_I8086 M_I186 M_I286 M_I386"
  148.   attrlist="$attrlist i186 __m88k__ m88k DGUX __DGUX__ NeXT _AIX"
  149.   pth="/bin /usr/bin /usr/ucb /sbin /usr/sbin /usr/local /usr/local/bin /usr/lbin"
  150. ! pth="$pth /usr/5bin /vol/local/bin /etc /usr/bsd /usr/lib /usr/ccs/lib /usr/ccs/bin /lib"
  151.   pth="$pth /usr/local/lib /sys5.3/bin /sys5.3/usr/bin /bsd4.3/bin /bsd4.3/usr/bin /bsd4.3/usr/ucb"
  152.   pth="$pth /usr/convex /usr/mmdf/bin /usr/mmdf/lib ${BSDBASE-/bsd}/usr/ucb ${BSDBASE-/bsd}/bin ${BSDBASE-/bsd}/usr/bin"
  153.   
  154. ***************
  155. *** 798,804 ****
  156.   if $test -f "$uname"; then
  157.       uname_os=`uname -s`
  158.       uname_rel=`uname -r`
  159. !     uname_rel=`expr "$uname" : "\(...\).*"`
  160.   else
  161.       uname_os=unknown
  162.       uname_rel=unknown
  163. --- 799,805 ----
  164.   if $test -f "$uname"; then
  165.       uname_os=`uname -s`
  166.       uname_rel=`uname -r`
  167. !     uname_rel=`expr "$uname_rel" : "\(...\).*"`
  168.   else
  169.       uname_os=unknown
  170.       uname_rel=unknown
  171. ***************
  172. *** 810,816 ****
  173.       echo exit 0 >usg
  174.       echo exit 1 >v7
  175.   elif $contains SIGTSTP foo >/dev/null 2>&1 ; then
  176. !     if $test "$uname_os" = "SunOs" -a "$uname_rel" = "4.1" ; then
  177.       echo "Looks like SunOs 4.1, a USG system, but we'll see..."
  178.       echo exit 1 >bsd
  179.       echo exit 0 >usg
  180. --- 811,817 ----
  181.       echo exit 0 >usg
  182.       echo exit 1 >v7
  183.   elif $contains SIGTSTP foo >/dev/null 2>&1 ; then
  184. !     if $test "(" $uname_os" = "SunOS" -a "$uname_rel" = "4.1")" ; then
  185.       echo "Looks like SunOs 4.1, a USG system, but we'll see..."
  186.       echo exit 1 >bsd
  187.       echo exit 0 >usg
  188. ***************
  189. *** 1405,1411 ****
  190.   
  191.   case "$ccflags" in
  192.   '') case "$cc" in
  193. !     *gcc*) dflt='-fpcc-struct-return';;
  194.       *) dflt='';;
  195.       esac
  196.       ;;
  197. --- 1406,1412 ----
  198.   
  199.   case "$ccflags" in
  200.   '') case "$cc" in
  201. !     *gcc*) dflt='-fpcc-struct-return -traditional';;
  202.       *) dflt='';;
  203.       esac
  204.       ;;
  205. ***************
  206. *** 3700,3705 ****
  207. --- 3701,3710 ----
  208.       d_tz_min="$undef"
  209.   fi
  210.   $rm -f try.c
  211. + : see if there is a tzname
  212. + set tzname d_tzname
  213. + eval $inlibc
  214.   : check for valid reply/to fields
  215.   case "$d_useembed" in
  216.   "$define")    dflt=y;;
  217. ***************
  218. *** 4516,4521 ****
  219. --- 4521,4527 ----
  220.   d_termio='$d_termio'
  221.   d_termios='$d_termios'
  222.   d_tz_min='$d_tz_min'
  223. + d_tzname='$d_tzname'
  224.   d_useembed='$d_useembed'
  225.   d_utimbuf='$d_utimbuf'
  226.   d_vfork='$d_vfork'
  227.  
  228. Index: config.h.SH
  229. *** ../elm2.4/config.h.SH    Tue Oct 27 11:17:22 1992
  230. --- config.h.SH    Sat Nov 14 21:11:40 1992
  231. ***************
  232. *** 496,501 ****
  233. --- 496,506 ----
  234.    */
  235.   #$d_tz_min    TZ_MINUTESWEST     /**/
  236.   
  237. + /* TZNAME:
  238. +  *    This symbol, if defined, indicates that extern char *tzname[] exists.
  239. +  */
  240. + #$d_tzname    TZNAME    /**/
  241.   /* USE_EMBEDDED_ADDRESSES:
  242.    *    This symbol, if defined, indicates that replyto: and from:
  243.    *    headers can be trusted.
  244.  
  245. Index: Instruct
  246. *** ../elm2.4/Instruct    Sat Oct  3 18:12:32 1992
  247. --- Instruct    Sat Nov 14 20:07:24 1992
  248. ***************
  249. *** 1,7 ****
  250.                   Instructions
  251.                   ------------
  252.   
  253. !                 Last Update: $Date: 1992/10/03 22:12:17 $
  254.   
  255.   
  256.       This file contains instructions on how to create and install
  257. --- 1,7 ----
  258.                   Instructions
  259.                   ------------
  260.   
  261. !                 Last Update: $Date: 1992/11/15 01:07:19 $
  262.   
  263.   
  264.       This file contains instructions on how to create and install
  265. ***************
  266. *** 16,22 ****
  267.   
  268.       $ sh Configure
  269.   
  270. !     Answer the questions of that program,, then let it create the
  271.   localized Makefiles and system definition files for you.  When it's
  272.   done you can double check the configuration (or customize it further)
  273.   by reading the Configuration Guide and then rerunning Configure.
  274. --- 16,22 ----
  275.   
  276.       $ sh Configure
  277.   
  278. !     Answer the questions of that program, then let it create the
  279.   localized Makefiles and system definition files for you.  When it's
  280.   done you can double check the configuration (or customize it further)
  281.   by reading the Configuration Guide and then rerunning Configure.
  282.  
  283. Index: MANIFEST
  284. *** ../elm2.4/MANIFEST    Tue Nov 10 15:20:21 1992
  285. --- MANIFEST    Sat Nov 14 20:35:44 1992
  286. ***************
  287. *** 43,48 ****
  288. --- 43,49 ----
  289.   filter/filter.c
  290.   filter/lock.c
  291.   filter/parse.c
  292. + filter/regexp.c
  293.   filter/rules.c
  294.   filter/summarize.c
  295.   filter/utils.c
  296. ***************
  297. *** 59,64 ****
  298. --- 60,66 ----
  299.   hdrs/ndbz.h
  300.   hdrs/nl_types.h
  301.   hdrs/patchlevel.h
  302. + hdrs/regexp.h
  303.   hdrs/s_aliases.h
  304.   hdrs/s_answer.h
  305.   hdrs/s_arepdaem.h
  306.  
  307. Index: README
  308. *** ../elm2.4/README    Tue Nov 10 15:20:21 1992
  309. --- README    Sat Nov 14 20:06:38 1992
  310. ***************
  311. *** 2,8 ****
  312.   
  313.   See the NOTICE and Instruct files for further details.
  314.   
  315. ! It is IMPERITIVE that all users rerun newalias after installing
  316.   Elm 2.4 when upgrading from a previous version.  Elm's behavior
  317.   with aliases could be unpredictible if this step is not performed.
  318.   
  319. --- 2,8 ----
  320.   
  321.   See the NOTICE and Instruct files for further details.
  322.   
  323. ! It is IMPERATIVE that all users rerun newalias after installing
  324.   Elm 2.4 when upgrading from a previous version.  Elm's behavior
  325.   with aliases could be unpredictible if this step is not performed.
  326.   
  327.  
  328. Index: doc/Filter.guid
  329. Prereq: 5.1
  330. *** ../elm2.4/doc/Filter.guid    Sat Oct  3 16:54:23 1992
  331. --- doc/Filter.guid    Sat Nov 14 20:41:50 1992
  332. ***************
  333. *** 1,4 ****
  334. ! .\" @(#)$Id: Filter.guid,v 5.1 1992/10/03 20:51:50 syd Exp $
  335.   .\"
  336.   .\"  A guide to the Elm Filter program
  337.   .\"  format with:
  338. --- 1,4 ----
  339. ! .\" @(#)$Id: Filter.guid,v 5.2 1992/11/15 01:41:50 syd Exp $
  340.   .\"
  341.   .\"  A guide to the Elm Filter program
  342.   .\"  format with:
  343. ***************
  344. *** 12,17 ****
  345. --- 12,22 ----
  346.   .\"    Syd Weinstein        elm@DSI.COM (dsinc!elm)
  347.   .\"
  348.   .\"  $Log: Filter.guid,v $
  349. + .\" Revision 5.2  1992/11/15  01:41:50  syd
  350. + .\" Add regexp processing to filter.
  351. + .\" Add execc operator
  352. + .\" From: Jan Djarv <Jan.Djarv@sa.erisoft.se>
  353. + .\"
  354.   .\" Revision 5.1  1992/10/03  20:51:50  syd
  355.   .\" Initial checkin as of 2.4 Release at PL0
  356.   .\"
  357. ***************
  358. *** 145,150 ****
  359. --- 150,159 ----
  360.   The \f2value\f1 is any quoted string that is to be matched against
  361.   or number if ``lines'' is the field being considered.
  362.   .sp
  363. + The relation ``matches'' (or ``~'') takes an egrep like regular expression 
  364. + as the \f2value\f1. The regular expression must be enclosed in pairs of ``/''.
  365. + If you need a ``/'' in your expression write it as ``\\/''.
  366. + .sp
  367.   Individual conditions are joined together by using the word ``and'',
  368.   and the logic of a condition can be flipped by using ``not'' as the
  369.   first word (e.g. `not subject "joe"').  We'll see more examples of
  370. ***************
  371. *** 162,167 ****
  372. --- 171,177 ----
  373.   forward  \f2address\f1
  374.   forwardc  \f2address\f1
  375.   execute  \f2command\f1
  376. + executec  \f2command\f1
  377.   leave
  378.   .in 0
  379.   .fi
  380. ***************
  381. *** 172,190 ****
  382.   \f3forwardc\f1 sends the message to the specified address and leaves a copy in your mailbox; 
  383.   \f3execute\f1 feeds the message to the specified command (or complex
  384.   sequence of commands) as standard input;
  385.   and \f3leave\f1 leaves the message in your mailbox.
  386.   .sp
  387.   NOTE: The execute command assumes that you are doing something
  388.   useful with incoming mail.  The command does \f2not\f1
  389. ! automatically append the message to your mail spool.  A
  390. ! command such as:
  391.   .sp
  392. !  if (from = "dave") then echo mail from dave > /dev/tty
  393.   .sp
  394.   will result in \f2losing\f1 your mail.  A more suitable
  395.   use for execute would be:
  396.   .sp
  397. !  if (from = "boss") then vacation pat
  398.   .sp
  399.   Foldernames can contain any of a number of macros, too, as we'll see in
  400.   the example ruleset below.  The macros available for the string fields are;
  401. --- 182,201 ----
  402.   \f3forwardc\f1 sends the message to the specified address and leaves a copy in your mailbox; 
  403.   \f3execute\f1 feeds the message to the specified command (or complex
  404.   sequence of commands) as standard input;
  405. + \f3executec\f1 is like \f3execute\f1 but also leaves a copy in your mailbox;
  406.   and \f3leave\f1 leaves the message in your mailbox.
  407.   .sp
  408.   NOTE: The execute command assumes that you are doing something
  409.   useful with incoming mail.  The command does \f2not\f1
  410. ! automatically append the message to your mail spool.  Use executec for that.
  411. ! A command such as:
  412.   .sp
  413. !  if (from = "dave") then execute "echo mail from dave > /dev/tty"
  414.   .sp
  415.   will result in \f2losing\f1 your mail.  A more suitable
  416.   use for execute would be:
  417.   .sp
  418. !  if (from = "boss") then execute "vacation pat"
  419.   .sp
  420.   Foldernames can contain any of a number of macros, too, as we'll see in
  421.   the example ruleset below.  The macros available for the string fields are;
  422. ***************
  423. *** 208,216 ****
  424. --- 219,236 ----
  425.   .zf
  426.   %t    current hour and minute in HH:MM format
  427.   %y    year (last two digits)
  428. + %&    the string that matched the last regular expression
  429. + %1-%9    the i:th subexpression in the last regular expression that matched
  430.   .TE
  431.   .ft 1
  432.   .sp
  433. + If a message has a subject of \f2This is a test\f1, and the rule is
  434. + .sp
  435. + if (subject matches /([a-z]+) a ([a-z]+)/) then "echo %& %1 %2"
  436. + .sp
  437. + then %& expands to \f2is a test\f1, %1 expands to \f2is\f1 and %2 expands to
  438. + \f2test\f1.
  439. + .sp
  440.   Foldernames may contain a leading '~/' which will be expanded to be
  441.   your home directory.
  442.   .sp
  443. ***************
  444. *** 586,599 ****
  445.   .in .5i
  446.   
  447.   .ti -\n(TWu
  448. ! 1. The ability to use regular expressions in the patterns.  
  449. ! This would be a \f2very\f1 nice feature!
  450. ! .ti -\n(TWu
  451. ! 2. Perhaps more \f2actions\f1 available (but what?)
  452.   
  453.   .ti -\n(TWu
  454. ! 3. Certainly the ability to filter based on any field or combination of
  455.   fields.  
  456.   .in 0
  457.   .ne 5
  458. --- 606,615 ----
  459.   .in .5i
  460.   
  461.   .ti -\n(TWu
  462. ! 1. Perhaps more \f2actions\f1 available (but what?)
  463.   
  464.   .ti -\n(TWu
  465. ! 2. Certainly the ability to filter based on any field or combination of
  466.   fields.  
  467.   .in 0
  468.   .ne 5
  469.  
  470. Index: doc/filter.1
  471. *** ../elm2.4/doc/filter.1    Mon Oct 19 13:04:04 1992
  472. --- doc/filter.1    Sat Nov 14 20:48:08 1992
  473. ***************
  474. *** 58,63 ****
  475. --- 58,64 ----
  476.           \fBsave  \fIfoldername\fR
  477.           \fBsavecopy \fIfoldername\fR
  478.           \fBexecute  \fIcommand\fR
  479. +         \fBexecutec  \fIcommand\fR
  480.           \fBforward  \fIaddress\fR
  481.           \fBleave\fR
  482.   
  483.  
  484. Index: filter/regexp.c
  485. *** /dev/null    Mon Nov 16 22:43:59 1992
  486. --- filter/regexp.c    Mon Nov 16 23:10:02 1992
  487. ***************
  488. *** 0 ****
  489. --- 1,1214 ----
  490. + /* $Id: regexp.c,v 5.4 1992/11/17 18:25:42 syd Exp $ */
  491. + /*******************************************************************************
  492. +  *  The Elm Mail System  -  $Revision: 5.4 $   $State: Exp $
  493. +  *
  494. +  *             Copyright (c) 1992 USENET Community Trust
  495. +  *******************************************************************************
  496. +  * Bug reports, patches, comments, suggestions should be sent to:
  497. +  *
  498. +  *    Syd Weinstein, Elm Coordinator
  499. +  *    elm@DSI.COM            dsinc!elm
  500. +  *
  501. +  *******************************************************************************
  502. +  * $Log: regexp.c,v $
  503. +  * Revision 5.4  1992/11/17  18:25:42  syd
  504. +  * change to use index instead of strchr
  505. +  * From: Syd
  506. +  *
  507. +  * Revision 5.3  1992/11/17  04:10:01  syd
  508. +  * The changes to filter/regexp.c are to correct compiler warnings about
  509. +  * unreachable statements.
  510. +  *
  511. +  * The changes to filter/rules.c are to correct the fact that we are passing
  512. +  * a pointer to a condition_rec structore to a function expecting a pointer to
  513. +  * a character string.
  514. +  * From: Tom Moore <tmoore@fievel.DaytonOH.NCR.COM>
  515. +  *
  516. +  * Revision 5.2  1992/11/15  01:39:31  syd
  517. +  * add proper headers
  518. +  *
  519. +  *
  520. +  ******************************************************************************/
  521. + /*
  522. +  * regcomp and regexec -- regsub and regerror are elsewhere
  523. +  *
  524. +  *    Copyright (c) 1986 by University of Toronto.
  525. +  *    Written by Henry Spencer.  Not derived from licensed software.
  526. +  *
  527. +  *    Permission is granted to anyone to use this software for any
  528. +  *    purpose on any computer system, and to redistribute it freely,
  529. +  *    subject to the following restrictions:
  530. +  *
  531. +  *    1. The author is not responsible for the consequences of use of
  532. +  *        this software, no matter how awful, even if they arise
  533. +  *        from defects in it.
  534. +  *
  535. +  *    2. The origin of this software must not be misrepresented, either
  536. +  *        by explicit claim or by omission.
  537. +  *
  538. +  *    3. Altered versions must be plainly marked as such, and must not
  539. +  *        be misrepresented as being the original software.
  540. +  *
  541. +  * Beware that some of this code is subtly aware of the way operator
  542. +  * precedence is structured in regular expressions.  Serious changes in
  543. +  * regular-expression syntax might require a total rethink.
  544. +  */
  545. + /*
  546. +  * Altered by Jan D. (Jan.Djarv@sa.erisoft.se) for use in elm:s filter
  547. +  */
  548. + #include "defs.h"
  549. + #include "regexp.h"
  550. + #include <stdio.h>
  551. + /* #include "regmagic.h" -- Inlined here (next 5 lines) */
  552. + /*
  553. +  * The first byte of the regexp internal "program" is actually this magic
  554. +  * number; the start node begins in the second byte.
  555. +  */
  556. + #define    MAGIC    0234
  557. + /*
  558. +  * The "internal use only" fields in regexp.h are present to pass info from
  559. +  * compile to execute that permits the execute phase to run lots faster on
  560. +  * simple cases.  They are:
  561. +  *
  562. +  * regstart    char that must begin a match; '\0' if none obvious
  563. +  * reganch    is the match anchored (at beginning-of-line only)?
  564. +  * regmust    string (pointer into program) that match must include, or NULL
  565. +  * regmlen    length of regmust string
  566. +  *
  567. +  * Regstart and reganch permit very fast decisions on suitable starting points
  568. +  * for a match, cutting down the work a lot.  Regmust permits fast rejection
  569. +  * of lines that cannot possibly match.  The regmust tests are costly enough
  570. +  * that regcomp() supplies a regmust only if the r.e. contains something
  571. +  * potentially expensive (at present, the only such thing detected is * or +
  572. +  * at the start of the r.e., which can involve a lot of backup).  Regmlen is
  573. +  * supplied because the test in regexec() needs it and regcomp() is computing
  574. +  * it anyway.
  575. +  */
  576. + /*
  577. +  * Structure for regexp "program".  This is essentially a linear encoding
  578. +  * of a nondeterministic finite-state machine (aka syntax charts or
  579. +  * "railroad normal form" in parsing technology).  Each node is an opcode
  580. +  * plus a "next" pointer, possibly plus an operand.  "Next" pointers of
  581. +  * all nodes except BRANCH implement concatenation; a "next" pointer with
  582. +  * a BRANCH on both ends of it is connecting two alternatives.  (Here we
  583. +  * have one of the subtle syntax dependencies:  an individual BRANCH (as
  584. +  * opposed to a collection of them) is never concatenated with anything
  585. +  * because of operator precedence.)  The operand of some types of node is
  586. +  * a literal string; for others, it is a node leading into a sub-FSM.  In
  587. +  * particular, the operand of a BRANCH node is the first node of the branch.
  588. +  * (NB this is *not* a tree structure:  the tail of the branch connects
  589. +  * to the thing following the set of BRANCHes.)  The opcodes are:
  590. +  */
  591. + /* definition    number    opnd?    meaning */
  592. + #define    END    0    /* no    End of program. */
  593. + #define    BOL    1    /* no    Match "" at beginning of line. */
  594. + #define    EOL    2    /* no    Match "" at end of line. */
  595. + #define    ANY    3    /* no    Match any one character. */
  596. + #define    ANYOF    4    /* str    Match any character in this string. */
  597. + #define    ANYBUT    5    /* str    Match any character not in this string. */
  598. + #define    BRANCH    6    /* node    Match this alternative, or the next... */
  599. + #define    BACK    7    /* no    Match "", "next" ptr points backward. */
  600. + #define    EXACTLY    8    /* str    Match this string. */
  601. + #define    NOTHING    9    /* no    Match empty string. */
  602. + #define    STAR    10    /* node    Match this (simple) thing 0 or more times. */
  603. + #define    PLUS    11    /* node    Match this (simple) thing 1 or more times. */
  604. + #define    OPEN    20    /* no    Mark this point in input as start of #n. */
  605. +             /*    OPEN+1 is number 1, etc. */
  606. + #define    CLOSE    30    /* no    Analogous to OPEN. */
  607. + /*
  608. +  * Opcode notes:
  609. +  *
  610. +  * BRANCH    The set of branches constituting a single choice are hooked
  611. +  *        together with their "next" pointers, since precedence prevents
  612. +  *        anything being concatenated to any individual branch.  The
  613. +  *        "next" pointer of the last BRANCH in a choice points to the
  614. +  *        thing following the whole choice.  This is also where the
  615. +  *        final "next" pointer of each individual branch points; each
  616. +  *        branch starts with the operand node of a BRANCH node.
  617. +  *
  618. +  * BACK        Normal "next" pointers all implicitly point forward; BACK
  619. +  *        exists to make loop structures possible.
  620. +  *
  621. +  * STAR,PLUS    '?', and complex '*' and '+', are implemented as circular
  622. +  *        BRANCH structures using BACK.  Simple cases (one character
  623. +  *        per match) are implemented with STAR and PLUS for speed
  624. +  *        and to minimize recursive plunges.
  625. +  *
  626. +  * OPEN,CLOSE    ...are numbered at compile time.
  627. +  */
  628. + /*
  629. +  * A node is one char of opcode followed by two chars of "next" pointer.
  630. +  * "Next" pointers are stored as two 8-bit pieces, high order first.  The
  631. +  * value is a positive offset from the opcode of the node containing it.
  632. +  * An operand, if any, simply follows the node.  (Note that much of the
  633. +  * code generation knows about this implicit relationship.)
  634. +  *
  635. +  * Using two bytes for the "next" pointer is vast overkill for most things,
  636. +  * but allows patterns to get big without disasters.
  637. +  */
  638. + #define    OP(p)    (*(p))
  639. + #define    NEXT(p)    (((*((p)+1)&0377)<<8) + (*((p)+2)&0377))
  640. + #define    OPERAND(p)    ((p) + 3)
  641. + /*
  642. +  * See regmagic.h for one further detail of program structure.
  643. +  */
  644. + /*
  645. +  * Utility definitions.
  646. +  */
  647. + #ifndef CHARBITS
  648. + #define    UCHARAT(p)    ((int)*(unsigned char *)(p))
  649. + #else
  650. + #define    UCHARAT(p)    ((int)*(p)&CHARBITS)
  651. + #endif
  652. + #define    FAIL(m)    { regerror(m); return(NULL); }
  653. + #define    ISMULT(c)    ((c) == '*' || (c) == '+' || (c) == '?')
  654. + #define    META    "^$.[()|?+*\\"
  655. + /*
  656. +  * Flags to be passed up and down.
  657. +  */
  658. + #define    HASWIDTH    01    /* Known never to match null string. */
  659. + #define    SIMPLE        02    /* Simple enough to be STAR/PLUS operand. */
  660. + #define    SPSTART        04    /* Starts with * or +. */
  661. + #define    WORST        0    /* Worst case. */
  662. + /*
  663. +  * Global work variables for regcomp().
  664. +  */
  665. + static char *regparse;        /* Input-scan pointer. */
  666. + static int regnpar;        /* () count. */
  667. + static char regdummy;
  668. + static char *regcode;        /* Code-emit pointer; ®dummy = don't. */
  669. + static long regsize;        /* Code size. */
  670. + /*
  671. +  * Forward declarations for regcomp()'s friends.
  672. +  */
  673. + #ifndef STATIC
  674. + #define    STATIC    static
  675. + #endif
  676. + STATIC char *reg();
  677. + STATIC char *regbranch();
  678. + STATIC char *regpiece();
  679. + STATIC char *regatom();
  680. + STATIC char *regnode();
  681. + STATIC char *regnext();
  682. + STATIC void regc();
  683. + STATIC void reginsert();
  684. + STATIC void regtail();
  685. + STATIC void regoptail();
  686. + /*
  687. +  - regcomp - compile a regular expression into internal code
  688. +  *
  689. +  * We can't allocate space until we know how big the compiled form will be,
  690. +  * but we can't compile it (and thus know how big it is) until we've got a
  691. +  * place to put the code.  So we cheat:  we compile it twice, once with code
  692. +  * generation turned off and size counting turned on, and once "for real".
  693. +  * This also means that we don't allocate space until we are sure that the
  694. +  * thing really will compile successfully, and we never have to move the
  695. +  * code and thus invalidate pointers into it.  (Note that it has to be in
  696. +  * one piece because free() must be able to free it all.)
  697. +  *
  698. +  * Beware that the optimization-preparation code in here knows about some
  699. +  * of the structure of the compiled regexp.
  700. +  */
  701. + regexp *
  702. + regcomp(exp)
  703. + char *exp;
  704. + {
  705. +     register regexp *r;
  706. +     register char *scan;
  707. +     register char *longest;
  708. +     register int len;
  709. +     int flags;
  710. +     if (exp == NULL)
  711. +         FAIL("NULL argument");
  712. +     /* First pass: determine size, legality. */
  713. +     regparse = exp;
  714. +     regnpar = 1;
  715. +     regsize = 0L;
  716. +     regcode = ®dummy;
  717. +     regc(MAGIC);
  718. +     if (reg(0, &flags) == NULL)
  719. +         return(NULL);
  720. +     /* Small enough for pointer-storage convention? */
  721. +     if (regsize >= 32767L)        /* Probably could be 65535L. */
  722. +         FAIL("regexp too big");
  723. +     /* Allocate space. */
  724. +     r = (regexp *)malloc(sizeof(regexp) + (unsigned)regsize);
  725. +     if (r == NULL)
  726. +         FAIL("out of space");
  727. +     /* Second pass: emit code. */
  728. +     regparse = exp;
  729. +     regnpar = 1;
  730. +     regcode = r->program;
  731. +     regc(MAGIC);
  732. +     if (reg(0, &flags) == NULL)
  733. +         return(NULL);
  734. +     /* Dig out information for optimizations. */
  735. +     r->regstart = '\0';    /* Worst-case defaults. */
  736. +     r->reganch = 0;
  737. +     r->regmust = NULL;
  738. +     r->regmlen = 0;
  739. +     scan = r->program+1;            /* First BRANCH. */
  740. +     if (OP(regnext(scan)) == END) {        /* Only one top-level choice. */
  741. +         scan = OPERAND(scan);
  742. +         /* Starting-point info. */
  743. +         if (OP(scan) == EXACTLY)
  744. +             r->regstart = *OPERAND(scan);
  745. +         else if (OP(scan) == BOL)
  746. +             r->reganch++;
  747. +         /*
  748. +          * If there's something expensive in the r.e., find the
  749. +          * longest literal string that must appear and make it the
  750. +          * regmust.  Resolve ties in favor of later strings, since
  751. +          * the regstart check works with the beginning of the r.e.
  752. +          * and avoiding duplication strengthens checking.  Not a
  753. +          * strong reason, but sufficient in the absence of others.
  754. +          */
  755. +         if (flags&SPSTART) {
  756. +             longest = NULL;
  757. +             len = 0;
  758. +             for (; scan != NULL; scan = regnext(scan))
  759. +                 if (OP(scan) == EXACTLY && strlen(OPERAND(scan)) >= len) {
  760. +                     longest = OPERAND(scan);
  761. +                     len = strlen(OPERAND(scan));
  762. +                 }
  763. +             r->regmust = longest;
  764. +             r->regmlen = len;
  765. +         }
  766. +     }
  767. +     return(r);
  768. + }
  769. + /*
  770. +  - reg - regular expression, i.e. main body or parenthesized thing
  771. +  *
  772. +  * Caller must absorb opening parenthesis.
  773. +  *
  774. +  * Combining parenthesis handling with the base level of regular expression
  775. +  * is a trifle forced, but the need to tie the tails of the branches to what
  776. +  * follows makes it hard to avoid.
  777. +  */
  778. + static char *
  779. + reg(paren, flagp)
  780. + int paren;            /* Parenthesized? */
  781. + int *flagp;
  782. + {
  783. +     register char *ret;
  784. +     register char *br;
  785. +     register char *ender;
  786. +     register int parno;
  787. +     int flags;
  788. +     *flagp = HASWIDTH;    /* Tentatively. */
  789. +     /* Make an OPEN node, if parenthesized. */
  790. +     if (paren) {
  791. +         if (regnpar >= NSUBEXP)
  792. +             FAIL("too many ()");
  793. +         parno = regnpar;
  794. +         regnpar++;
  795. +         ret = regnode(OPEN+parno);
  796. +     } else
  797. +         ret = NULL;
  798. +     /* Pick up the branches, linking them together. */
  799. +     br = regbranch(&flags);
  800. +     if (br == NULL)
  801. +         return(NULL);
  802. +     if (ret != NULL)
  803. +         regtail(ret, br);    /* OPEN -> first. */
  804. +     else
  805. +         ret = br;
  806. +     if (!(flags&HASWIDTH))
  807. +         *flagp &= ~HASWIDTH;
  808. +     *flagp |= flags&SPSTART;
  809. +     while (*regparse == '|') {
  810. +         regparse++;
  811. +         br = regbranch(&flags);
  812. +         if (br == NULL)
  813. +             return(NULL);
  814. +         regtail(ret, br);    /* BRANCH -> BRANCH. */
  815. +         if (!(flags&HASWIDTH))
  816. +             *flagp &= ~HASWIDTH;
  817. +         *flagp |= flags&SPSTART;
  818. +     }
  819. +     /* Make a closing node, and hook it on the end. */
  820. +     ender = regnode((paren) ? CLOSE+parno : END);    
  821. +     regtail(ret, ender);
  822. +     /* Hook the tails of the branches to the closing node. */
  823. +     for (br = ret; br != NULL; br = regnext(br))
  824. +         regoptail(br, ender);
  825. +     /* Check for proper termination. */
  826. +     if (paren && *regparse++ != ')') {
  827. +         FAIL("unmatched ()");
  828. +     } else if (!paren && *regparse != '\0') {
  829. +         if (*regparse == ')') {
  830. +             FAIL("unmatched ()");
  831. +         } else
  832. +             FAIL("junk on end");    /* "Can't happen". */
  833. +         /* NOTREACHED */
  834. +     }
  835. +     return(ret);
  836. + }
  837. + /*
  838. +  - regbranch - one alternative of an | operator
  839. +  *
  840. +  * Implements the concatenation operator.
  841. +  */
  842. + static char *
  843. + regbranch(flagp)
  844. + int *flagp;
  845. + {
  846. +     register char *ret;
  847. +     register char *chain;
  848. +     register char *latest;
  849. +     int flags;
  850. +     *flagp = WORST;        /* Tentatively. */
  851. +     ret = regnode(BRANCH);
  852. +     chain = NULL;
  853. +     while (*regparse != '\0' && *regparse != '|' && *regparse != ')') {
  854. +         latest = regpiece(&flags);
  855. +         if (latest == NULL)
  856. +             return(NULL);
  857. +         *flagp |= flags&HASWIDTH;
  858. +         if (chain == NULL)    /* First piece. */
  859. +             *flagp |= flags&SPSTART;
  860. +         else
  861. +             regtail(chain, latest);
  862. +         chain = latest;
  863. +     }
  864. +     if (chain == NULL)    /* Loop ran zero times. */
  865. +         (void) regnode(NOTHING);
  866. +     return(ret);
  867. + }
  868. + /*
  869. +  - regpiece - something followed by possible [*+?]
  870. +  *
  871. +  * Note that the branching code sequences used for ? and the general cases
  872. +  * of * and + are somewhat optimized:  they use the same NOTHING node as
  873. +  * both the endmarker for their branch list and the body of the last branch.
  874. +  * It might seem that this node could be dispensed with entirely, but the
  875. +  * endmarker role is not redundant.
  876. +  */
  877. + static char *
  878. + regpiece(flagp)
  879. + int *flagp;
  880. + {
  881. +     register char *ret;
  882. +     register char op;
  883. +     register char *next;
  884. +     int flags;
  885. +     ret = regatom(&flags);
  886. +     if (ret == NULL)
  887. +         return(NULL);
  888. +     op = *regparse;
  889. +     if (!ISMULT(op)) {
  890. +         *flagp = flags;
  891. +         return(ret);
  892. +     }
  893. +     if (!(flags&HASWIDTH) && op != '?')
  894. +         FAIL("*+ operand could be empty");
  895. +     *flagp = (op != '+') ? (WORST|SPSTART) : (WORST|HASWIDTH);
  896. +     if (op == '*' && (flags&SIMPLE))
  897. +         reginsert(STAR, ret);
  898. +     else if (op == '*') {
  899. +         /* Emit x* as (x&|), where & means "self". */
  900. +         reginsert(BRANCH, ret);            /* Either x */
  901. +         regoptail(ret, regnode(BACK));        /* and loop */
  902. +         regoptail(ret, ret);            /* back */
  903. +         regtail(ret, regnode(BRANCH));        /* or */
  904. +         regtail(ret, regnode(NOTHING));        /* null. */
  905. +     } else if (op == '+' && (flags&SIMPLE))
  906. +         reginsert(PLUS, ret);
  907. +     else if (op == '+') {
  908. +         /* Emit x+ as x(&|), where & means "self". */
  909. +         next = regnode(BRANCH);            /* Either */
  910. +         regtail(ret, next);
  911. +         regtail(regnode(BACK), ret);        /* loop back */
  912. +         regtail(next, regnode(BRANCH));        /* or */
  913. +         regtail(ret, regnode(NOTHING));        /* null. */
  914. +     } else if (op == '?') {
  915. +         /* Emit x? as (x|) */
  916. +         reginsert(BRANCH, ret);            /* Either x */
  917. +         regtail(ret, regnode(BRANCH));        /* or */
  918. +         next = regnode(NOTHING);        /* null. */
  919. +         regtail(ret, next);
  920. +         regoptail(ret, next);
  921. +     }
  922. +     regparse++;
  923. +     if (ISMULT(*regparse))
  924. +         FAIL("nested *?+");
  925. +     return(ret);
  926. + }
  927. + /*
  928. +  - regatom - the lowest level
  929. +  *
  930. +  * Optimization:  gobbles an entire sequence of ordinary characters so that
  931. +  * it can turn them into a single node, which is smaller to store and
  932. +  * faster to run.  Backslashed characters are exceptions, each becoming a
  933. +  * separate node; the code is simpler that way and it's not worth fixing.
  934. +  */
  935. + static char *
  936. + regatom(flagp)
  937. + int *flagp;
  938. + {
  939. +     register char *ret;
  940. +     int flags;
  941. +     *flagp = WORST;        /* Tentatively. */
  942. +     switch (*regparse++) {
  943. +     case '^':
  944. +         ret = regnode(BOL);
  945. +         break;
  946. +     case '$':
  947. +         ret = regnode(EOL);
  948. +         break;
  949. +     case '.':
  950. +         ret = regnode(ANY);
  951. +         *flagp |= HASWIDTH|SIMPLE;
  952. +         break;
  953. +     case '[': {
  954. +             register int class;
  955. +             register int classend;
  956. +             if (*regparse == '^') {    /* Complement of range. */
  957. +                 ret = regnode(ANYBUT);
  958. +                 regparse++;
  959. +             } else
  960. +                 ret = regnode(ANYOF);
  961. +             if (*regparse == ']' || *regparse == '-')
  962. +                 regc(*regparse++);
  963. +             while (*regparse != '\0' && *regparse != ']') {
  964. +                 if (*regparse == '-') {
  965. +                     regparse++;
  966. +                     if (*regparse == ']' || *regparse == '\0')
  967. +                         regc('-');
  968. +                     else {
  969. +                         class = UCHARAT(regparse-2)+1;
  970. +                         classend = UCHARAT(regparse);
  971. +                         if (class > classend+1)
  972. +                             FAIL("invalid [] range");
  973. +                         for (; class <= classend; class++)
  974. +                             regc(class);
  975. +                         regparse++;
  976. +                     }
  977. +                 } else
  978. +                     regc(*regparse++);
  979. +             }
  980. +             regc('\0');
  981. +             if (*regparse != ']')
  982. +                 FAIL("unmatched []");
  983. +             regparse++;
  984. +             *flagp |= HASWIDTH|SIMPLE;
  985. +         }
  986. +         break;
  987. +     case '(':
  988. +         ret = reg(1, &flags);
  989. +         if (ret == NULL)
  990. +             return(NULL);
  991. +         *flagp |= flags&(HASWIDTH|SPSTART);
  992. +         break;
  993. +     case '\0':
  994. +     case '|':
  995. +     case ')':
  996. +         FAIL("internal urp");    /* Supposed to be caught earlier. */
  997. +     case '?':
  998. +     case '+':
  999. +     case '*':
  1000. +         FAIL("?+* follows nothing");
  1001. +     case '\\':
  1002. +         if (*regparse == '\0')
  1003. +             FAIL("trailing \\");
  1004. +         ret = regnode(EXACTLY);
  1005. +         regc(*regparse++);
  1006. +         regc('\0');
  1007. +         *flagp |= HASWIDTH|SIMPLE;
  1008. +         break;
  1009. +     default: {
  1010. +             register int len;
  1011. +             register char ender;
  1012. +             regparse--;
  1013. +             len = strcspn(regparse, META);
  1014. +             if (len <= 0)
  1015. +                 FAIL("internal disaster");
  1016. +             ender = *(regparse+len);
  1017. +             if (len > 1 && ISMULT(ender))
  1018. +                 len--;        /* Back off clear of ?+* operand. */
  1019. +             *flagp |= HASWIDTH;
  1020. +             if (len == 1)
  1021. +                 *flagp |= SIMPLE;
  1022. +             ret = regnode(EXACTLY);
  1023. +             while (len > 0) {
  1024. +                 regc(*regparse++);
  1025. +                 len--;
  1026. +             }
  1027. +             regc('\0');
  1028. +         }
  1029. +         break;
  1030. +     }
  1031. +     return(ret);
  1032. + }
  1033. + /*
  1034. +  - regnode - emit a node
  1035. +  */
  1036. + static char *            /* Location. */
  1037. + regnode(op)
  1038. + char op;
  1039. + {
  1040. +     register char *ret;
  1041. +     register char *ptr;
  1042. +     ret = regcode;
  1043. +     if (ret == ®dummy) {
  1044. +         regsize += 3;
  1045. +         return(ret);
  1046. +     }
  1047. +     ptr = ret;
  1048. +     *ptr++ = op;
  1049. +     *ptr++ = '\0';        /* Null "next" pointer. */
  1050. +     *ptr++ = '\0';
  1051. +     regcode = ptr;
  1052. +     return(ret);
  1053. + }
  1054. + /*
  1055. +  - regc - emit (if appropriate) a byte of code
  1056. +  */
  1057. + static void
  1058. + regc(b)
  1059. + char b;
  1060. + {
  1061. +     if (regcode != ®dummy)
  1062. +         *regcode++ = b;
  1063. +     else
  1064. +         regsize++;
  1065. + }
  1066. + /*
  1067. +  - reginsert - insert an operator in front of already-emitted operand
  1068. +  *
  1069. +  * Means relocating the operand.
  1070. +  */
  1071. + static void
  1072. + reginsert(op, opnd)
  1073. + char op;
  1074. + char *opnd;
  1075. + {
  1076. +     register char *src;
  1077. +     register char *dst;
  1078. +     register char *place;
  1079. +     if (regcode == ®dummy) {
  1080. +         regsize += 3;
  1081. +         return;
  1082. +     }
  1083. +     src = regcode;
  1084. +     regcode += 3;
  1085. +     dst = regcode;
  1086. +     while (src > opnd)
  1087. +         *--dst = *--src;
  1088. +     place = opnd;        /* Op node, where operand used to be. */
  1089. +     *place++ = op;
  1090. +     *place++ = '\0';
  1091. +     *place++ = '\0';
  1092. + }
  1093. + /*
  1094. +  - regtail - set the next-pointer at the end of a node chain
  1095. +  */
  1096. + static void
  1097. + regtail(p, val)
  1098. + char *p;
  1099. + char *val;
  1100. + {
  1101. +     register char *scan;
  1102. +     register char *temp;
  1103. +     register int offset;
  1104. +     if (p == ®dummy)
  1105. +         return;
  1106. +     /* Find last node. */
  1107. +     scan = p;
  1108. +     for (;;) {
  1109. +         temp = regnext(scan);
  1110. +         if (temp == NULL)
  1111. +             break;
  1112. +         scan = temp;
  1113. +     }
  1114. +     if (OP(scan) == BACK)
  1115. +         offset = scan - val;
  1116. +     else
  1117. +         offset = val - scan;
  1118. +     *(scan+1) = (offset>>8)&0377;
  1119. +     *(scan+2) = offset&0377;
  1120. + }
  1121. + /*
  1122. +  - regoptail - regtail on operand of first argument; nop if operandless
  1123. +  */
  1124. + static void
  1125. + regoptail(p, val)
  1126. + char *p;
  1127. + char *val;
  1128. + {
  1129. +     /* "Operandless" and "op != BRANCH" are synonymous in practice. */
  1130. +     if (p == NULL || p == ®dummy || OP(p) != BRANCH)
  1131. +         return;
  1132. +     regtail(OPERAND(p), val);
  1133. + }
  1134. + /*
  1135. +  * regexec and friends
  1136. +  */
  1137. + /*
  1138. +  * Global work variables for regexec().
  1139. +  */
  1140. + static char *reginput;        /* String-input pointer. */
  1141. + static char *regbol;        /* Beginning of input, for ^ check. */
  1142. + static char **regstartp;    /* Pointer to startp array. */
  1143. + static char **regendp;        /* Ditto for endp. */
  1144. + /*
  1145. +  * Forwards.
  1146. +  */
  1147. + STATIC int regtry();
  1148. + STATIC int regmatch();
  1149. + STATIC int regrepeat();
  1150. + #ifdef DEBUG
  1151. + int regnarrate = 0;
  1152. + void regdump();
  1153. + STATIC char *regprop();
  1154. + #endif
  1155. + /*
  1156. +  - regexec - match a regexp against a string
  1157. +  */
  1158. + int
  1159. + regexec(prog, string)
  1160. + register regexp *prog;
  1161. + register char *string;
  1162. + {
  1163. +     register char *s;
  1164. +     /* Be paranoid... */
  1165. +     if (prog == NULL || string == NULL) {
  1166. +         regerror("NULL parameter");
  1167. +         return(0);
  1168. +     }
  1169. +     /* Check validity of program. */
  1170. +     if (UCHARAT(prog->program) != MAGIC) {
  1171. +         regerror("corrupted program");
  1172. +         return(0);
  1173. +     }
  1174. +     /* If there is a "must appear" string, look for it. */
  1175. +     if (prog->regmust != NULL) {
  1176. +         s = string;
  1177. +         while ((s = index(s, prog->regmust[0])) != NULL) {
  1178. +             if (strncmp(s, prog->regmust, prog->regmlen) == 0)
  1179. +                 break;    /* Found it. */
  1180. +             s++;
  1181. +         }
  1182. +         if (s == NULL)    /* Not present. */
  1183. +             return(0);
  1184. +     }
  1185. +     /* Mark beginning of line for ^ . */
  1186. +     regbol = string;
  1187. +     /* Simplest case:  anchored match need be tried only once. */
  1188. +     if (prog->reganch)
  1189. +         return(regtry(prog, string));
  1190. +     /* Messy cases:  unanchored match. */
  1191. +     s = string;
  1192. +     if (prog->regstart != '\0')
  1193. +         /* We know what char it must start with. */
  1194. +         while ((s = index(s, prog->regstart)) != NULL) {
  1195. +             if (regtry(prog, s))
  1196. +                 return(1);
  1197. +             s++;
  1198. +         }
  1199. +     else
  1200. +         /* We don't -- general case. */
  1201. +         do {
  1202. +             if (regtry(prog, s))
  1203. +                 return(1);
  1204. +         } while (*s++ != '\0');
  1205. +     /* Failure. */
  1206. +     return(0);
  1207. + }
  1208. + /*
  1209. +  - regtry - try match at specific point
  1210. +  */
  1211. + static int            /* 0 failure, 1 success */
  1212. + regtry(prog, string)
  1213. + regexp *prog;
  1214. + char *string;
  1215. + {
  1216. +     register int i;
  1217. +     register char **sp;
  1218. +     register char **ep;
  1219. +     reginput = string;
  1220. +     regstartp = prog->startp;
  1221. +     regendp = prog->endp;
  1222. +     sp = prog->startp;
  1223. +     ep = prog->endp;
  1224. +     for (i = NSUBEXP; i > 0; i--) {
  1225. +         *sp++ = NULL;
  1226. +         *ep++ = NULL;
  1227. +     }
  1228. +     if (regmatch(prog->program + 1)) {
  1229. +         prog->startp[0] = string;
  1230. +         prog->endp[0] = reginput;
  1231. +         return(1);
  1232. +     } else
  1233. +         return(0);
  1234. + }
  1235. + /*
  1236. +  - regmatch - main matching routine
  1237. +  *
  1238. +  * Conceptually the strategy is simple:  check to see whether the current
  1239. +  * node matches, call self recursively to see whether the rest matches,
  1240. +  * and then act accordingly.  In practice we make some effort to avoid
  1241. +  * recursion, in particular by going through "ordinary" nodes (that don't
  1242. +  * need to know whether the rest of the match failed) by a loop instead of
  1243. +  * by recursion.
  1244. +  */
  1245. + static int            /* 0 failure, 1 success */
  1246. + regmatch(prog)
  1247. + char *prog;
  1248. + {
  1249. +     register char *scan;    /* Current node. */
  1250. +     char *next;        /* Next node. */
  1251. +     scan = prog;
  1252. + #ifdef DEBUG
  1253. +     if (scan != NULL && regnarrate)
  1254. +         fprintf(stderr, "%s(\n", regprop(scan));
  1255. + #endif
  1256. +     while (scan != NULL) {
  1257. + #ifdef DEBUG
  1258. +         if (regnarrate)
  1259. +             fprintf(stderr, "%s...\n", regprop(scan));
  1260. + #endif
  1261. +         next = regnext(scan);
  1262. +         switch (OP(scan)) {
  1263. +         case BOL:
  1264. +             if (reginput != regbol)
  1265. +                 return(0);
  1266. +             break;
  1267. +         case EOL:
  1268. +             if (*reginput != '\0')
  1269. +                 return(0);
  1270. +             break;
  1271. +         case ANY:
  1272. +             if (*reginput == '\0')
  1273. +                 return(0);
  1274. +             reginput++;
  1275. +             break;
  1276. +         case EXACTLY: {
  1277. +                 register int len;
  1278. +                 register char *opnd;
  1279. +                 opnd = OPERAND(scan);
  1280. +                 /* Inline the first character, for speed. */
  1281. +                 if (*opnd != *reginput)
  1282. +                     return(0);
  1283. +                 len = strlen(opnd);
  1284. +                 if (len > 1 && strncmp(opnd, reginput, len) != 0)
  1285. +                     return(0);
  1286. +                 reginput += len;
  1287. +             }
  1288. +             break;
  1289. +         case ANYOF:
  1290. +              if (*reginput == '\0' || index(OPERAND(scan), *reginput) == NULL)
  1291. +                 return(0);
  1292. +             reginput++;
  1293. +             break;
  1294. +         case ANYBUT:
  1295. +              if (*reginput == '\0' || index(OPERAND(scan), *reginput) != NULL)
  1296. +                 return(0);
  1297. +             reginput++;
  1298. +             break;
  1299. +         case NOTHING:
  1300. +             break;
  1301. +         case BACK:
  1302. +             break;
  1303. +         case OPEN+1:
  1304. +         case OPEN+2:
  1305. +         case OPEN+3:
  1306. +         case OPEN+4:
  1307. +         case OPEN+5:
  1308. +         case OPEN+6:
  1309. +         case OPEN+7:
  1310. +         case OPEN+8:
  1311. +         case OPEN+9: {
  1312. +                 register int no;
  1313. +                 register char *save;
  1314. +                 no = OP(scan) - OPEN;
  1315. +                 save = reginput;
  1316. +                 if (regmatch(next)) {
  1317. +                     /*
  1318. +                      * Don't set startp if some later
  1319. +                      * invocation of the same parentheses
  1320. +                      * already has.
  1321. +                      */
  1322. +                     if (regstartp[no] == NULL)
  1323. +                         regstartp[no] = save;
  1324. +                     return(1);
  1325. +                 } else
  1326. +                     return(0);
  1327. +             }
  1328. +             break;
  1329. +         case CLOSE+1:
  1330. +         case CLOSE+2:
  1331. +         case CLOSE+3:
  1332. +         case CLOSE+4:
  1333. +         case CLOSE+5:
  1334. +         case CLOSE+6:
  1335. +         case CLOSE+7:
  1336. +         case CLOSE+8:
  1337. +         case CLOSE+9: {
  1338. +                 register int no;
  1339. +                 register char *save;
  1340. +                 no = OP(scan) - CLOSE;
  1341. +                 save = reginput;
  1342. +                 if (regmatch(next)) {
  1343. +                     /*
  1344. +                      * Don't set endp if some later
  1345. +                      * invocation of the same parentheses
  1346. +                      * already has.
  1347. +                      */
  1348. +                     if (regendp[no] == NULL)
  1349. +                         regendp[no] = save;
  1350. +                     return(1);
  1351. +                 } else
  1352. +                     return(0);
  1353. +             }
  1354. +             break;
  1355. +         case BRANCH: {
  1356. +                 register char *save;
  1357. +                 if (OP(next) != BRANCH)        /* No choice. */
  1358. +                     next = OPERAND(scan);    /* Avoid recursion. */
  1359. +                 else {
  1360. +                     do {
  1361. +                         save = reginput;
  1362. +                         if (regmatch(OPERAND(scan)))
  1363. +                             return(1);
  1364. +                         reginput = save;
  1365. +                         scan = regnext(scan);
  1366. +                     } while (scan != NULL && OP(scan) == BRANCH);
  1367. +                     return(0);
  1368. +                     /* NOTREACHED */
  1369. +                 }
  1370. +             }
  1371. +             break;
  1372. +         case STAR:
  1373. +         case PLUS: {
  1374. +                 register char nextch;
  1375. +                 register int no;
  1376. +                 register char *save;
  1377. +                 register int mmin;
  1378. +                 /*
  1379. +                  * Lookahead to avoid useless match attempts
  1380. +                  * when we know what character comes next.
  1381. +                  */
  1382. +                 nextch = '\0';
  1383. +                 if (OP(next) == EXACTLY)
  1384. +                     nextch = *OPERAND(next);
  1385. +                 mmin = (OP(scan) == STAR) ? 0 : 1;
  1386. +                 save = reginput;
  1387. +                 no = regrepeat(OPERAND(scan));
  1388. +                 while (no >= mmin) {
  1389. +                     /* If it could work, try it. */
  1390. +                     if (nextch == '\0' || *reginput == nextch)
  1391. +                         if (regmatch(next))
  1392. +                             return(1);
  1393. +                     /* Couldn't or didn't -- back up. */
  1394. +                     no--;
  1395. +                     reginput = save + no;
  1396. +                 }
  1397. +                 return(0);
  1398. +             }
  1399. +         case END:
  1400. +             return(1);    /* Success! */
  1401. +         default:
  1402. +             regerror("memory corruption");
  1403. +             return(0);
  1404. +         }
  1405. +         scan = next;
  1406. +     }
  1407. +     /*
  1408. +      * We get here only if there's trouble -- normally "case END" is
  1409. +      * the terminating point.
  1410. +      */
  1411. +     regerror("corrupted pointers");
  1412. +     return(0);
  1413. + }
  1414. + /*
  1415. +  - regrepeat - repeatedly match something simple, report how many
  1416. +  */
  1417. + static int
  1418. + regrepeat(p)
  1419. + char *p;
  1420. + {
  1421. +     register int count = 0;
  1422. +     register char *scan;
  1423. +     register char *opnd;
  1424. +     scan = reginput;
  1425. +     opnd = OPERAND(p);
  1426. +     switch (OP(p)) {
  1427. +     case ANY:
  1428. +         count = strlen(scan);
  1429. +         scan += count;
  1430. +         break;
  1431. +     case EXACTLY:
  1432. +         while (*opnd == *scan) {
  1433. +             count++;
  1434. +             scan++;
  1435. +         }
  1436. +         break;
  1437. +     case ANYOF:
  1438. +         while (*scan != '\0' && index(opnd, *scan) != NULL) {
  1439. +             count++;
  1440. +             scan++;
  1441. +         }
  1442. +         break;
  1443. +     case ANYBUT:
  1444. +         while (*scan != '\0' && index(opnd, *scan) == NULL) {
  1445. +             count++;
  1446. +             scan++;
  1447. +         }
  1448. +         break;
  1449. +     default:        /* Oh dear.  Called inappropriately. */
  1450. +         regerror("internal foulup");
  1451. +         count = 0;    /* Best compromise. */
  1452. +         break;
  1453. +     }
  1454. +     reginput = scan;
  1455. +     return(count);
  1456. + }
  1457. + /*
  1458. +  - regnext - dig the "next" pointer out of a node
  1459. +  */
  1460. + static char *
  1461. + regnext(p)
  1462. + register char *p;
  1463. + {
  1464. +     register int offset;
  1465. +     if (p == ®dummy)
  1466. +         return(NULL);
  1467. +     offset = NEXT(p);
  1468. +     if (offset == 0)
  1469. +         return(NULL);
  1470. +     if (OP(p) == BACK)
  1471. +         return(p-offset);
  1472. +     else
  1473. +         return(p+offset);
  1474. + }
  1475. + #ifdef DEBUG
  1476. + STATIC char *regprop();
  1477. + /*
  1478. +  - regdump - dump a regexp onto stdout in vaguely comprehensible form
  1479. +  */
  1480. + void
  1481. + regdump(r)
  1482. + regexp *r;
  1483. + {
  1484. +     register char *s;
  1485. +     register char op = EXACTLY;    /* Arbitrary non-END op. */
  1486. +     register char *next;
  1487. +     s = r->program + 1;
  1488. +     while (op != END) {    /* While that wasn't END last time... */
  1489. +         op = OP(s);
  1490. +         printf("%2d%s", s-r->program, regprop(s));    /* Where, what. */
  1491. +         next = regnext(s);
  1492. +         if (next == NULL)        /* Next ptr. */
  1493. +             printf("(0)");
  1494. +         else 
  1495. +             printf("(%d)", (s-r->program)+(next-s));
  1496. +         s += 3;
  1497. +         if (op == ANYOF || op == ANYBUT || op == EXACTLY) {
  1498. +             /* Literal string, where present. */
  1499. +             while (*s != '\0') {
  1500. +                 putchar(*s);
  1501. +                 s++;
  1502. +             }
  1503. +             s++;
  1504. +         }
  1505. +         putchar('\n');
  1506. +     }
  1507. +     /* Header fields of interest. */
  1508. +     if (r->regstart != '\0')
  1509. +         printf("start `%c' ", r->regstart);
  1510. +     if (r->reganch)
  1511. +         printf("anchored ");
  1512. +     if (r->regmust != NULL)
  1513. +         printf("must have \"%s\"", r->regmust);
  1514. +     printf("\n");
  1515. + }
  1516. + /*
  1517. +  - regprop - printable representation of opcode
  1518. +  */
  1519. + static char *
  1520. + regprop(op)
  1521. + char *op;
  1522. + {
  1523. +     register char *p;
  1524. +     static char buf[50];
  1525. +     (void) strcpy(buf, ":");
  1526. +     switch (OP(op)) {
  1527. +     case BOL:
  1528. +         p = "BOL";
  1529. +         break;
  1530. +     case EOL:
  1531. +         p = "EOL";
  1532. +         break;
  1533. +     case ANY:
  1534. +         p = "ANY";
  1535. +         break;
  1536. +     case ANYOF:
  1537. +         p = "ANYOF";
  1538. +         break;
  1539. +     case ANYBUT:
  1540. +         p = "ANYBUT";
  1541. +         break;
  1542. +     case BRANCH:
  1543. +         p = "BRANCH";
  1544. +         break;
  1545. +     case EXACTLY:
  1546. +         p = "EXACTLY";
  1547. +         break;
  1548. +     case NOTHING:
  1549. +         p = "NOTHING";
  1550. +         break;
  1551. +     case BACK:
  1552. +         p = "BACK";
  1553. +         break;
  1554. +     case END:
  1555. +         p = "END";
  1556. +         break;
  1557. +     case OPEN+1:
  1558. +     case OPEN+2:
  1559. +     case OPEN+3:
  1560. +     case OPEN+4:
  1561. +     case OPEN+5:
  1562. +     case OPEN+6:
  1563. +     case OPEN+7:
  1564. +     case OPEN+8:
  1565. +     case OPEN+9:
  1566. +         sprintf(buf+strlen(buf), "OPEN%d", OP(op)-OPEN);
  1567. +         p = NULL;
  1568. +         break;
  1569. +     case CLOSE+1:
  1570. +     case CLOSE+2:
  1571. +     case CLOSE+3:
  1572. +     case CLOSE+4:
  1573. +     case CLOSE+5:
  1574. +     case CLOSE+6:
  1575. +     case CLOSE+7:
  1576. +     case CLOSE+8:
  1577. +     case CLOSE+9:
  1578. +         sprintf(buf+strlen(buf), "CLOSE%d", OP(op)-CLOSE);
  1579. +         p = NULL;
  1580. +         break;
  1581. +     case STAR:
  1582. +         p = "STAR";
  1583. +         break;
  1584. +     case PLUS:
  1585. +         p = "PLUS";
  1586. +         break;
  1587. +     default:
  1588. +         regerror("corrupted opcode");
  1589. +         break;
  1590. +     }
  1591. +     if (p != NULL)
  1592. +         (void) strcat(buf, p);
  1593. +     return(buf);
  1594. + }
  1595. + #endif
  1596.  
  1597. Index: src/date.c
  1598. Prereq: 5.1
  1599. *** ../elm2.4/src/date.c    Sat Oct  3 18:58:48 1992
  1600. --- src/date.c    Sat Nov 14 21:10:21 1992
  1601. ***************
  1602. *** 1,8 ****
  1603.   
  1604. ! static char rcsid[] = "@(#)$Id: date.c,v 5.1 1992/10/03 22:58:40 syd Exp $";
  1605.   
  1606.   /*******************************************************************************
  1607. !  *  The Elm Mail System  -  $Revision: 5.1 $   $State: Exp $
  1608.    *
  1609.    *             Copyright (c) 1988-1992 USENET Community Trust
  1610.    *             Copyright (c) 1986,1987 Dave Taylor
  1611. --- 1,8 ----
  1612.   
  1613. ! static char rcsid[] = "@(#)$Id: date.c,v 5.2 1992/11/15 02:10:11 syd Exp $";
  1614.   
  1615.   /*******************************************************************************
  1616. !  *  The Elm Mail System  -  $Revision: 5.2 $   $State: Exp $
  1617.    *
  1618.    *             Copyright (c) 1988-1992 USENET Community Trust
  1619.    *             Copyright (c) 1986,1987 Dave Taylor
  1620. ***************
  1621. *** 14,19 ****
  1622. --- 14,23 ----
  1623.    *
  1624.    *******************************************************************************
  1625.    * $Log: date.c,v $
  1626. +  * Revision 5.2  1992/11/15  02:10:11  syd
  1627. +  * remove no longer used tzname
  1628. +  * From: Syd
  1629. +  *
  1630.    * Revision 5.1  1992/10/03  22:58:40  syd
  1631.    * Initial checkin as of 2.4 Release at PL0
  1632.    *
  1633. ***************
  1634. *** 65,76 ****
  1635.   
  1636.   int  days_in_month[] = { 31,    28,    31,    30,    31,     30, 
  1637.             31,     31,    30,   31,    30,     31,  -1};
  1638. - #ifdef BSD
  1639. -   char *timezone();
  1640. - #else
  1641. -   extern char *tzname[];
  1642. - #endif
  1643.   
  1644.   days_ahead(days, buffer)
  1645.   int days;
  1646. --- 69,74 ----
  1647.  
  1648. Index: lib/getarpdate.c
  1649. Prereq: 5.2
  1650. *** ../elm2.4/lib/getarpdate.c    Tue Nov 10 15:20:24 1992
  1651. --- lib/getarpdate.c    Sat Nov 14 21:18:27 1992
  1652. ***************
  1653. *** 1,7 ****
  1654. ! static char rcsid[] = "@(#)$Id: getarpdate.c,v 5.2 1992/11/07 19:27:30 syd Exp $";
  1655.   
  1656.   /*******************************************************************************
  1657. !  *  The Elm Mail System  -  $Revision: 5.2 $   $State: Exp $
  1658.    *
  1659.    *            Copyright (c) 1988-1992 USENET Community Trust
  1660.    *            Copyright (c) 1986,1987 Dave Taylor
  1661. --- 1,7 ----
  1662. ! static char rcsid[] = "@(#)$Id: getarpdate.c,v 5.4 1992/11/15 02:18:15 syd Exp $";
  1663.   
  1664.   /*******************************************************************************
  1665. !  *  The Elm Mail System  -  $Revision: 5.4 $   $State: Exp $
  1666.    *
  1667.    *            Copyright (c) 1988-1992 USENET Community Trust
  1668.    *            Copyright (c) 1986,1987 Dave Taylor
  1669. ***************
  1670. *** 13,18 ****
  1671. --- 13,27 ----
  1672.    *
  1673.    *******************************************************************************
  1674.    * $Log: getarpdate.c,v $
  1675. +  * Revision 5.4  1992/11/15  02:18:15  syd
  1676. +  * Change most of the rest of the BSDs to TZNAME
  1677. +  * From: Syd
  1678. +  *
  1679. +  * Revision 5.3  1992/11/15  02:10:58  syd
  1680. +  * change tzname ifdef from ndefBSD to ifdef TZNAME on its own
  1681. +  * configure variable
  1682. +  * From: Syd
  1683. +  *
  1684.    * Revision 5.2  1992/11/07  19:27:30  syd
  1685.    * Symbol change for AIX370
  1686.    * From: uri@watson.ibm.com
  1687. ***************
  1688. *** 54,63 ****
  1689.   static char *arpa_monname[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
  1690.             "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", ""};
  1691.   
  1692. ! #if defined(BSD) && !defined(_POSIX_SOURCE)
  1693. !   char *timezone();
  1694. ! #else
  1695.     extern char *tzname[];
  1696.   #endif
  1697.   
  1698.   #ifdef _AIX370
  1699. --- 63,72 ----
  1700.   static char *arpa_monname[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
  1701.             "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", ""};
  1702.   
  1703. ! #ifdef TZNAME
  1704.     extern char *tzname[];
  1705. + #else
  1706. +   char *timezone();
  1707.   #endif
  1708.   
  1709.   #ifdef _AIX370
  1710. ***************
  1711. *** 80,86 ****
  1712.       long       tzmin;        /* number of minutes off gmt      */
  1713.       char      *tzsign;        /* + or - gmt              */
  1714.   
  1715. ! #ifdef BSD
  1716.   # ifndef TZ_MINUTESWEST
  1717.       struct timeb    loc_time;
  1718.   
  1719. --- 89,95 ----
  1720.       long       tzmin;        /* number of minutes off gmt      */
  1721.       char      *tzsign;        /* + or - gmt              */
  1722.   
  1723. ! #ifndef TZNAME
  1724.   # ifndef TZ_MINUTESWEST
  1725.       struct timeb    loc_time;
  1726.   
  1727. ***************
  1728. *** 94,100 ****
  1729.       junk = time_val.tv_sec;
  1730.   # endif /* TZ_MINUTESWEST */
  1731.   
  1732. ! #else /* BSD */
  1733.       extern    time_t    timezone;
  1734.   # ifdef ALTCHECK
  1735.       extern    time_t    altzone;
  1736. --- 103,109 ----
  1737.       junk = time_val.tv_sec;
  1738.   # endif /* TZ_MINUTESWEST */
  1739.   
  1740. ! #else /* TZNAME */
  1741.       extern    time_t    timezone;
  1742.   # ifdef ALTCHECK
  1743.       extern    time_t    altzone;
  1744. ***************
  1745. *** 101,112 ****
  1746.   # endif
  1747.   
  1748.       junk = time((time_t *) 0);    /* this must be here for it to work! */
  1749. ! #endif /* BSD */
  1750.   
  1751.       the_time = localtime(&junk);
  1752.       if (the_time->tm_year < 100)
  1753.           the_time->tm_year += 1900;
  1754. ! #ifdef BSD
  1755.   # ifdef TZ_MINUTESWEST
  1756.       if (the_time->tm_isdst && time_zone.tz_dsttime != DST_NONE)
  1757.           tzmin = - (time_zone.tz_minuteswest - 60);
  1758. --- 110,121 ----
  1759.   # endif
  1760.   
  1761.       junk = time((time_t *) 0);    /* this must be here for it to work! */
  1762. ! #endif /* TZNAME */
  1763.   
  1764.       the_time = localtime(&junk);
  1765.       if (the_time->tm_year < 100)
  1766.           the_time->tm_year += 1900;
  1767. ! #ifndef TZNAME
  1768.   # ifdef TZ_MINUTESWEST
  1769.       if (the_time->tm_isdst && time_zone.tz_dsttime != DST_NONE)
  1770.           tzmin = - (time_zone.tz_minuteswest - 60);
  1771. ***************
  1772. *** 115,121 ****
  1773.   # else /* TZ_MINUTESWEST */
  1774.       tzmin = the_time->tm_gmtoff / 60;
  1775.   # endif /* TZ_MINUTESWEST */
  1776. ! #else /* BSD */
  1777.   # ifdef ALTCHECK
  1778.       if (the_time->tm_isdst)
  1779.           tzmin = - (altzone / 60);
  1780. --- 124,130 ----
  1781.   # else /* TZ_MINUTESWEST */
  1782.       tzmin = the_time->tm_gmtoff / 60;
  1783.   # endif /* TZ_MINUTESWEST */
  1784. ! #else /* TZNAME */
  1785.   # ifdef ALTCHECK
  1786.       if (the_time->tm_isdst)
  1787.           tzmin = - (altzone / 60);
  1788. ***************
  1789. *** 124,130 ****
  1790.   # else /* ALTCHECK */
  1791.       tzmin = - (timezone / 60);
  1792.   # endif /* ALTCHECK */
  1793. ! #endif /* BSD */
  1794.   
  1795.       if (tzmin >= 0)
  1796.           tzsign = "+";
  1797. --- 133,139 ----
  1798.   # else /* ALTCHECK */
  1799.       tzmin = - (timezone / 60);
  1800.   # endif /* ALTCHECK */
  1801. ! #endif /* TZNAME */
  1802.   
  1803.       if (tzmin >= 0)
  1804.           tzsign = "+";
  1805. ***************
  1806. *** 139,145 ****
  1807.         arpa_monname[the_time->tm_mon], the_time->tm_year,
  1808.         the_time->tm_hour, the_time->tm_min, the_time->tm_sec,
  1809.         tzsign, tzmin / 60, tzmin % 60,
  1810. ! #ifdef BSD
  1811.   #ifdef TZ_MINUTESWEST
  1812.   # ifdef GOULD_NP1
  1813.         the_time->tm_zone);
  1814. --- 148,154 ----
  1815.         arpa_monname[the_time->tm_mon], the_time->tm_year,
  1816.         the_time->tm_hour, the_time->tm_min, the_time->tm_sec,
  1817.         tzsign, tzmin / 60, tzmin % 60,
  1818. ! #ifndef TZNAME
  1819.   #ifdef TZ_MINUTESWEST
  1820.   # ifdef GOULD_NP1
  1821.         the_time->tm_zone);
  1822.  
  1823. Index: src/editmsg.c
  1824. Prereq: 5.2
  1825. *** ../elm2.4/src/editmsg.c    Mon Oct 19 13:04:08 1992
  1826. --- src/editmsg.c    Mon Nov 16 23:05:25 1992
  1827. ***************
  1828. *** 1,8 ****
  1829.   
  1830. ! static char rcsid[] = "@(#)$Id: editmsg.c,v 5.2 1992/10/17 22:22:33 syd Exp $";
  1831.   
  1832.   /*******************************************************************************
  1833. !  *  The Elm Mail System  -  $Revision: 5.2 $   $State: Exp $
  1834.    *
  1835.    *             Copyright (c) 1988-1992 USENET Community Trust
  1836.    *            Copyright (c) 1986,1987 Dave Taylor
  1837. --- 1,8 ----
  1838.   
  1839. ! static char rcsid[] = "@(#)$Id: editmsg.c,v 5.3 1992/11/17 04:05:24 syd Exp $";
  1840.   
  1841.   /*******************************************************************************
  1842. !  *  The Elm Mail System  -  $Revision: 5.3 $   $State: Exp $
  1843.    *
  1844.    *             Copyright (c) 1988-1992 USENET Community Trust
  1845.    *            Copyright (c) 1986,1987 Dave Taylor
  1846. ***************
  1847. *** 14,19 ****
  1848. --- 14,23 ----
  1849.    *
  1850.    *******************************************************************************
  1851.    * $Log: editmsg.c,v $
  1852. +  * Revision 5.3  1992/11/17  04:05:24  syd
  1853. +  * Fix for editing interrupt broken by posix_signal().
  1854. +  * From cs.utexas.edu!chinacat!chip Mon Nov 16 09:03:04 1992
  1855. +  *
  1856.    * Revision 5.2  1992/10/17  22:22:33  syd
  1857.    * Fix warnings from my ANSI C compiler because the declaration of
  1858.    * edit_interrupt did not match the prototype for the second argument of
  1859. ***************
  1860. *** 38,43 ****
  1861. --- 42,53 ----
  1862.   #include <setjmp.h>
  1863.   #endif /* BSD */
  1864.   #include <ctype.h>
  1865. + #ifdef POSIX_SIGNALS
  1866. + #define jmp_buf            sigjmp_buf
  1867. + #define setjmp(env)        sigsetjmp((env), 1)
  1868. + #define longjmp(env,val)    siglongjmp((env), (val))
  1869. + #endif
  1870.   
  1871.   #ifdef BSD
  1872.   #undef        tolower
  1873.  
  1874. -- 
  1875. ========================================================================
  1876. Sydney S. Weinstein, CDP, CCP          Elm Coordinator - Current 2.4PL08
  1877. Datacomp Systems, Inc.                 Projected 3.0 Release: ??? ?,1994
  1878. syd@DSI.COM or dsinc!syd      Voice: (215) 947-9900, FAX: (215) 938-0235
  1879.