Subject: elm 2.4 Patch #23c
Summary: This is an official patch for elm 2.4 system.  Please apply it.
Priority: HIGH

THIS IS PART 3 OF A 5 PART PATCH

Fix:    From rn, say "| patch -p -N -d DIR", where DIR is your elm source
       directory.  Outside of rn, say "cd DIR; patch -p -N <thisarticle".
       If you don't have the patch program, apply the following by hand,
       or get patch (version 2.0, latest patchlevel).

       After patching:
               Apply patches 23d, 23e next

       If patch indicates that patchlevel is the wrong version, you may need
       to apply one or more previous patches, or the patch may already
       have been applied.  See the patchlevel.h file to find out what has or
       has not been applied.  In any event, don't continue with the patch.

       If you are missing previous patches they can be obtained from our:
       archive server.

       Syd Weinstein
       [email protected]

       The patches are available from the dsinc archive server
       Send the following message to [email protected] for
       a list of available patches:

       Subject: patch list
       send index elm

Index: lib/ndbz.c
Prereq: 5.6
*** ../elm2.4/lib/ndbz.c        Sun Apr 11 23:22:31 1993
--- lib/ndbz.c  Sun Aug 22 22:46:55 1993
***************
*** 1,7 ****
! static char rcsid[] = "@(#)$Id: ndbz.c,v 5.6 1993/02/08 00:18:11 syd Exp $";

 /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.6 $   $State: Exp $
  *
  *                    Copyright (c) 1988-1992 USENET Community Trust
  *                    Copyright (c) 1986,1987 Dave Taylor
--- 1,7 ----
! static char rcsid[] = "@(#)$Id: ndbz.c,v 5.11 1993/08/23 02:46:51 syd Exp $";

 /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.11 $   $State: Exp $
  *
  *                    Copyright (c) 1988-1992 USENET Community Trust
  *                    Copyright (c) 1986,1987 Dave Taylor
***************
*** 13,18 ****
--- 13,47 ----
  *
  *******************************************************************************
  * $Log: ndbz.c,v $
+  * Revision 5.11  1993/08/23  02:46:51  syd
+  * Test ANSI_C, not __STDC__ (which is not set on e.g. AIX).
+  * From: decwrl!uunet.UU.NET!fin!chip (Chip Salzenberg)
+  *
+  * Revision 5.10  1993/08/03  19:28:39  syd
+  * Elm tries to replace the system toupper() and tolower() on current
+  * BSD systems, which is unnecessary.  Even worse, the replacements
+  * collide during linking with routines in isctype.o.  This patch adds
+  * a Configure test to determine whether replacements are really needed
+  * (BROKE_CTYPE definition).  The <ctype.h> header file is now included
+  * globally through hdrs/defs.h and the BROKE_CTYPE patchup is handled
+  * there.  Inclusion of <ctype.h> was removed from *all* the individual
+  * files, and the toupper() and tolower() routines in lib/opt_utils.c
+  * were dropped.
+  * From: [email protected] (Chip Rosenthal)
+  *
+  * Revision 5.9  1993/08/03  19:22:01  syd
+  * Add proper casts to free() calls to suppress warnings.
+  * Properly cast return types.
+  * From: [email protected] (Chip Rosenthal)
+  *
+  * Revision 5.8  1993/07/20  02:59:53  syd
+  * Support aliases both on 64 bit and 32 bit machines at the same time.
+  * From: Dan Mosedale <[email protected]>
+  *
+  * Revision 5.7  1993/06/09  23:41:34  syd
+  * Add frees of db structure on failed dbz_open
+  * From: Syd
+  *
  * Revision 5.6  1993/02/08  00:18:11  syd
  * fix taghere to be || instead of | and paren to make
  * it catch duplicates again, as per testing.
***************
*** 74,80 ****
 */

 #include "headers.h"
- #include <ctype.h>
 #include <errno.h>
 #ifndef ANSI_C
 extern int errno;
--- 103,108 ----
***************
*** 194,200 ****
 #endif

 static int getconf();
! static long getno();
 static int putconf();
 static void mybytemap();
 static of_t bytemap();
--- 222,228 ----
 #endif

 static int getconf();
! static int32 getno();
 static int putconf();
 static void mybytemap();
 static of_t bytemap();
***************
*** 246,252 ****
 #define       MAPOUT(o)       ((db->dbz_bytesame) ? (o) : bytemap((o), db->dbz_mybmap, db->dbz_conf.bytemap))

 /* externals used */
! #ifndef __STDC__ /* avoid problemswith systems that declare atol as a macro */
 extern long atol();
 #endif

--- 274,280 ----
 #define       MAPOUT(o)       ((db->dbz_bytesame) ? (o) : bytemap((o), db->dbz_mybmap, db->dbz_conf.bytemap))

 /* externals used */
! #if !ANSI_C  /* avoid problems with systems that declare atol as a macro */
 extern long atol();
 #endif

***************
*** 282,293 ****

       if (size != 0 && size < 2) {
               dprint(5, (debugfile, "dbz_fresh: preposterous size (%ld)\n", size));
!               return(NULL);
       }

       /* get default configuration */
       if (getconf((FILE *)NULL, (FILE *)NULL, &c) < 0)
!               return(NULL);   /* "can't happen" */

       /* and mess with it as specified */
       if (size != 0)
--- 310,321 ----

       if (size != 0 && size < 2) {
               dprint(5, (debugfile, "dbz_fresh: preposterous size (%ld)\n", size));
!               return (DBZ *)NULL;
       }

       /* get default configuration */
       if (getconf((FILE *)NULL, (FILE *)NULL, &c) < 0)
!               return (DBZ *)NULL; /* "can't happen" */

       /* and mess with it as specified */
       if (size != 0)
***************
*** 316,346 ****
       /* write it out */
       fn = enstring(name, dir);
       if (fn == NULL)
!               return(NULL);
       f = fopen(fn, "w");
!       free(fn);
       if (f == NULL) {
               dprint(5, (debugfile, "dbz_fresh: unable to write config\n"));
!               return(NULL);
       }
       if (putconf(f, &c) < 0) {
               (void) fclose(f);
!               return(NULL);
       }
       if (fclose(f) == EOF) {
               dprint(5, (debugfile, "dbz_fresh: fclose failure\n"));
!               return(NULL);
       }

       /* create/truncate .pag */
       fn = enstring(name, pag);
       if (fn == NULL)
!               return(NULL);
       f = fopen(fn, "w");
!       free(fn);
       if (f == NULL) {
               dprint(5, (debugfile, "dbz_fresh: unable to create/truncate .pag file\n"));
!               return(NULL);
       } else
               (void) fclose(f);

--- 344,374 ----
       /* write it out */
       fn = enstring(name, dir);
       if (fn == NULL)
!               return (DBZ *)NULL;
       f = fopen(fn, "w");
!       free((malloc_t)fn);
       if (f == NULL) {
               dprint(5, (debugfile, "dbz_fresh: unable to write config\n"));
!               return (DBZ *)NULL;
       }
       if (putconf(f, &c) < 0) {
               (void) fclose(f);
!               return (DBZ *)NULL;
       }
       if (fclose(f) == EOF) {
               dprint(5, (debugfile, "dbz_fresh: fclose failure\n"));
!               return (DBZ *)NULL;
       }

       /* create/truncate .pag */
       fn = enstring(name, pag);
       if (fn == NULL)
!               return (DBZ *)NULL;
       f = fopen(fn, "w");
!       free((malloc_t)fn);
       if (f == NULL) {
               dprint(5, (debugfile, "dbz_fresh: unable to create/truncate .pag file\n"));
!               return (DBZ *)NULL;
       } else
               (void) fclose(f);

***************
*** 426,443 ****
       /* pick up the old configuration */
       fn = enstring(oldname, dir);
       if (fn == NULL)
!               return(NULL);
       f = fopen(fn, "r");
!       free(fn);
       if (f == NULL) {
               dprint(5, (debugfile, "dbz_again: cannot open old .dir file\n"));
!               return(NULL);
       }
       i = getconf(f, (FILE *)NULL, &c);
       (void) fclose(f);
       if (i < 0) {
               dprint(5, (debugfile, "dbz_again: getconf failed\n"));
!               return(NULL);
       }

       /* tinker with it */
--- 454,471 ----
       /* pick up the old configuration */
       fn = enstring(oldname, dir);
       if (fn == NULL)
!               return (DBZ *)NULL;
       f = fopen(fn, "r");
!       free((malloc_t)fn);
       if (f == NULL) {
               dprint(5, (debugfile, "dbz_again: cannot open old .dir file\n"));
!               return (DBZ *)NULL;
       }
       i = getconf(f, (FILE *)NULL, &c);
       (void) fclose(f);
       if (i < 0) {
               dprint(5, (debugfile, "dbz_again: getconf failed\n"));
!               return (DBZ *)NULL;
       }

       /* tinker with it */
***************
*** 463,491 ****
       /* write it out */
       fn = enstring(name, dir);
       if (fn == NULL)
!               return(NULL);
       f = fopen(fn, "w");
!       free(fn);
       if (f == NULL) {
               dprint(5, (debugfile, "dbz_again: unable to write new .dir\n"));
!               return(NULL);
       }
       i = putconf(f, &c);
       (void) fclose(f);
       if (i < 0) {
               dprint(5, (debugfile, "dbz_again: putconf failed\n"));
!               return(NULL);
       }

       /* create/truncate .pag */
       fn = enstring(name, pag);
       if (fn == NULL)
!               return(NULL);
       f = fopen(fn, "w");
!       free(fn);
       if (f == NULL) {
               dprint(5, (debugfile, "dbz_again: unable to create/truncate .pag file\n"));
!               return(NULL);
       } else
               (void) fclose(f);

--- 491,519 ----
       /* write it out */
       fn = enstring(name, dir);
       if (fn == NULL)
!               return (DBZ *)NULL;
       f = fopen(fn, "w");
!       free((malloc_t)fn);
       if (f == NULL) {
               dprint(5, (debugfile, "dbz_again: unable to write new .dir\n"));
!               return (DBZ *)NULL;
       }
       i = putconf(f, &c);
       (void) fclose(f);
       if (i < 0) {
               dprint(5, (debugfile, "dbz_again: putconf failed\n"));
!               return (DBZ *)NULL;
       }

       /* create/truncate .pag */
       fn = enstring(name, pag);
       if (fn == NULL)
!               return (DBZ *)NULL;
       f = fopen(fn, "w");
!       free((malloc_t)fn);
       if (f == NULL) {
               dprint(5, (debugfile, "dbz_again: unable to create/truncate .pag file\n"));
!               return (DBZ *)NULL;
       } else
               (void) fclose(f);

***************
*** 512,540 ****

       if ((db = (DBZ *) calloc(sizeof(DBZ), 1)) == NULL) {
               dprint(5, (debugfile, "dbz_open: no room for DBZ structure\n"));
!               return(NULL);
       }
       /* open the .dir file */
       dirfname = enstring(name, dir);
