From 9a33ff618b5901a3af815650d4b84d39ee96e529 Mon Sep 17 00:00:00 2001 From: Josh Bressers Date: Fri, 6 Jan 2006 21:51:43 +0000 Subject: [PATCH] * patch #3968: Move the add() function from its own file (add.c) and into utils.c. There was also a duplicate add() function in mf.c which has been removed. --- ChangeLog | 6 ++++++ h/prototypes.h | 1 - h/utils.h | 1 + sbr/Makefile.in | 2 +- sbr/add.c | 48 ------------------------------------------------ sbr/mf.c | 15 --------------- sbr/seq_read.c | 1 + sbr/utils.c | 37 +++++++++++++++++++++++++++++++++++++ uip/ali.c | 1 + uip/distsbr.c | 1 + uip/mhbuild.c | 1 + uip/mhcachesbr.c | 1 + uip/mhlistsbr.c | 1 + uip/mhmail.c | 1 + uip/mhmisc.c | 1 + uip/mhshowsbr.c | 1 + uip/mhstoresbr.c | 1 + uip/picksbr.c | 1 + uip/post.c | 1 + uip/repl.c | 1 + uip/show.c | 1 + uip/slocal.c | 1 + uip/spost.c | 1 + 23 files changed, 61 insertions(+), 65 deletions(-) delete mode 100644 sbr/add.c diff --git a/ChangeLog b/ChangeLog index 1c2fc9d..46d2bdb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-01-06 Josh Bressers + + * patch #3968: Move the add() function from its own file (add.c) and + into utils.c. There was also a duplicate add() function in mf.c which + has been removed. + 2006-01-02 Josh Bressers * Remove sbr/pwd.c file, moving the pwd() function into sbr/utils.c. diff --git a/h/prototypes.h b/h/prototypes.h index fe41962..d53d663 100644 --- a/h/prototypes.h +++ b/h/prototypes.h @@ -25,7 +25,6 @@ char *etcpath(char *); /* * prototypes from the nmh subroutine library */ -char *add (char *, char *); void adios (char *, char *, ...); void admonish (char *, char *, ...); void advertise (char *, char *, char *, va_list); diff --git a/h/utils.h b/h/utils.h index 60e26e5..542baec 100644 --- a/h/utils.h +++ b/h/utils.h @@ -8,3 +8,4 @@ void *mh_xmalloc(size_t); void *mh_xrealloc(void *, size_t); char *pwd(void); +char *add(char *, char *); diff --git a/sbr/Makefile.in b/sbr/Makefile.in index 5f73e0f..d6c2796 100644 --- a/sbr/Makefile.in +++ b/sbr/Makefile.in @@ -52,7 +52,7 @@ COMPILE2 = $(CC) -c $(DEFS) $(CONFIGDEFS) $(INCLUDES) $(KRB4_INCLUDES) $(HESIOD_ SIGNAL_H = @SIGNAL_H@ # source for library functions -SRCS = add.c addrsbr.c ambigsw.c atooi.c brkstring.c \ +SRCS = addrsbr.c ambigsw.c atooi.c brkstring.c \ check_charset.c client.c closefds.c concat.c context_del.c \ context_find.c context_foil.c context_read.c \ context_replace.c context_save.c copy.c \ diff --git a/sbr/add.c b/sbr/add.c deleted file mode 100644 index 40201c1..0000000 --- a/sbr/add.c +++ /dev/null @@ -1,48 +0,0 @@ - -/* - * add.c -- If "s1" is NULL, this routine just creates a - * -- copy of "s2" into newly malloc'ed memory. - * -- - * -- If "s1" is not NULL, then copy the concatenation - * -- of "s1" and "s2" (note the order) into newly - * -- malloc'ed memory. Then free "s1". - * - * $Id$ - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ - -#include -#include - -char * -add (char *s2, char *s1) -{ - char *cp; - size_t len1 = 0, len2 = 0; - - if (s1) - len1 = strlen (s1); - if (s2) - len2 = strlen (s2); - - - cp = mh_xmalloc (len1 + len2 + 1); - - /* Copy s1 and free it */ - if (s1) { - memcpy (cp, s1, len1); - free (s1); - } - - /* Copy s2 */ - if (s2) - memcpy (cp + len1, s2, len2); - - /* Now NULL terminate the string */ - cp[len1 + len2] = '\0'; - - return cp; -} diff --git a/sbr/mf.c b/sbr/mf.c index 518a184..44dab8a 100644 --- a/sbr/mf.c +++ b/sbr/mf.c @@ -18,7 +18,6 @@ * static prototypes */ static char *getcpy (char *); -static char *add (char *, char *); static void compress (char *, char *); static int isat (char *); static int parse_address (void); @@ -49,20 +48,6 @@ getcpy (char *s) } -static char * -add (char *s1, char *s2) -{ - register char *p; - - if (!s2) - return getcpy (s1); - - p = mh_xmalloc ((size_t) (strlen (s1) + strlen (s2) + 2)); - sprintf (p, "%s%s", s2, s1); - free (s2); - return p; -} - int isfrom(char *string) { diff --git a/sbr/seq_read.c b/sbr/seq_read.c index f36edb5..c18d1da 100644 --- a/sbr/seq_read.c +++ b/sbr/seq_read.c @@ -11,6 +11,7 @@ */ #include +#include /* * static prototypes diff --git a/sbr/utils.c b/sbr/utils.c index 2120b84..8741b20 100644 --- a/sbr/utils.c +++ b/sbr/utils.c @@ -74,3 +74,40 @@ pwd(void) return curwd; } + +/* + * add -- If "s1" is NULL, this routine just creates a + * -- copy of "s2" into newly malloc'ed memory. + * -- + * -- If "s1" is not NULL, then copy the concatenation + * -- of "s1" and "s2" (note the order) into newly + * -- malloc'ed memory. Then free "s1". + */ +char * +add (char *s2, char *s1) +{ + char *cp; + size_t len1 = 0, len2 = 0; + + if (s1) + len1 = strlen (s1); + if (s2) + len2 = strlen (s2); + + cp = mh_xmalloc (len1 + len2 + 1); + + /* Copy s1 and free it */ + if (s1) { + memcpy (cp, s1, len1); + free (s1); + } + + /* Copy s2 */ + if (s2) + memcpy (cp + len1, s2, len2); + + /* Now NULL terminate the string */ + cp[len1 + len2] = '\0'; + + return cp; +} diff --git a/uip/ali.c b/uip/ali.c index c600387..737f68c 100644 --- a/uip/ali.c +++ b/uip/ali.c @@ -13,6 +13,7 @@ #include #include #include +#include /* * maximum number of names diff --git a/uip/distsbr.c b/uip/distsbr.c index bda98c8..0191037 100644 --- a/uip/distsbr.c +++ b/uip/distsbr.c @@ -11,6 +11,7 @@ #include #include +#include static int hdrfd = NOTOK; static int txtfd = NOTOK; diff --git a/uip/mhbuild.c b/uip/mhbuild.c index b16e8c9..1c5abdc 100644 --- a/uip/mhbuild.c +++ b/uip/mhbuild.c @@ -20,6 +20,7 @@ #include #include #include +#include #ifdef HAVE_SYS_WAIT_H # include diff --git a/uip/mhcachesbr.c b/uip/mhcachesbr.c index 56d3dcc..ba66f6e 100644 --- a/uip/mhcachesbr.c +++ b/uip/mhcachesbr.c @@ -21,6 +21,7 @@ #include #include #include +#include #ifdef TIME_WITH_SYS_TIME # include diff --git a/uip/mhlistsbr.c b/uip/mhlistsbr.c index bce44d0..10ec55d 100644 --- a/uip/mhlistsbr.c +++ b/uip/mhlistsbr.c @@ -19,6 +19,7 @@ #include #include #include +#include /* mhmisc.c */ int part_ok (CT, int); diff --git a/uip/mhmail.c b/uip/mhmail.c index d74a7f1..b5da86c 100644 --- a/uip/mhmail.c +++ b/uip/mhmail.c @@ -11,6 +11,7 @@ #include #include +#include #include static struct swit switches[] = { diff --git a/uip/mhmisc.c b/uip/mhmisc.c index a3da759..9f0044a 100644 --- a/uip/mhmisc.c +++ b/uip/mhmisc.c @@ -13,6 +13,7 @@ #include #include #include +#include extern int debugsw; diff --git a/uip/mhshowsbr.c b/uip/mhshowsbr.c index 1c786cc..08d676e 100644 --- a/uip/mhshowsbr.c +++ b/uip/mhshowsbr.c @@ -20,6 +20,7 @@ #include #include #include +#include #ifdef HAVE_SYS_WAIT_H # include diff --git a/uip/mhstoresbr.c b/uip/mhstoresbr.c index 72694b6..519e481 100644 --- a/uip/mhstoresbr.c +++ b/uip/mhstoresbr.c @@ -20,6 +20,7 @@ #include #include #include +#include /* diff --git a/uip/picksbr.c b/uip/picksbr.c index 71ae644..1154f46 100644 --- a/uip/picksbr.c +++ b/uip/picksbr.c @@ -12,6 +12,7 @@ #include #include #include +#include #ifdef TIME_WITH_SYS_TIME # include diff --git a/uip/post.c b/uip/post.c index aff49a0..2fe45a1 100644 --- a/uip/post.c +++ b/uip/post.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include diff --git a/uip/repl.c b/uip/repl.c index b1c0782..e5fa527 100644 --- a/uip/repl.c +++ b/uip/repl.c @@ -10,6 +10,7 @@ */ #include +#include static struct swit switches[] = { diff --git a/uip/show.c b/uip/show.c index 5773b56..b068d49 100644 --- a/uip/show.c +++ b/uip/show.c @@ -11,6 +11,7 @@ #include #include +#include static struct swit switches[] = { #define CHECKMIMESW 0 diff --git a/uip/slocal.c b/uip/slocal.c index 993a141..e51f869 100644 --- a/uip/slocal.c +++ b/uip/slocal.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include diff --git a/uip/spost.c b/uip/spost.c index 5a7d943..e2b43bd 100644 --- a/uip/spost.c +++ b/uip/spost.c @@ -19,6 +19,7 @@ #include #include #include +#include #define uptolow(c) ((isalpha(c) && isupper (c)) ? tolower (c) : c) -- 1.7.10.4