!       if (dirfname == NULL)
!               return(NULL);

       if (mode == O_RDONLY) {
               db->dbz_dirf = fopen(dirfname, "r");
               db->dbz_dirronly = 1;
       } else
               db->dbz_dirf = fopen(dirfname, "r+");
!       free(dirfname);
       if (db->dbz_dirf == NULL) {
               dprint(5, (debugfile, "dbz_open: can't open .dir file\n"));
!               return(NULL);
       }

       /* open the .pag file */
       pagfname = enstring(name, pag);
       if (pagfname == NULL) {
               (void) fclose(db->dbz_dirf);
!               return(NULL);
       }
       if (mode == O_RDONLY) {
               db->dbz_pagf = fopen(pagfname, "rb");
--- 540,573 ----

       if ((db = (DBZ *) calloc(sizeof(DBZ), 1)) == NULL) {
               dprint(5, (debugfile, "dbz_open: no room for DBZ structure\n"));
!               return (DBZ *)NULL;
       }
       /* open the .dir file */
       dirfname = enstring(name, dir);
!       if (dirfname == NULL) {
!               free((malloc_t)db);
!               return (DBZ *)NULL;
!       }

       if (mode == O_RDONLY) {
               db->dbz_dirf = fopen(dirfname, "r");
               db->dbz_dirronly = 1;
       } else
               db->dbz_dirf = fopen(dirfname, "r+");
!       free((malloc_t)dirfname);
!
       if (db->dbz_dirf == NULL) {
               dprint(5, (debugfile, "dbz_open: can't open .dir file\n"));
!               free((malloc_t)db);
!               return (DBZ *)NULL;
       }

       /* open the .pag file */
       pagfname = enstring(name, pag);
       if (pagfname == NULL) {
               (void) fclose(db->dbz_dirf);
!               free((malloc_t)db);
!               return (DBZ *)NULL;
       }
       if (mode == O_RDONLY) {
               db->dbz_pagf = fopen(pagfname, "rb");
***************
*** 545,552 ****
       if (db->dbz_pagf == NULL) {
               dprint(5, (debugfile, "dbz_open: .pag open failed\n"));
               (void) fclose(db->dbz_dirf);
!               free(pagfname);
!               return(NULL);
       }
 #ifdef NOBUFFER
       /*
--- 578,586 ----
       if (db->dbz_pagf == NULL) {
               dprint(5, (debugfile, "dbz_open: .pag open failed\n"));
               (void) fclose(db->dbz_dirf);
!               free((malloc_t)pagfname);
!               free((malloc_t)db);
!               return (DBZ *)NULL;
       }
 #ifdef NOBUFFER
       /*
***************
*** 572,579 ****
               if (db->dbz_basefname == NULL) {
                       (void) fclose(db->dbz_pagf);
                       (void) fclose(db->dbz_dirf);
!                       free(pagfname);
!                       return(NULL);
               }
       } else
               db->dbz_basefname = NULL;
--- 606,614 ----
               if (db->dbz_basefname == NULL) {
                       (void) fclose(db->dbz_pagf);
                       (void) fclose(db->dbz_dirf);
!                       free((malloc_t)pagfname);
!                       free((malloc_t)db);
!                       return (DBZ *)NULL;
               }
       } else
               db->dbz_basefname = NULL;
***************
*** 589,597 ****
               (void) fclose(db->dbz_pagf);
               (void) fclose(db->dbz_basef);
               (void) fclose(db->dbz_dirf);
!               free(pagfname);
               errno = EDOM;   /* kind of a kludge, but very portable */
!               return(NULL);
       }
       db->dbz_tagbits = db->dbz_conf.tagmask << db->dbz_conf.tagshift;
       db->dbz_taghere = db->dbz_conf.tagenb << db->dbz_conf.tagshift;
--- 624,633 ----
               (void) fclose(db->dbz_pagf);
               (void) fclose(db->dbz_basef);
               (void) fclose(db->dbz_dirf);
!               free((malloc_t)pagfname);
!               free((malloc_t)db);
               errno = EDOM;   /* kind of a kludge, but very portable */
!               return (DBZ *)NULL;
       }
       db->dbz_tagbits = db->dbz_conf.tagmask << db->dbz_conf.tagshift;
       db->dbz_taghere = db->dbz_conf.tagenb << db->dbz_conf.tagshift;
***************
*** 613,619 ****
               db->dbz_bufpagf = NULL;
               db->dbz_corepag = NULL;
       }
!       free(pagfname);

       /* misc. setup */
       crcinit();
--- 649,655 ----
               db->dbz_bufpagf = NULL;
               db->dbz_corepag = NULL;
       }
!       free((malloc_t)pagfname);

       /* misc. setup */
       crcinit();
***************
*** 668,681 ****
               ret = -1;
       }
       if (db->dbz_corepag != NULL)
!               free((char *)db->dbz_corepag);
       db->dbz_corepag = NULL;
       if (fclose(db->dbz_basef) == EOF) {
               dprint(5, (debugfile, "dbz_close: fclose(basef) failed\n"));
               ret = -1;
       }
       if (db->dbz_basefname != NULL)
!               free(db->dbz_basefname);
       db->dbz_basef = NULL;
       db->dbz_pagf = NULL;
       if (fclose(db->dbz_dirf) == EOF) {
--- 704,717 ----
               ret = -1;
       }
       if (db->dbz_corepag != NULL)
!               free((malloc_t)db->dbz_corepag);
       db->dbz_corepag = NULL;
       if (fclose(db->dbz_basef) == EOF) {
               dprint(5, (debugfile, "dbz_close: fclose(basef) failed\n"));
               ret = -1;
       }
       if (db->dbz_basefname != NULL)
!               free((malloc_t)db->dbz_basefname);
       db->dbz_basef = NULL;
       db->dbz_pagf = NULL;
       if (fclose(db->dbz_dirf) == EOF) {
***************
*** 683,689 ****
               ret = -1;
       }

!       free((char *) db);

       dprint(5, (debugfile, "dbz_close: %s\n", (ret == 0) ? "succeeded" : "failed"));
       return(ret);
--- 719,725 ----
               ret = -1;
       }

!       free((malloc_t) db);

       dprint(5, (debugfile, "dbz_close: %s\n", (ret == 0) ? "succeeded" : "failed"));
       return(ret);
***************
*** 829,842 ****

       if (db->dbz_basefname == NULL) {
               dprint(5, (debugfile, "latebase: name foulup\n"));
!               return(NULL);
       }
       it = fopen(db->dbz_basefname, "r");
       if (it == NULL) {
               dprint(5, (debugfile, "latebase: still can't open base\n"));
       } else {
               dprint(5, (debugfile, "latebase: late open succeeded\n"));
!               free(db->dbz_basefname);
               db->dbz_basefname = NULL;
 #ifdef _IOFBF
               (void) setvbuf(it, db->dbz_basebuf, _IOFBF, sizeof(db->dbz_basebuf));
--- 865,878 ----

       if (db->dbz_basefname == NULL) {
               dprint(5, (debugfile, "latebase: name foulup\n"));
!               return (FILE *)NULL;
       }
       it = fopen(db->dbz_basefname, "r");
       if (it == NULL) {
               dprint(5, (debugfile, "latebase: still can't open base\n"));
       } else {
               dprint(5, (debugfile, "latebase: late open succeeded\n"));
!               free((malloc_t)db->dbz_basefname);
               db->dbz_basefname = NULL;
 #ifdef _IOFBF
               (void) setvbuf(it, db->dbz_basebuf, _IOFBF, sizeof(db->dbz_basebuf));
***************
*** 988,996 ****
 }

 /*
!  - getno - get a long
  */
! static long
 getno(f, ep)
 FILE *f;
 int *ep;
--- 1024,1032 ----
 }

 /*
!  - getno - get an int32
  */
! static int32
 getno(f, ep)
 FILE *f;
 int *ep;
***************
*** 1023,1029 ****
               dprint(5, (debugfile, "getno: `%s' non-numeric\n", getbuf));
               *ep = -1;
       }
!       return(atol(getbuf));
 }

 /*
--- 1059,1066 ----
               dprint(5, (debugfile, "getno: `%s' non-numeric\n", getbuf));
               *ep = -1;
       }
!
!       return((int32)atol(getbuf));
 }

 /*
***************
*** 1073,1086 ****
       it = malloc((size_t)db->dbz_conf.tsize * SOF);
       if (it == NULL) {
               dprint(5, (debugfile, "getcore: malloc failed\n"));
!               return(NULL);
       }

       nread = fread(it, SOF, (size_t)db->dbz_conf.tsize, db->dbz_bufpagf);
       if (ferror(db->dbz_bufpagf)) {
               dprint(5, (debugfile, "getcore: read failed\n"));
!               free(it);
!               return(NULL);
       }

       p = (of_t *)it + nread;
--- 1110,1123 ----
       it = malloc((size_t)db->dbz_conf.tsize * SOF);
       if (it == NULL) {
               dprint(5, (debugfile, "getcore: malloc failed\n"));
!               return (of_t *)NULL;
       }

       nread = fread(it, SOF, (size_t)db->dbz_conf.tsize, db->dbz_bufpagf);
       if (ferror(db->dbz_bufpagf)) {
               dprint(5, (debugfile, "getcore: read failed\n"));
!               free((malloc_t)it);
!               return (of_t *)NULL;
       }

       p = (of_t *)it + nread;

Index: lib/opt_utils.c
Prereq: 5.7
*** ../elm2.4/lib/opt_utils.c   Tue Jan 19 22:02:34 1993
--- lib/opt_utils.c     Tue Aug  3 16:11:44 1993
***************
*** 1,8 ****

! static char rcsid[] = "@(#)$Id: opt_utils.c,v 5.7 1993/01/20 03:02:19 syd Exp $";

 /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.7 $   $State: Exp $
  *
  *                    Copyright (c) 1988-1992 USENET Community Trust
  *                    Copyright (c) 1986,1987 Dave Taylor
--- 1,8 ----

! static char rcsid[] = "@(#)$Id: opt_utils.c,v 5.8 1993/08/03 19:28:39 syd Exp $";

 /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.8 $   $State: Exp $
  *
  *                    Copyright (c) 1988-1992 USENET Community Trust
  *                    Copyright (c) 1986,1987 Dave Taylor
***************
*** 14,19 ****
--- 14,31 ----
  *
  *******************************************************************************
  * $Log: opt_utils.c,v $
+  * Revision 5.8  1993/08/03  19:28:39  syd
+  * Elm tries to replace the system toupper() and tolower() on current
+  * BSD systems, which is unnecessary.  Even worse, the replacements
+  * collide during linking with routines in isctype.o.  This patch adds
+  * a Configure test to determine whether replacements are really needed
+  * (BROKE_CTYPE definition).  The <ctype.h> header file is now included
+  * globally through hdrs/defs.h and the BROKE_CTYPE patchup is handled
+  * there.  Inclusion of <ctype.h> was removed from *all* the individual
+  * files, and the toupper() and tolower() routines in lib/opt_utils.c
+  * were dropped.
+  * From: [email protected] (Chip Rosenthal)
+  *
  * Revision 5.7  1993/01/20  03:02:19  syd
  * Move string declarations to defs.h
  * From: Syd
***************
*** 57,63 ****

 #include "headers.h"
 #include "s_error.h"
- #include <ctype.h>

 #ifdef PWDINSYS
 #  include <sys/pwd.h>
--- 69,74 ----
***************
*** 65,75 ****
 #  include <pwd.h>
 #endif

- #ifdef BSD
- #undef tolower
- #undef toupper
- #endif
-
 #ifndef GETHOSTNAME
 # ifdef DOUNAME
 #  include <sys/utsname.h>
--- 76,81 ----
***************
*** 217,251 ****

 #endif

- #if defined(BSD) && !defined(_POSIX_SOURCE)
-
- /** some supplementary string functions for Berkeley Unix systems **/
-
- int
- tolower(ch)
- int ch;
- {
-       /** This should be a macro call, but if you use this as a macro
-           calls to 'tolower' where the argument is a function call will
-           cause the function to be called TWICE which is obviously the
-           wrong behaviour.  On the other hand, to just blindly translate
-           assuming the character is always uppercase can cause BIG
-           problems, so...
-       **/
-
-       return ( isupper(ch) ? ch - 'A' + 'a' : ch );
- }
-
- int
- toupper(ch)
- int ch;
- {
-       /** see comment for above routine - tolower() **/
-
-       return ( islower(ch) ? ch - 'a' + 'A' : ch );
- }
-
- #endif

 #ifndef STRTOK

--- 223,228 ----

Index: lib/parsarpdat.c
Prereq: 5.2
*** ../elm2.4/lib/parsarpdat.c  Sun Apr 11 22:16:33 1993
--- lib/parsarpdat.c    Tue Aug  3 15:28:55 1993
***************
*** 1,8 ****

! static char rcsid[] = "@(#)$Id: parsarpdat.c,v 5.2 1993/04/12 02:16:32 syd Exp $";

 /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.2 $   $State: Exp $
  *
  *                    Copyright (c) 1993 USENET Community Trust
  *******************************************************************************
--- 1,8 ----

! static char rcsid[] = "@(#)$Id: parsarpdat.c,v 5.3 1993/08/03 19:28:39 syd Exp $";

 /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.3 $   $State: Exp $
  *
  *                    Copyright (c) 1993 USENET Community Trust
  *******************************************************************************
***************
*** 13,18 ****
--- 13,30 ----
  *
  *******************************************************************************
  * $Log: parsarpdat.c,v $
+  * Revision 5.3  1993/08/03  19:28:39  syd
+  * Elm tries to replace the system toupper() and tolower() on current
+  * BSD systems, which is unnecessary.  Even worse, the replacements
+  * collide during linking with routines in isctype.o.  This patch adds
+  * a Configure test to determine whether replacements are really needed
+  * (BROKE_CTYPE definition).  The <ctype.h> header file is now included
+  * globally through hdrs/defs.h and the BROKE_CTYPE patchup is handled
+  * there.  Inclusion of <ctype.h> was removed from *all* the individual
+  * files, and the toupper() and tolower() routines in lib/opt_utils.c
+  * were dropped.
+  * From: [email protected] (Chip Rosenthal)
+  *
  * Revision 5.2  1993/04/12  02:16:32  syd
  * Fix year handling bug in date(1) time formats.
  * From: [email protected] (Chip Rosenthal)
***************
*** 25,31 ****


 #include "headers.h"
- #include <ctype.h>


 /*
--- 37,42 ----

Index: lib/parsarpwho.c
Prereq: 5.3
*** ../elm2.4/lib/parsarpwho.c  Tue Jan 19 00:07:19 1993
--- lib/parsarpwho.c    Mon Jul 19 22:06:41 1993
***************
*** 1,8 ****

! static char rcsid[] = "@(#)$Id: parsarpwho.c,v 5.3 1993/01/19 05:07:05 syd Exp $";

 /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.3 $   $State: Exp $
  *
  *                    Copyright (c) 1988-1992 USENET Community Trust
  *                    Copyright (c) 1986,1987 Dave Taylor
--- 1,8 ----

! static char rcsid[] = "@(#)$Id: parsarpwho.c,v 5.4 1993/07/20 02:06:13 syd Exp $";

 /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.4 $   $State: Exp $
  *
  *                    Copyright (c) 1988-1992 USENET Community Trust
  *                    Copyright (c) 1986,1987 Dave Taylor
***************
*** 14,19 ****
--- 14,23 ----
  *
  *******************************************************************************
  * $Log: parsarpwho.c,v $
+  * Revision 5.4  1993/07/20  02:06:13  syd
+  * Changes for vms problem
+  * From: M.� Anio
+  *
  * Revision 5.3  1993/01/19  05:07:05  syd
  * Trim erroreous extra log entry
  * From: Syd
***************
*** 49,54 ****
--- 53,60 ----
           or  From: hplabs!dat (Dave Taylor)

           Added: removes quotes if name is quoted (12/12)
+            HOWEVER:  From: "NAME \"VMS USER\"" <USER@VMS>
+                  must be handled delicately !
           Added: only copies STRING characters...
           Added: if no comment part, copy address instead!
           Added: if is_really_a_to, this is really a 'to' line
***************
*** 119,134 ****

       if (strlen(temp) > 0) {         /* mess with buffer... */

!         /* remove leading spaces and quotes... */

!         while (whitespace(temp[0]) || temp[0] == '"')
           temp = (char *) (temp + 1);         /* increment address! */

!         /* remove trailing spaces and quotes... */

         i = strlen(temp) - 1;

!         while (i >= 0 && (whitespace(temp[i]) || temp[i] == '"'))
          temp[i--] = '\0';

         /* if anything is left, let's change 'from' value! */
--- 125,150 ----

       if (strlen(temp) > 0) {         /* mess with buffer... */

!         /* remove leading spaces and ONE quote... */

!         while (whitespace(temp[0]))
!           temp = (char *) (temp + 1);         /* increment address! */
!         if (temp[0] == '"')
!           temp = (char *) (temp + 1);         /* increment address! */
!         while (whitespace(temp[0]))
           temp = (char *) (temp + 1);         /* increment address! */

!         /* remove trailing spaces and ONE quote... */

         i = strlen(temp) - 1;

!         while (i >= 0 && (whitespace(temp[i])))
!          temp[i--] = '\0';
!         /* Can delete ONE trailing quote, NOT THEM ALL!
!            Assuming the incoming quotes were all right.. [[email protected]] */
!         if (i >= 0 && temp[i] == '"')
!          temp[i--] = '\0';
!         while (i >= 0 && (whitespace(temp[i])))
          temp[i--] = '\0';

         /* if anything is left, let's change 'from' value! */

Index: lib/posixsig.c
Prereq: 5.6
*** ../elm2.4/lib/posixsig.c    Tue Apr 20 21:16:46 1993
--- lib/posixsig.c      Sun Aug 22 22:46:55 1993
***************
*** 1,8 ****

! static char rcsid[] = "@(#)$Id: posixsig.c,v 5.6 1993/04/21 01:16:45 syd Exp $";

 /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.6 $   $State: Exp $
  *
  *                    Copyright (c) 1988-1992 USENET Community Trust
  *                    Copyright (c) 1986,1987 Dave Taylor
--- 1,8 ----

! static char rcsid[] = "@(#)$Id: posixsig.c,v 5.8 1993/08/23 02:46:51 syd Exp $";

 /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.8 $   $State: Exp $
  *
  *                    Copyright (c) 1988-1992 USENET Community Trust
  *                    Copyright (c) 1986,1987 Dave Taylor
***************
*** 14,19 ****
--- 14,27 ----
  *
  *******************************************************************************
  * $Log: posixsig.c,v $
+  * Revision 5.8  1993/08/23  02:46:51  syd
+  * Test ANSI_C, not __STDC__ (which is not set on e.g. AIX).
+  * From: decwrl!uunet.UU.NET!fin!chip (Chip Salzenberg)
+  *
+  * Revision 5.7  1993/08/03  20:14:49  syd
+  * Fix where some systems name SIG_ERR BADSIG
+  * From: Syd
+  *
  * Revision 5.6  1993/04/21  01:16:45  syd
  * SunOS 4.1.3 uses the BSD convention for signal handling in system
  * calls like read. The system call resumes when the signal handler
***************
*** 51,61 ****
 #include "headers.h"

 #ifdef POSIX_SIGNALS
 /*
  * This routine used to duplicate the old signal() calls
  */
 SIGHAND_TYPE
! #if (defined(__STDC__) && !defined(apollo))
 (*posix_signal(signo, fun))(int)
       int signo;
       SIGHAND_TYPE (*fun)(int);
--- 59,78 ----
 #include "headers.h"

 #ifdef POSIX_SIGNALS
+
+ #ifndef SIG_ERR
+ #  ifdef BADSIG
+ #    define SIG_ERR BADSIG
+ #  else
+ #    define SIG_ERR -1
+ #  endif /* BADSIG */
+ #endif /* SIG_ERRR */
+
 /*
  * This routine used to duplicate the old signal() calls
  */
 SIGHAND_TYPE
! #if ANSI_C && !defined(apollo)
 (*posix_signal(signo, fun))(int)
       int signo;
       SIGHAND_TYPE (*fun)(int);

Index: lib/qstrings.c
Prereq: 5.1
*** ../elm2.4/lib/qstrings.c    Sat Oct  3 18:42:28 1992
--- lib/qstrings.c      Tue Aug  3 15:28:56 1993
***************
*** 1,8 ****

! static char rcsid[] = "@(#)$Id: qstrings.c,v 5.1 1992/10/03 22:41:36 syd Exp $";

 /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.1 $   $State: Exp $
  *
  *                    Copyright (c) 1988-1992 USENET Community Trust
  *                    Copyright (c) 1986,1987 Dave Taylor
--- 1,8 ----

! static char rcsid[] = "@(#)$Id: qstrings.c,v 5.2 1993/08/03 19:28:39 syd Exp $";

 /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.2 $   $State: Exp $
  *
  *                    Copyright (c) 1988-1992 USENET Community Trust
  *                    Copyright (c) 1986,1987 Dave Taylor
***************
*** 14,19 ****
--- 14,31 ----
  *
  *******************************************************************************
  * $Log: qstrings.c,v $
+  * Revision 5.2  1993/08/03  19:28:39  syd
+  * Elm tries to replace the system toupper() and tolower() on current
+  * BSD systems, which is unnecessary.  Even worse, the replacements
+  * collide during linking with routines in isctype.o.  This patch adds
+  * a Configure test to determine whether replacements are really needed
+  * (BROKE_CTYPE definition).  The <ctype.h> header file is now included
+  * globally through hdrs/defs.h and the BROKE_CTYPE patchup is handled
+  * there.  Inclusion of <ctype.h> was removed from *all* the individual
+  * files, and the toupper() and tolower() routines in lib/opt_utils.c
+  * were dropped.
+  * From: [email protected] (Chip Rosenthal)
+  *
  * Revision 5.1  1992/10/03  22:41:36  syd
  * Initial checkin as of 2.4 Release at PL0
  *
***************
*** 26,37 ****
 **/

 #include "headers.h"
- #include <ctype.h>
-
- #ifdef BSD
- #undef tolower
- #undef toupper
- #endif

 char *qstrpbrk(source, keys)
 char *source, *keys;
--- 38,43 ----

Index: lib/realfrom.c
Prereq: 5.3
*** ../elm2.4/lib/realfrom.c    Sat May  8 13:09:56 1993
--- lib/realfrom.c      Tue Aug  3 15:28:56 1993
***************
*** 1,8 ****

! static char rcsid[] = "@(#)$Id: realfrom.c,v 5.3 1993/05/08 17:09:56 syd Exp $";

 /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.3 $   $State: Exp $
  *
  *                    Copyright (c) 1993 USENET Community Trust
  *******************************************************************************
--- 1,8 ----

! static char rcsid[] = "@(#)$Id: realfrom.c,v 5.4 1993/08/03 19:28:39 syd Exp $";

 /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.4 $   $State: Exp $
  *
  *                    Copyright (c) 1993 USENET Community Trust
  *******************************************************************************
***************
*** 13,18 ****
--- 13,30 ----
  *
  *******************************************************************************
  * $Log: realfrom.c,v $
+  * Revision 5.4  1993/08/03  19:28:39  syd
+  * Elm tries to replace the system toupper() and tolower() on current
+  * BSD systems, which is unnecessary.  Even worse, the replacements
+  * collide during linking with routines in isctype.o.  This patch adds
+  * a Configure test to determine whether replacements are really needed
+  * (BROKE_CTYPE definition).  The <ctype.h> header file is now included
+  * globally through hdrs/defs.h and the BROKE_CTYPE patchup is handled
+  * there.  Inclusion of <ctype.h> was removed from *all* the individual
+  * files, and the toupper() and tolower() routines in lib/opt_utils.c
+  * were dropped.
+  * From: [email protected] (Chip Rosenthal)
+  *
  * Revision 5.3  1993/05/08  17:09:56  syd
  * Fix problem where "<space>From" was recognized as a valid "From_" line.
  * From: decwrl!decvax!gatech!WLK.COM!chip (Chip Rosenthal)
***************
*** 30,40 ****


 #include "headers.h"
- #include <ctype.h>
-
- #ifdef BSD
- #undef tolower
- #endif


 extern long make_gmttime();
--- 42,47 ----

Index: lib/rfc822tlen.c
*** /dev/null   Sun Sep 19 14:13:21 1993
--- lib/rfc822tlen.c    Mon Jul 19 23:15:24 1993
***************
*** 0 ****
--- 1,155 ----
+
+ static char rcsid[] = "@(#)$Id: rfc822tlen.c,v 5.2 1993/07/20 03:15:15 syd Exp $";
+
+ /*******************************************************************************
+  *  The Elm Mail System  -  $Revision: 5.2 $   $State: Exp $
+  *
+  *                    Copyright (c) 1993 USENET Community Trust
+  *******************************************************************************
+  * Bug reports, patches, comments, suggestions should be sent to:
+  *
+  *    Syd Weinstein, Elm Coordinator
+  *    [email protected]                     dsinc!elm
+  *
+  *******************************************************************************
+  * $Log: rfc822tlen.c,v $
+  * Revision 5.2  1993/07/20  03:15:15  syd
+  * remove extra garbage line
+  *
+  * Revision 5.1  1993/06/10  03:02:20  syd
+  * Initial Checkin
+  *
+  *
+  ******************************************************************************/
+
+ #include <stdio.h>
+
+ /*
+  * rfc822_toklen(str) - Returns length of RFC-822 token that starts at "str".
+  *
+  * We understand the following tokens:
+  *
+  *    linear-white-space
+  *    specials
+  *    "quoted string"
+  *    [domain.literal]
+  *    (comment)
+  *    CTL  (control chars)
+  *    atom
+  */
+
+ #define charlen(s)    ((s)[0] == '\\' && (s)[1] != '\0' ? 2 : 1)
+
+ #define IS822_SPECIAL(c) ( \
+       ((c) == '(') || ((c) == ')') || ((c) == '<') || ((c) == '>') \
+       || ((c) == '@') || ((c) == ',') || ((c) == ';') || ((c) == ':') \
+       || ((c) == '\\') || ((c) == '"') || ((c) == '.') || ((c) == '[') \
+       || ((c) == ']') \
+ )
+
+ /*
+  * RFC-822 defines SPACE to be just < > and HTAB, but after LWSP folding
+  * CR and NL should be equivalent.
+  */
+ #define IS822_SPACE(c) ((c) == ' ' || (c) == '\t' || (c) == '\r' || (c) == '\n')
+
+ /*
+  * We've thrown non-ASCII (value > 0177) into this.
+  */
+ #define IS822_CTL(c)  ((c) <= 037 || (c) >= 0177)
+
+ #define IS822_ATOMCH(c)       (!IS822_SPECIAL(c) && !IS822_SPACE(c) && !IS822_CTL(c))
+
+
+ int rfc822_toklen(str)
+ register char *str;
+ {
+       char *str0;
+       int depth;
+       register int chlen;
+
+       str0 = str;
+
+       if (*str == '"') {                      /* quoted-string */
+               ++str;
+               while (*str != '\0' && *str != '"')
+                       str += charlen(str);
+               if (*str != '\0')
+                       ++str;
+               return (str-str0);
+       }
+
+       if (*str == '(' ) {                     /* comment */
+               ++str;
+               depth = 0;
+               while (*str != '\0' && (*str != ')' || depth > 0)) {
+                       switch (*str) {
+                       case '(':
+                               ++str;
+                               ++depth;
+                               break;
+                       case ')':
+                               ++str;
+                               --depth;
+                               break;
+                       default:
+                               str += charlen(str);
+                               break;
+                       }
+               }
+               if (*str != '\0')
+                       ++str;
+               return (str-str0);
+       }
+
+
+       if (*str == '[') {                      /* domain-literal */
+               ++str;
+               while (*str != '\0' && *str != ']')
+                       str += charlen(str);
+               if (*str != '\0')
+                       ++str;
+               return (str-str0);
+       }
+
+       if (IS822_SPACE(*str)) {                /* linear-white-space */
+               while (++str, IS822_SPACE(*str))
+                       ;
+               return (str-str0);
+       }
+
+       if (IS822_SPECIAL(*str) || IS822_CTL(*str))
+               return charlen(str);            /* specials and CTL */
+
+       /*
+        * Treat as an "atom".
+        */
+       while (IS822_ATOMCH(*str))
+               ++str;
+       return (str-str0);
+ }
+
+
+ #ifdef _TEST
+ main()
+ {
+       char buf[1024], *bp;
+       int len;
+       for (;;) {
+               fputs("\nstr> ", stdout);
+               fflush(stdout);
+               if (gets(buf) == NULL) {
+                       putchar('\n');
+                       break;
+               }
+               bp = buf;
+               while (*bp != '\0') {
+                       len = rfc822_toklen(bp);
+                       printf("len %4d  |%.*s|\n", len, len, bp);
+                       bp += len;
+               }
+       }
+       exit(0);
+ }
+ #endif
+

Index: lib/shiftlower.c
Prereq: 5.1
*** ../elm2.4/lib/shiftlower.c  Sat Oct  3 18:42:29 1992
--- lib/shiftlower.c    Tue Aug  3 15:28:57 1993
***************
*** 1,7 ****
! static char rcsid[] = "@(#)$Id: shiftlower.c,v 5.1 1992/10/03 22:41:36 syd Exp $";

 /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.1 $   $State: Exp $
  *
  *                    Copyright (c) 1988-1992 USENET Community Trust
  *                    Copyright (c) 1986,1987 Dave Taylor
--- 1,7 ----
! static char rcsid[] = "@(#)$Id: shiftlower.c,v 5.2 1993/08/03 19:28:39 syd Exp $";

 /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.2 $   $State: Exp $
  *
  *                    Copyright (c) 1988-1992 USENET Community Trust
  *                    Copyright (c) 1986,1987 Dave Taylor
***************
*** 13,18 ****
--- 13,30 ----
  *
  *******************************************************************************
  * $Log: shiftlower.c,v $
+  * Revision 5.2  1993/08/03  19:28:39  syd
+  * Elm tries to replace the system toupper() and tolower() on current
+  * BSD systems, which is unnecessary.  Even worse, the replacements
+  * collide during linking with routines in isctype.o.  This patch adds
+  * a Configure test to determine whether replacements are really needed
+  * (BROKE_CTYPE definition).  The <ctype.h> header file is now included
+  * globally through hdrs/defs.h and the BROKE_CTYPE patchup is handled
+  * there.  Inclusion of <ctype.h> was removed from *all* the individual
+  * files, and the toupper() and tolower() routines in lib/opt_utils.c
+  * were dropped.
+  * From: [email protected] (Chip Rosenthal)
+  *
  * Revision 5.1  1992/10/03  22:41:36  syd
  * Initial checkin as of 2.4 Release at PL0
  *
***************
*** 25,37 ****

 #include "headers.h"

- #include <ctype.h>
-
- #ifdef BSD
- #undef tolower
- #undef toupper
- #endif
-
 char *shift_lower(string)
 char *string;
 {
--- 37,42 ----
***************
*** 42,51 ****
       register char *bufptr = buffer;

       for (; *string; string++, bufptr++)
!         if (isupper(*string))
!           *bufptr = tolower(*string);
!         else
!           *bufptr = *string;

       *bufptr = 0;

--- 47,53 ----
       register char *bufptr = buffer;

       for (; *string; string++, bufptr++)
!         *bufptr = tolower(*string);

       *bufptr = 0;


Index: lib/strftime.c
Prereq: 5.4
*** ../elm2.4/lib/strftime.c    Sat May  8 15:56:51 1993
--- lib/strftime.c      Sun Aug 22 22:46:56 1993
***************
*** 1,8 ****

! static char rcsid[] = "@(#)$Id: strftime.c,v 5.4 1993/05/08 19:56:45 syd Exp $";

 /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.4 $   $State: Exp $
  *
  * Public-domain relatively quick-and-dirty implemenation of
  * ANSI library routine for System V Unix systems.
--- 1,8 ----

! static char rcsid[] = "@(#)$Id: strftime.c,v 5.8 1993/08/23 02:46:51 syd Exp $";

 /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.8 $   $State: Exp $
  *
  * Public-domain relatively quick-and-dirty implemenation of
  * ANSI library routine for System V Unix systems.
***************
*** 19,24 ****
--- 19,52 ----
  *
  *******************************************************************************
  * $Log: strftime.c,v $
+  * Revision 5.8  1993/08/23  02:46:51  syd
+  * Test ANSI_C, not __STDC__ (which is not set on e.g. AIX).
+  * From: decwrl!uunet.UU.NET!fin!chip (Chip Salzenberg)
+  *
+  * Revision 5.7  1993/08/03  19:28:39  syd
+  * Elm tries to replace the system toupper() and tolower() on current
+  * BSD systems, which is unnecessary.  Even worse, the replacements
+  * collide during linking with routines in isctype.o.  This patch adds
+  * a Configure test to determine whether replacements are really needed
+  * (BROKE_CTYPE definition).  The <ctype.h> header file is now included
+  * globally through hdrs/defs.h and the BROKE_CTYPE patchup is handled
+  * there.  Inclusion of <ctype.h> was removed from *all* the individual
+  * files, and the toupper() and tolower() routines in lib/opt_utils.c
+  * were dropped.
+  * From: [email protected] (Chip Rosenthal)
+  *
+  * Revision 5.6  1993/08/03  19:20:31  syd
+  * Implement new timezone handling.  New file lib/get_tz.c with new timezone
+  * routines.  Added new TZMINS_USE_xxxxxx and TZNAME_USE_xxxxxx configuration
+  * definitions.  Obsoleted TZNAME, ALTCHECK, and TZ_MINUTESWEST configuration
+  * definitions.  Updated Configure.  Modified lib/getarpdate.c and
+  * lib/strftime.c to use new timezone routines.
+  * From: [email protected] (Chip Rosenthal)
+  *
+  * Revision 5.5  1993/06/10  03:17:45  syd
+  * Change from TZNAME_MISSING to TZNAME
+  * From: Syd via request from Dan Blanchard
+  *
  * Revision 5.4  1993/05/08  19:56:45  syd
  * update to newer version
  * From: Syd
***************
*** 79,103 ****
 #ifdef I_SYSTIME
 #  include <sys/time.h>
 #endif
- #ifdef BSD
- #  include <sys/timeb.h>
- #endif

! #include <ctype.h>

! #ifndef __STDC__
! #define const /**/

 #ifndef BSD
! extern void tzset();
! #endif
! static int weeknumber();
! #else /* __STDC__ */
! #ifndef BSD
! extern void tzset(void);
 #endif
! static int weeknumber(const struct tm *timeptr, int firstweekday);
! #endif

 /* defaults: season to taste */
 #define SYSV_EXT      1       /* stuff in System V ascftime routine */
--- 107,126 ----
 #ifdef I_SYSTIME
 #  include <sys/time.h>
 #endif

! #if ANSI_C
! # define P_(x) x
! #else
! # define P_(x) /**/
! # define const        /**/
! #endif

! extern char *get_tz_name();

 #ifndef BSD
! extern void tzset P_((void));
 #endif
! static int weeknumber P_((const struct tm *timeptr, int firstweekday));

 /* defaults: season to taste */
 #define SYSV_EXT      1       /* stuff in System V ascftime routine */
***************
*** 133,146 ****

 #define range(low, item, hi)  maximum(low, minimum(item, hi))

- #ifndef BSD
- extern char *tzname[2];
- extern int daylight;
- #endif
-
 /* minimum --- return minimum of two numbers */

! #ifndef __STDC__
 static inline int
 minimum(a, b)
 int a, b;
--- 156,164 ----

 #define range(low, item, hi)  maximum(low, minimum(item, hi))

 /* minimum --- return minimum of two numbers */

! #if !ANSI_C
 static inline int
 minimum(a, b)
 int a, b;
***************
*** 154,160 ****

 /* maximum --- return maximum of two numbers */

! #ifndef __STDC__
 static inline int
 maximum(a, b)
 int a, b;
--- 172,178 ----

 /* maximum --- return maximum of two numbers */

! #if !ANSI_C
 static inline int
 maximum(a, b)
 int a, b;
***************
*** 168,174 ****

 /* strftime --- produce formatted time */

! #ifndef __STDC__
 size_t
 strftime(s, maxsize, format, timeptr)
 char *s;
--- 186,192 ----

 /* strftime --- produce formatted time */

! #if !ANSI_C
 size_t
 strftime(s, maxsize, format, timeptr)
 char *s;
***************
*** 394,411 ****
                       break;

               case 'Z':       /* time zone name or abbrevation */
!                       i = 0;
!                       if (
! #ifndef TZNAME_MISSING
!                           daylight &&
! #endif
!                           timeptr->tm_isdst)
!                               i = 1;
! #ifdef TZNAME_MISSING
!                       strcpy(tbuf, timeptr->tm_zone);
! #else
!                       strcpy(tbuf, tzname[i]);
! #endif
                       break;

 #ifdef SYSV_EXT
--- 412,418 ----
                       break;

               case 'Z':       /* time zone name or abbrevation */
!                       strcpy(tbuf, get_tz_name(timeptr));
                       break;

 #ifdef SYSV_EXT
***************
*** 528,534 ****
 #ifdef POSIX2_DATE
 /* iso8601wknum --- compute week number according to ISO 8601 */

! #ifndef __STDC__
 static int
 iso8601wknum(timeptr)
 const struct tm *timeptr;
--- 535,541 ----
 #ifdef POSIX2_DATE
 /* iso8601wknum --- compute week number according to ISO 8601 */

! #if !ANSI_C
 static int
 iso8601wknum(timeptr)
 const struct tm *timeptr;
***************
*** 590,596 ****

 /* With thanks and tip of the hatlo to [email protected] */

! #ifndef __STDC__
 static int
 weeknumber(timeptr, firstweekday)
 const struct tm *timeptr;
--- 597,603 ----

 /* With thanks and tip of the hatlo to [email protected] */

! #if !ANSI_C
 static int
 weeknumber(timeptr, firstweekday)
 const struct tm *timeptr;

Index: lib/strincmp.c
Prereq: 5.1
*** ../elm2.4/lib/strincmp.c    Sat Oct  3 18:42:29 1992
--- lib/strincmp.c      Tue Aug  3 15:28:58 1993
***************
*** 1,8 ****

! static char rcsid[] = "@(#)$Id: strincmp.c,v 5.1 1992/10/03 22:41:36 syd Exp $";

 /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.1 $   $State: Exp $
  *
  *                    Copyright (c) 1988-1992 USENET Community Trust
  *                    Copyright (c) 1986,1987 Dave Taylor
--- 1,8 ----

! static char rcsid[] = "@(#)$Id: strincmp.c,v 5.2 1993/08/03 19:28:39 syd Exp $";

 /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.2 $   $State: Exp $
  *
  *                    Copyright (c) 1988-1992 USENET Community Trust
  *                    Copyright (c) 1986,1987 Dave Taylor
***************
*** 14,19 ****
--- 14,31 ----
  *
  *******************************************************************************
  * $Log: strincmp.c,v $
+  * Revision 5.2  1993/08/03  19:28:39  syd
+  * Elm tries to replace the system toupper() and tolower() on current
+  * BSD systems, which is unnecessary.  Even worse, the replacements
+  * collide during linking with routines in isctype.o.  This patch adds
+  * a Configure test to determine whether replacements are really needed
+  * (BROKE_CTYPE definition).  The <ctype.h> header file is now included
+  * globally through hdrs/defs.h and the BROKE_CTYPE patchup is handled
+  * there.  Inclusion of <ctype.h> was removed from *all* the individual
+  * files, and the toupper() and tolower() routines in lib/opt_utils.c
+  * were dropped.
+  * From: [email protected] (Chip Rosenthal)
+  *
  * Revision 5.1  1992/10/03  22:41:36  syd
  * Initial checkin as of 2.4 Release at PL0
  *
***************
*** 24,35 ****
 **/

 #include "headers.h"
- #include <ctype.h>
-
- #ifdef BSD
- #undef tolower
- #undef toupper
- #endif

 int
 strincmp(s1,s2,n)
--- 36,41 ----
***************
*** 39,46 ****
       /* case insensitive comparison */
       register int d;
       while (--n >= 0) {
!         d = ( isupper(*s1) ? tolower(*s1) : *s1 )
!                 - ( isupper(*s2) ? tolower(*s2) : *s2 ) ;
         if ( d != 0 || *s1 == '\0' || *s2 == '\0' )
           return d;
         ++s1;
--- 45,51 ----
       /* case insensitive comparison */
       register int d;
       while (--n >= 0) {
!         d = (tolower(*s1) - tolower(*s2));
         if ( d != 0 || *s1 == '\0' || *s2 == '\0' )
           return d;
         ++s1;

Index: lib/striparens.c
Prereq: 5.1
*** ../elm2.4/lib/striparens.c  Sat Oct  3 18:42:30 1992
--- lib/striparens.c    Wed Jun  9 23:09:06 1993
***************
*** 1,7 ****
! static char rcsid[] = "@(#)$Id: striparens.c,v 5.1 1992/10/03 22:41:36 syd Exp $";

 /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.1 $   $State: Exp $
  *
  *                    Copyright (c) 1988-1992 USENET Community Trust
  *                    Copyright (c) 1986,1987 Dave Taylor
--- 1,7 ----
! static char rcsid[] = "@(#)$Id: striparens.c,v 5.2 1993/06/10 03:09:06 syd Exp $";

 /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.2 $   $State: Exp $
  *
  *                    Copyright (c) 1988-1992 USENET Community Trust
  *                    Copyright (c) 1986,1987 Dave Taylor
***************
*** 13,134 ****
  *
  *******************************************************************************
  * $Log: striparens.c,v $
  * Revision 5.1  1992/10/03  22:41:36  syd
  * Initial checkin as of 2.4 Release at PL0
  *
  *
  ******************************************************************************/

! /**
!
! **/

 #include "headers.h"


! char *strip_parens(string)
! char *string;
 {
!       /**
!           Remove parenthesized information from a string.  More specifically,
!           comments as defined in RFC822 are removed.  This procedure is
!           non-destructive - a pointer to static data is returned.
!       **/
!       static char  buffer[VERY_LONG_STRING];
!       register char *bufp;
!       register int depth, l;
!
!       bufp = buffer;
!       depth = 0;
!       while (*string != '\0') {
!         l = len_next_part(string);
!         if (l == 1) {
!           switch ( *string ) {
!           case '(':                   /* begin comment on '('         */
!             ++depth;
!             break;
!           case ')':                   /* decr nesting level on ')'    */
!             --depth;
!             break;
!           case '\\':                  /* treat next char literally    */
!             if ( *++string == '\0' ) {                /* gracefully handle    */
!               *bufp++ = '\\';                 /* '\' at end of string */
!               --string;                               /* even tho it's wrong  */
!             } else if ( depth == 0 ) {
!               *bufp++ = '\\';
!               *bufp++ = *string;
!             }
!             break;
!           default:                    /* a regular char               */
!             if ( depth == 0 )
!               *bufp++ = *string;
!             break;
!           }
!           string++;
!         } else {
!           if (depth == 0) {
!             while (--l >= 0)
!               *bufp++ = *string++;
!           } else
!             string += l;
!         }
       }
!       *bufp = '\0';
!       return( (char *) buffer);
 }

! /*
!  * Added by RLH.  This could be combined w/ above if willing to pass
!  * a TRUE/FALSE for whether we are stripping or getting...
!  */
! char *get_parens(string)
! char *string;
 {
!       /**
!           Find and return parenthesized information in a string.  More
!           specifically, comments as defined in RFC822 are retrieved.
!           This procedure is non-destructive - a pointer to static data
!           is returned.
!       **/
!       static char  buffer[VERY_LONG_STRING];
!       register char *bufp;
!       register int depth, l;
!
!       bufp = buffer;
!       depth = 0;
!       while (*string != '\0') {
!         l = len_next_part(string);
!         if (l == 1) {
!           switch ( *string ) {
!           case '(':                   /* begin comment on '('         */
!             ++depth;
!             break;
!           case ')':                   /* decr nesting level on ')'    */
!             --depth;
!             break;
!           case '\\':                  /* treat next char literally    */
!             if ( *++string == '\0' ) {                /* gracefully handle    */
!               *bufp++ = '\\';                 /* '\' at end of string */
!               --string;                               /* even tho it's wrong  */
!             } else if ( depth > 0 ) {
!               *bufp++ = '\\';
!               *bufp++ = *string;
!             }
!             break;
!           default:                    /* a regular char               */
!             if ( depth > 0 )
!               *bufp++ = *string;
!             break;
!           }
!           string++;
!         } else {
!           if (depth > 0) {
!             while (--l >= 0)
!               *bufp++ = *string++;
!           } else
!             string += l;
!         }
       }
!       *bufp = '\0';
!       return( (char *) buffer);
 }
--- 13,89 ----
  *
  *******************************************************************************
  * $Log: striparens.c,v $
+  * Revision 5.2  1993/06/10  03:09:06  syd
+  * Greatly simplified "lib/striparens.c" to use new rfc822_toklen() routine.
+  * This cut more than 50% out of the object size.  Also added _TEST case.
+  * From: [email protected] (Chip Rosenthal)
+  *
  * Revision 5.1  1992/10/03  22:41:36  syd
  * Initial checkin as of 2.4 Release at PL0
  *
  *
  ******************************************************************************/

! /*
!  * strip_parens() - Delete all (parenthesized) information from a string.
!  * get_parens() - Extract all (parenthesized) information from a string.
!  *
!  * These routines handle RFC-822 comments.  Nested parens are understood.
!  * get_parens() does not include the parens in the return result.  Both
!  * routines are non-destructive.  They return a pointer to static data
!  * that will be overwritten on the next call to either routine.
!  */

 #include "headers.h"

+ static char paren_buffer[VERY_LONG_STRING];

! char *strip_parens(src)
! register char *src;
 {
!       register int len;
!       register char *dest = paren_buffer;
!
!       while (*src != '\0') {
!               len = rfc822_toklen(src);
!               if (*src != '(') {      /*)*/
!                       strncpy(dest, src, len);
!                       dest += len;
!               }
!               src += len;
       }
!       *dest = '\0';
!       return paren_buffer;
 }

! char *get_parens(src)
! register char *src;
 {
!       register int len;
!       register char *dest = paren_buffer;
!
!       while (*src != '\0') {
!               len = rfc822_toklen(src);
!               if (len > 2 && *src == '(') {   /*)*/
!                       strncpy(dest, src+1, len-2);
!                       dest += (len-2);
!               }
!               src += len;
!       }
!       *dest = '\0';
!       return paren_buffer;
! }
!
! #ifdef _TEST
! main()
! {
!       char buf[1024];
!       while (fputs("\nstr> ", stdout), gets(buf) != NULL) {
!               printf("strip_parens() |%s|\n", strip_parens(buf));
!               printf("get_parens()   |%s|\n", get_parens(buf));
       }
!       putchar('\n');
!       exit(0);
 }
+ #endif
+

Index: lib/strtokq.c
Prereq: 5.2
*** ../elm2.4/lib/strtokq.c     Wed Feb  3 11:20:33 1993
--- lib/strtokq.c       Mon Jul 19 22:05:17 1993
***************
*** 1,8 ****

! static char rcsid[] = "@(#)$Id: strtokq.c,v 5.2 1993/02/03 16:20:30 syd Exp $";

 /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.2 $   $State: Exp $
  *
  *                    Copyright (c) 1988-1992 USENET Community Trust
  *                    Copyright (c) 1986,1987 Dave Taylor
--- 1,8 ----

! static char rcsid[] = "@(#)$Id: strtokq.c,v 5.3 1993/07/20 02:05:17 syd Exp $";

 /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.3 $   $State: Exp $
  *
  *                    Copyright (c) 1988-1992 USENET Community Trust
  *                    Copyright (c) 1986,1987 Dave Taylor
***************
*** 14,19 ****
--- 14,35 ----
  *
  *******************************************************************************
  * $Log: strtokq.c,v $
+  * Revision 5.3  1993/07/20  02:05:17  syd
+  * A long-standing bug of handling replies to VMS systems.
+  * Original "From: " -line is of format:
+  *    From: "NAME \"Real Name\"" <USERNAME@vms-system>
+  * (PMDF mailer)
+  *    Anyway,  parse_arpa_who()  strips quotes too cleanly
+  * resulting data:
+  *    NAME \"Real Name\
+  * which, when put into parenthesis, becomes:
+  *    (NAME \"Real Name\)
+  * which in its turn lacks closing `)'
+  * Patch of  lib/parsarpwho.c  fixes that.
+  * strtokq() started one position too late to search for next double-quote (") char.
+  * Another one-off (chops off trailing comment character, quote or not..)  in   src/reply.c
+  * From:      Matti Aarnio <[email protected]>
+  *
  * Revision 5.2  1993/02/03  16:20:30  syd
  * add include file
  *
***************
*** 54,60 ****
           register char *sp;
           char quote = *sourceptr++;

!           for (sp = sourceptr+1; *sp != '\0' && *sp != quote; sp++)
             if (*sp == '\\') sp++;    /* skip escaped characters */
                                       /* expand_macros will fix them later */

--- 70,76 ----
           register char *sp;
           char quote = *sourceptr++;

!           for (sp = sourceptr; *sp != '\0' && *sp != quote; sp++)
             if (*sp == '\\') sp++;    /* skip escaped characters */
                                       /* expand_macros will fix them later */


Index: nls/C/C/C/s_aliases.m
*** ../elm2.4/nls/C/C/C/s_aliases.m     Sat May  8 13:03:49 1993
--- nls/C/C/C/s_aliases.m       Sat Jun 12 01:26:18 1993
***************
*** 31,37 ****
 $ #MenuLn3
 16    l)imit display, m)ail, n)ew alias, r)eturn, t)ag, u)ndelete, or e(x)it
 $ #Sort
! 17    Sorting messages by %s...
 $ group and person must both be 6 characters long
 $ #Group
 18    " Group"
--- 31,37 ----
 $ #MenuLn3
 16    l)imit display, m)ail, n)ew alias, r)eturn, t)ag, u)ndelete, or e(x)it
 $ #Sort
! 17    Sorting aliases by %s...
 $ group and person must both be 6 characters long
 $ #Group
 18    " Group"

Index: nls/C/C/C/s_answer.m
*** ../elm2.4/nls/C/C/C/s_answer.m      Tue Jan 19 22:36:05 1993
--- nls/C/C/C/s_answer.m        Tue Aug 10 14:53:57 1993
***************
*** 38,44 ****
 $ #EnterMessage
 18    \n\nEnter message for %s ending with a blank line.\n\n
 $ #ElmCommand
! 19    ((%s -s "While You Were Out" %s ; %s %s) & ) < %s > /dev/null
 $ #CannotHaveMoreNames
 20    ** Can't have more than 'FirstName LastName' as address!\n
 $ #NotFoundForGroup
--- 38,44 ----
 $ #EnterMessage
 18    \n\nEnter message for %s ending with a blank line.\n\n
 $ #ElmCommand
! 19    ( ( %s -s "While You Were Out" %s < %s ; %s %s) & ) > /dev/null
 $ #CannotHaveMoreNames
 20    ** Can't have more than 'FirstName LastName' as address!\n
 $ #NotFoundForGroup

Index: nls/C/C/C/s_elm.m
*** ../elm2.4/nls/C/C/C/s_elm.m Mon May 31 15:34:49 1993
--- nls/C/C/C/s_elm.m   Tue Aug  3 14:58:06 1993
***************
*** 1000,1010 ****
--- 1000,1012 ----
 \t -dn\t\tDebug - set debug level to 'n'\n\r\
 \t -fx\t\tFolder - read folder 'x' rather than incoming mailbox\n\r\
 \t -h \t\tHelp - give this list of options\n\r\
+ \t -ix\t\tInclude prepared file 'x' in edit buffer for send\n\r\
 \t -k \t\tKeypad - enable HP 2622 terminal keyboard\n\r
 $ #ArgsHelp2
 536   \t -K \t\tKeypad&softkeys - enable use of softkeys + "-k"\n\r\
 \t -m \t\tMenu - Turn off menu, using more of the screen\n\r\
 \t -sx\t\tSubject 'x' - for batch mailing\n\r\
+ \t -t \t\tTiTe - don't use termcap/terminfo ti/te entries.\n\r\
 \t -V \t\tEnable sendmail voyeur mode.\n\r\
 \t -v \t\tPrint out ELM version information.\n\r\
 \t -z \t\tZero - don't enter ELM if no mail is pending\n\r\
***************
*** 1066,1073 ****
 564   Too many weed headers! Out of memory!  Leaving...\n\r
 $ #NoMemDefaultWeed
 565   \nNot enough memory for default weedlist. Leaving.\n
! $ #CantExpandEnvVar
! 566   \n\rCan't expand environment variable '%s'.\n\r
 $ #CouldntMakeTempFileName
 567   Sorry - couldn't make file temp file name.
 $ #CouldntOpenForWriting
--- 1068,1075 ----
 564   Too many weed headers! Out of memory!  Leaving...\n\r
 $ #NoMemDefaultWeed
 565   \nNot enough memory for default weedlist. Leaving.\n
! $ #CannotInitErrorExpanding
! 566   \r\nCannot initialize "%s" - error expanding "%s".\r\n
 $ #CouldntMakeTempFileName
 567   Sorry - couldn't make file temp file name.
 $ #CouldntOpenForWriting

Index: nls/C/C/C/s_elmalias.m
*** ../elm2.4/nls/C/C/C/s_elmalias.m    Sun Apr 11 22:10:16 1993
--- nls/C/C/C/s_elmalias.m      Tue Aug 10 14:54:55 1993
***************
*** 1,6 ****
 $set 4 #Elmalias
 $ #Usage
! 1     usage: %s [-aenrsuvV] [-f format] [alias ...]\n
 $ #OutOfMemory
 2     %s: out of memory [could not allocate %d bytes]\n
 $ #CannotSpecifyExpand
--- 1,6 ----
 $set 4 #Elmalias
 $ #Usage
! 1     usage: %s [-adenrsuvV] [-f format] [alias ...]\n
 $ #OutOfMemory
 2     %s: out of memory [could not allocate %d bytes]\n
 $ #CannotSpecifyExpand

Index: nls/C/C/C/s_filter.m
*** ../elm2.4/nls/C/C/C/s_filter.m      Mon Feb  8 13:35:25 1993
--- nls/C/C/C/s_filter.m        Tue Aug  3 15:07:36 1993
***************
*** 29,35 ****
 $ #EndMesg
 14    \n-- End of filtered message --\n
 $ #CouldntCreateLockFile
! 15    filter (%s): Couldn't create lock file %s\n
 $ #CantOpenMailBox
 16    filter (%s): Can't open mailbox %s!\n
 $ #SavedMessage
--- 29,35 ----
 $ #EndMesg
 14    \n-- End of filtered message --\n
 $ #CouldntCreateLockFile
! 15    filter (%s): Couldn't create lock file\n
 $ #CantOpenMailBox
 16    filter (%s): Can't open mailbox %s!\n
 $ #SavedMessage

Index: nls/gencat/dumpmsg.c
*** ../elm2.4/nls/gencat/dumpmsg.c      Tue Oct  1 11:42:21 1991
--- nls/gencat/dumpmsg.c        Sun Aug 22 22:46:29 1993
***************
*** 57,63 ****
 }

 void main(
! #if defined(__STDC__) || defined(__cplusplus)
               int argc, char *argv[])
 #else
               argc, argv)
--- 57,63 ----
 }

 void main(
! #if ANSI_C || defined(__cplusplus)
               int argc, char *argv[])
 #else
               argc, argv)

Index: nls/gencat/gencat.c
*** ../elm2.4/nls/gencat/gencat.c       Tue Jun 30 20:56:49 1992
--- nls/gencat/gencat.c Sun Aug 22 22:46:29 1993
***************
*** 65,82 ****
  * will be in C syntax, in bar.H in C++ syntax.
  */

! static void writeIfChanged(
! #if defined(__STDC__) || defined(__cplusplus)
!               char *fname, int lang, int orConsts
 #endif
! );

 void usage() {
!     fprintf(stderr, "Use: gencat [-new] [-or] [-lang C|C++|ANSIC] catfile msgfile [-h <header-file>]...\n");
 }

 void main(
! #if defined(__STDC__) || defined(__cplusplus)
               int argc, char *argv[])
 #else
               argc, argv)
--- 65,87 ----
  * will be in C syntax, in bar.H in C++ syntax.
  */

! #if ANSI_C || defined(__cplusplus)
! # define P_(x) x
! #else
! # define P_(x) /**/
 #endif
!
! static void writeIfChanged P_((char *fname, int lang, int orConsts));
!
! #undef P_

 void usage() {
!     fprintf(stderr, "Use: gencat [-new] [-or] [-lang C|C++|ANSIC]\n");
!     fprintf(stderr, "            catfile msgfile [-h <header-file>]...\n");
 }

 void main(
! #if ANSI_C || defined(__cplusplus)
               int argc, char *argv[])
 #else
               argc, argv)
***************
*** 164,170 ****
 }

 static void writeIfChanged(
! #if defined(__STDC__) || defined(__cplusplus)
               char *fname, int lang, int orConsts)
 #else
               fname, lang, orConsts)
--- 169,175 ----
 }

 static void writeIfChanged(
! #if ANSI_C || defined(__cplusplus)
               char *fname, int lang, int orConsts)
 #else
               fname, lang, orConsts)

Index: nls/gencat/gencat.h
*** ../elm2.4/nls/gencat/gencat.h       Mon Sep 23 15:47:46 1991
--- nls/gencat/gencat.h Sun Aug 22 22:46:29 1993
***************
*** 79,125 ****

 #define MAXTOKEN      1024

! extern void MCAddSet(
! #if defined(__STDC__) || defined(__cplusplus)
!               int setId, char *c
 #endif
!               );
! extern void MCDelSet(
! #if defined(__STDC__) || defined(__cplusplus)
!               int setId
! #endif
!               );
! extern void MCAddMsg(
! #if defined(__STDC__) || defined(__cplusplus)
!               int msgId, char *msg, char *c
! #endif
!               );
! extern void MCDelMsg(
! #if defined(__STDC__) || defined(__cplusplus)
!               int msgId
! #endif
!               );
! extern void MCParse(
! #if defined(__STDC__) || defined(__cplusplus)
!               int fd
! #endif
!               );
! extern void MCReadCat(
! #if defined(__STDC__) || defined(__cplusplus)
!               int fd
! #endif
!               );
! extern void MCWriteConst(
! #if defined(__STDC__) || defined(__cplusplus)
!               int fd, int type, int orConsts
! #endif
!               );
! extern void MCWriteCat(
! #if defined(__STDC__) || defined(__cplusplus)
!               int fd
 #endif
!               );
! extern long MCGetByteOrder();

 #ifndef True
 # define True         ~0
--- 79,103 ----

 #define MAXTOKEN      1024

! #if !defined(ANSI_C) && (defined(__STDC__) || defined(_AIX))
! # define ANSI_C 1
 #endif
!
! #if ANSI_C || defined(__cplusplus)
! # define P_(x) x
! #else
! # define P_(x) /**/
 #endif
!
! extern void MCAddSet P_((int setId, char *c));
! extern void MCDelSet P_((int setId));
! extern void MCAddMsg P_((int msgId, char *msg, char *c));
! extern void MCDelMsg P_((int msgId));
! extern void MCParse P_((int fd));
! extern void MCReadCat P_((int fd));
! extern void MCWriteConst P_((int fd, int type, int orConsts));
! extern void MCWriteCat P_((int fd));
! extern long MCGetByteOrder P_((void));

 #ifndef True
 # define True         ~0

Index: src/a_sort.c
Prereq: 5.4
*** ../elm2.4/src/a_sort.c      Sun Apr 11 21:10:15 1993
--- src/a_sort.c        Sat Jun 12 01:27:55 1993
***************
*** 1,8 ****

! static char rcsid[] = "@(#)$Id: a_sort.c,v 5.4 1993/04/12 01:10:15 syd Exp $";

 /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.4 $   $State: Exp $
  *
  *                    Copyright (c) 1988-1992 USENET Community Trust
  *                    Copyright (c) 1986,1987 Dave Taylor
--- 1,8 ----

! static char rcsid[] = "@(#)$Id: a_sort.c,v 5.5 1993/06/12 05:27:44 syd Exp $";

 /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.5 $   $State: Exp $
  *
  *                    Copyright (c) 1988-1992 USENET Community Trust
  *                    Copyright (c) 1986,1987 Dave Taylor
***************
*** 14,19 ****
--- 14,23 ----
  *
  *******************************************************************************
  * $Log: a_sort.c,v $
+  * Revision 5.5  1993/06/12  05:27:44  syd
+  * Fix calling sequence error
+  * From: Syd
+  *
  * Revision 5.4  1993/04/12  01:10:15  syd
  * fix @aliasname sort problem
  * From: "Robert L. Howard" <[email protected]>
***************
*** 75,81 ****

       if ((entries > 30) && visible && are_in_aliases) {
           error1(catgets(elm_msg_cat, AliasesSet, AliasesSort,
!                   "Sorting messages by %s..."), alias_sort_name(FULL));
       }

       if (entries > 1)
--- 79,85 ----

       if ((entries > 30) && visible && are_in_aliases) {
           error1(catgets(elm_msg_cat, AliasesSet, AliasesSort,
!                   "Sorting aliases by %s..."), alias_sort_name(FULL));
       }

       if (entries > 1)

Index: src/addr_util.c
Prereq: 5.10
*** ../elm2.4/src/addr_util.c   Mon May 31 15:32:21 1993
--- src/addr_util.c     Tue Aug  3 15:28:59 1993
***************
*** 1,8 ****

! static char rcsid[] = "@(#)$Id: addr_util.c,v 5.10 1993/05/31 19:32:20 syd Exp $";

 /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.10 $   $State: Exp $
  *
  *                    Copyright (c) 1988-1992 USENET Community Trust
  *                    Copyright (c) 1986,1987 Dave Taylor
--- 1,8 ----

! static char rcsid[] = "@(#)$Id: addr_util.c,v 5.11 1993/08/03 19:28:39 syd Exp $";

 /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.11 $   $State: Exp $
  *
  *                    Copyright (c) 1988-1992 USENET Community Trust
  *                    Copyright (c) 1986,1987 Dave Taylor
***************
*** 14,19 ****
--- 14,31 ----
  *
  *******************************************************************************
  * $Log: addr_util.c,v $
+  * Revision 5.11  1993/08/03  19:28:39  syd
+  * Elm tries to replace the system toupper() and tolower() on current
+  * BSD systems, which is unnecessary.  Even worse, the replacements
+  * collide during linking with routines in isctype.o.  This patch adds
+  * a Configure test to determine whether replacements are really needed
+  * (BROKE_CTYPE definition).  The <ctype.h> header file is now included
+  * globally through hdrs/defs.h and the BROKE_CTYPE patchup is handled
+  * there.  Inclusion of <ctype.h> was removed from *all* the individual
+  * files, and the toupper() and tolower() routines in lib/opt_utils.c
+  * were dropped.
+  * From: [email protected] (Chip Rosenthal)
+  *
  * Revision 5.10  1993/05/31  19:32:20  syd
  * With this patch build_address() should treat local mailing
  * lists and other aliases known by the transport agent as valid
***************
*** 80,92 ****
 #include "headers.h"
 #include "s_elm.h"

- #include <ctype.h>
-
- #ifdef BSD
- #undef tolower
- #undef toupper
- #endif
-

 translate_return(addr, ret_addr)
 char *addr, *ret_addr;
--- 92,97 ----

Index: src/alias.c
Prereq: 5.34
*** ../elm2.4/src/alias.c       Thu May 13 23:57:37 1993
--- src/alias.c Tue Aug  3 15:29:00 1993
***************
*** 1,8 ****

! static char rcsid[] = "@(#)$Id: alias.c,v 5.34 1993/05/14 03:57:36 syd Exp $";

 /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.34 $   $State: Exp $
  *
  *                    Copyright (c) 1988-1992 USENET Community Trust
  *                    Copyright (c) 1986,1987 Dave Taylor
--- 1,8 ----

! static char rcsid[] = "@(#)$Id: alias.c,v 5.37 1993/08/03 19:28:39 syd Exp $";

 /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.37 $   $State: Exp $
  *
  *                    Copyright (c) 1988-1992 USENET Community Trust
  *                    Copyright (c) 1986,1987 Dave Taylor
***************
*** 14,19 ****
--- 14,42 ----
  *
  *******************************************************************************
  * $Log: alias.c,v $
+  * Revision 5.37  1993/08/03  19:28:39  syd
+  * Elm tries to replace the system toupper() and tolower() on current
+  * BSD systems, which is unnecessary.  Even worse, the replacements
+  * collide during linking with routines in isctype.o.  This patch adds
+  * a Configure test to determine whether replacements are really needed
+  * (BROKE_CTYPE definition).  The <ctype.h> header file is now included
+  * globally through hdrs/defs.h and the BROKE_CTYPE patchup is handled
+  * there.  Inclusion of <ctype.h> was removed from *all* the individual
+  * files, and the toupper() and tolower() routines in lib/opt_utils.c
+  * were dropped.
+  * From: [email protected] (Chip Rosenthal)
+  *
+  * Revision 5.36  1993/06/12  05:27:44  syd
+  * Fix calling sequence error
+  * From: Syd
+  *
+  * Revision 5.35  1993/06/10  02:58:26  syd
+  * Correct problem in fetch_alias() with alias record fixup that caused
+  * core dump on machines with pointers larger than int.  This problem
+  * was reported on comp.mail.elm by Richard Eckman and Jim Brown.  Simplify
+  * get_one_alias() by having it use fetch_alias().
+  * From: [email protected] (Chip Rosenthal)
+  *
  * Revision 5.34  1993/05/14  03:57:36  syd
  * A couple of calls to want_to() had typos. Here is the patch.
  * From: Jukka Ukkonen <[email protected]>
***************
*** 230,244 ****
 #include "headers.h"
 #include "s_elm.h"
 #include <errno.h>
- #include <ctype.h>
 #include <sys/stat.h>
 #include "s_aliases.h"
 #include "ndbz.h"

- #ifdef BSD
- #undef        tolower
- #endif
-
 #define       ECHOIT  1       /* echo on for prompting */

 /*
--- 253,262 ----
***************
*** 984,990 ****

       main_state();           /* Save globals for return to main menu */

!       open_alias_files();     /* First, read the alias files. RLH */

       alias_screen(newaliases);
       define_softkeys(ALIAS);
--- 1002,1008 ----

       main_state();           /* Save globals for return to main menu */

!       open_alias_files(FALSE);        /* First, read the alias files. RLH */

       alias_screen(newaliases);
       define_softkeys(ALIAS);
***************
*** 1305,1311 ****
                 "Processed %d aliases.  Re-reading the database..."), na);
           if (sleepmsg > 0)
               sleep(sleepmsg);
!           open_alias_files();
           set_error(catgets(elm_msg_cat, AliasesSet, AliasesUpdatedOK,
                 "Aliases updated successfully."));
       }
--- 1323,1329 ----
                 "Processed %d aliases.  Re-reading the database..."), na);
           if (sleepmsg > 0)
               sleep(sleepmsg);
!           open_alias_files(TRUE);
           set_error(catgets(elm_msg_cat, AliasesSet, AliasesUpdatedOK,
                 "Aliases updated successfully."));
       }
***************
*** 1537,1610 ****
  *    Get an alias (name, address, etc.) from the data file
  */

!       long new_max;
!       register struct alias_rec       **new_aliases, *a;
!       struct alias_rec        ar;
!       FILE *data_file = db->dbz_basef;

!       if(read_one_alias(db, &ar) == 0) {
!           return(0);
!       }

       if (current >= max_aliases) {
           new_max = max_aliases + KLICK;
!           if (max_aliases == 0)
!               new_aliases = (struct alias_rec **)
!                   malloc(new_max * sizeof(struct alias_rec *));
!           else
!               new_aliases = (struct alias_rec **)
!                   realloc((char *) aliases,
!                       new_max * sizeof(struct alias_rec *));
!
!           if (new_aliases == NULL) {
!               error1(catgets(elm_msg_cat, AliasesSet, AliasesErrorMemory,
!       "\n\r\n\rCouldn't allocate enough memory! Alias #%d.\n\r\n\r"),
!                       current);
!               return(0);
           }
-           aliases = new_aliases;
           while (max_aliases < new_max)
               aliases[max_aliases++] = NULL;
       }

!
!       if (aliases[current] != NULL) {
!           free((char *) aliases[current]);
!           aliases[current] = NULL;
!       }
!
!       if ((a = (struct alias_rec *)
!               malloc(sizeof(ar) + ar.length)) == NULL) {
!               error1(catgets(elm_msg_cat, AliasesSet, AliasesErrorMemory,
!       "\n\r\n\rCouldn't allocate enough memory! Alias #%d.\n\r\n\r"),
!                       current);
!               return(0);
!           }
!
       aliases[current] = a;
!       fread((char *) (a + 1), ar.length, 1, data_file);
!       *a = ar;
! #ifdef CRAY
!       a->alias = (int) a->alias + (char *) (a + 1);
!       a->last_name = (int) a->last_name + (char *) (a + 1);
!       a->name = (int) a->name + (char *) (a + 1);
!       a->comment = (int) a->comment + (char *) (a + 1);
!       a->address = (int) a->address + (char *) (a + 1);
! #else
!       new_max = (long) (a + 1);
!
!       a->alias += new_max;
!       a->last_name += new_max;
!       a->name += new_max;
!       a->comment += new_max;
!       a->address += new_max;
! #endif
!       a->length = current;
!
!
!       return(1);
 }

 main_state()
 {
 /*    Save the globals that are shared for both menus
--- 1555,1587 ----
  *    Get an alias (name, address, etc.) from the data file
  */

!       int new_max;
!       register struct alias_rec *a;
!       extern struct alias_rec *fetch_alias();

!       if ((a = fetch_alias(db, (char *)NULL)) == NULL)
!           return 0;

       if (current >= max_aliases) {
           new_max = max_aliases + KLICK;
!           if (max_aliases == 0) {
!               aliases = (struct alias_rec **)
!                   safe_malloc(new_max * sizeof(struct alias_rec *));
!           } else {
!               aliases = (struct alias_rec **) safe_realloc((malloc_t)aliases,
!                   new_max * sizeof(struct alias_rec *));
           }
           while (max_aliases < new_max)
               aliases[max_aliases++] = NULL;
       }

!       if (aliases[current] != NULL)
!           free((malloc_t)aliases[current]);
       aliases[current] = a;
!       return 1;
 }

+
 main_state()
 {
 /*    Save the globals that are shared for both menus

Index: src/aliaslib.c
Prereq: 5.9
*** ../elm2.4/src/aliaslib.c    Mon May 31 15:39:44 1993
--- src/aliaslib.c      Tue Aug  3 15:29:01 1993
***************
*** 1,8 ****

! static char rcsid[] = "@(#)$Id: aliaslib.c,v 5.9 1993/05/31 19:39:43 syd Exp $";

 /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.9 $   $State: Exp $
  *
  *                    Copyright (c) 1988-1992 USENET Community Trust
  *                    Copyright (c) 1986,1987 Dave Taylor
--- 1,8 ----

! static char rcsid[] = "@(#)$Id: aliaslib.c,v 5.10 1993/08/03 19:28:39 syd Exp $";

 /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.10 $   $State: Exp $
  *
  *                    Copyright (c) 1988-1992 USENET Community Trust
  *                    Copyright (c) 1986,1987 Dave Taylor
***************
*** 14,19 ****
--- 14,31 ----
  *
  *******************************************************************************
  * $Log: aliaslib.c,v $
+  * Revision 5.10  1993/08/03  19:28:39  syd
+  * Elm tries to replace the system toupper() and tolower() on current
+  * BSD systems, which is unnecessary.  Even worse, the replacements
+  * collide during linking with routines in isctype.o.  This patch adds
+  * a Configure test to determine whether replacements are really needed
+  * (BROKE_CTYPE definition).  The <ctype.h> header file is now included
+  * globally through hdrs/defs.h and the BROKE_CTYPE patchup is handled
+  * there.  Inclusion of <ctype.h> was removed from *all* the individual
+  * files, and the toupper() and tolower() routines in lib/opt_utils.c
+  * were dropped.
+  * From: [email protected] (Chip Rosenthal)
+  *
  * Revision 5.9  1993/05/31  19:39:43  syd
  * Elm either failed to expand a group alias or crashed in strlen
  * (called from do_expand_group()).
***************
*** 70,76 ****

 #include "headers.h"
 #include "s_elm.h"
- #include <ctype.h>

 char *get_alias_address(), *qstrpbrk();
 extern int current_mail_message;
--- 82,87 ----

Index: src/builtin.c
Prereq: 5.1
*** ../elm2.4/src/builtin.c     Sat Oct  3 18:58:47 1992
--- src/builtin.c       Tue Aug  3 15:29:01 1993
***************
*** 1,8 ****

! static char rcsid[] = "@(#)$Id: builtin.c,v 5.1 1992/10/03 22:58:40 syd Exp $";

 /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.1 $   $State: Exp $
  *
  *                    Copyright (c) 1988-1992 USENET Community Trust
  *                    Copyright (c) 1986,1987 Dave Taylor
--- 1,8 ----

! static char rcsid[] = "@(#)$Id: builtin.c,v 5.2 1993/08/03 19:28:39 syd Exp $";

 /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.2 $   $State: Exp $
  *
  *                    Copyright (c) 1988-1992 USENET Community Trust
  *                    Copyright (c) 1986,1987 Dave Taylor
***************
*** 14,19 ****
--- 14,31 ----
  *
  *******************************************************************************
  * $Log: builtin.c,v $
+  * Revision 5.2  1993/08/03  19:28:39  syd
+  * Elm tries to replace the system toupper() and tolower() on current
+  * BSD systems, which is unnecessary.  Even worse, the replacements
+  * collide during linking with routines in isctype.o.  This patch adds
+  * a Configure test to determine whether replacements are really needed
+  * (BROKE_CTYPE definition).  The <ctype.h> header file is now included
+  * globally through hdrs/defs.h and the BROKE_CTYPE patchup is handled
+  * there.  Inclusion of <ctype.h> was removed from *all* the individual
+  * files, and the toupper() and tolower() routines in lib/opt_utils.c
+  * were dropped.
+  * From: [email protected] (Chip Rosenthal)
+  *
  * Revision 5.1  1992/10/03  22:58:40  syd
  * Initial checkin as of 2.4 Release at PL0
  *
***************
*** 32,38 ****

 #include "headers.h"
 #include "s_elm.h"
- #include <ctype.h>

 #define  BEEP         007             /* ASCII Bell character */

--- 44,49 ----