* patch #3968: Move the add() function from its own file (add.c) and
authorJosh Bressers <josh@bress.net>
Fri, 6 Jan 2006 21:51:43 +0000 (21:51 +0000)
committerJosh Bressers <josh@bress.net>
Fri, 6 Jan 2006 21:51:43 +0000 (21:51 +0000)
  into utils.c. There was also a duplicate add() function in mf.c which
  has been removed.

23 files changed:
ChangeLog
h/prototypes.h
h/utils.h
sbr/Makefile.in
sbr/add.c [deleted file]
sbr/mf.c
sbr/seq_read.c
sbr/utils.c
uip/ali.c
uip/distsbr.c
uip/mhbuild.c
uip/mhcachesbr.c
uip/mhlistsbr.c
uip/mhmail.c
uip/mhmisc.c
uip/mhshowsbr.c
uip/mhstoresbr.c
uip/picksbr.c
uip/post.c
uip/repl.c
uip/show.c
uip/slocal.c
uip/spost.c

index 1c2fc9d..46d2bdb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-01-06  Josh Bressers <josh@bress.net>
+
+       * 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 <josh@bress.net>
 
        * Remove sbr/pwd.c file, moving the pwd() function into sbr/utils.c.
 2006-01-02  Josh Bressers <josh@bress.net>
 
        * Remove sbr/pwd.c file, moving the pwd() function into sbr/utils.c.
index fe41962..d53d663 100644 (file)
@@ -25,7 +25,6 @@ char *etcpath(char *);
 /*
  * prototypes from the nmh subroutine library
  */
 /*
  * 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);
 void adios (char *, char *, ...);
 void admonish (char *, char *, ...);
 void advertise (char *, char *, char *, va_list);
index 60e26e5..542baec 100644 (file)
--- 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);
 void *mh_xmalloc(size_t);
 void *mh_xrealloc(void *, size_t);
 char *pwd(void);
+char *add(char *, char *);
index 5f73e0f..d6c2796 100644 (file)
@@ -52,7 +52,7 @@ COMPILE2 = $(CC) -c $(DEFS) $(CONFIGDEFS) $(INCLUDES) $(KRB4_INCLUDES) $(HESIOD_
 SIGNAL_H = @SIGNAL_H@
 
 # source for library functions
 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                         \
        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 (file)
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 <h/mh.h>
-#include <h/utils.h>
-
-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;
-}
index 518a184..44dab8a 100644 (file)
--- a/sbr/mf.c
+++ b/sbr/mf.c
@@ -18,7 +18,6 @@
  * static prototypes
  */
 static char *getcpy (char *);
  * 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);
 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)
 {
 int
 isfrom(char *string)
 {
index f36edb5..c18d1da 100644 (file)
@@ -11,6 +11,7 @@
  */
 
 #include <h/mh.h>
  */
 
 #include <h/mh.h>
+#include <h/utils.h>
 
 /*
  * static prototypes
 
 /*
  * static prototypes
index 2120b84..8741b20 100644 (file)
@@ -74,3 +74,40 @@ pwd(void)
 
     return curwd;
 }
 
     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;
+}
index c600387..737f68c 100644 (file)
--- a/uip/ali.c
+++ b/uip/ali.c
@@ -13,6 +13,7 @@
 #include <h/addrsbr.h>
 #include <h/aliasbr.h>
 #include <h/mts.h>
 #include <h/addrsbr.h>
 #include <h/aliasbr.h>
 #include <h/mts.h>
+#include <h/utils.h>
 
 /*
  * maximum number of names
 
 /*
  * maximum number of names
index bda98c8..0191037 100644 (file)
@@ -11,6 +11,7 @@
 
 #include <h/mh.h>
 #include <fcntl.h>
 
 #include <h/mh.h>
 #include <fcntl.h>
+#include <h/utils.h>
 
 static int  hdrfd = NOTOK;
 static int  txtfd = NOTOK;
 
 static int  hdrfd = NOTOK;
 static int  txtfd = NOTOK;
index b16e8c9..1c5abdc 100644 (file)
@@ -20,6 +20,7 @@
 #include <h/mime.h>
 #include <h/mhparse.h>
 #include <h/mhcachesbr.h>
 #include <h/mime.h>
 #include <h/mhparse.h>
 #include <h/mhcachesbr.h>
+#include <h/utils.h>
 
 #ifdef HAVE_SYS_WAIT_H
 # include <sys/wait.h>
 
 #ifdef HAVE_SYS_WAIT_H
 # include <sys/wait.h>
index 56d3dcc..ba66f6e 100644 (file)
@@ -21,6 +21,7 @@
 #include <h/mime.h>
 #include <h/mhparse.h>
 #include <h/mhcachesbr.h>
 #include <h/mime.h>
 #include <h/mhparse.h>
 #include <h/mhcachesbr.h>
+#include <h/utils.h>
 
 #ifdef TIME_WITH_SYS_TIME
 # include <sys/time.h>
 
 #ifdef TIME_WITH_SYS_TIME
 # include <sys/time.h>
index bce44d0..10ec55d 100644 (file)
@@ -19,6 +19,7 @@
 #include <h/tws.h>
 #include <h/mime.h>
 #include <h/mhparse.h>
 #include <h/tws.h>
 #include <h/mime.h>
 #include <h/mhparse.h>
+#include <h/utils.h>
 
 /* mhmisc.c */
 int part_ok (CT, int);
 
 /* mhmisc.c */
 int part_ok (CT, int);
index d74a7f1..b5da86c 100644 (file)
@@ -11,6 +11,7 @@
 
 #include <h/mh.h>
 #include <h/signals.h>
 
 #include <h/mh.h>
 #include <h/signals.h>
+#include <h/utils.h>
 #include <signal.h>
 
 static struct swit switches[] = {
 #include <signal.h>
 
 static struct swit switches[] = {
index a3da759..9f0044a 100644 (file)
@@ -13,6 +13,7 @@
 #include <errno.h>
 #include <h/mime.h>
 #include <h/mhparse.h>
 #include <errno.h>
 #include <h/mime.h>
 #include <h/mhparse.h>
+#include <h/utils.h>
 
 extern int debugsw;
 
 
 extern int debugsw;
 
index 1c786cc..08d676e 100644 (file)
@@ -20,6 +20,7 @@
 #include <h/tws.h>
 #include <h/mime.h>
 #include <h/mhparse.h>
 #include <h/tws.h>
 #include <h/mime.h>
 #include <h/mhparse.h>
+#include <h/utils.h>
 
 #ifdef HAVE_SYS_WAIT_H
 # include <sys/wait.h>
 
 #ifdef HAVE_SYS_WAIT_H
 # include <sys/wait.h>
index 72694b6..519e481 100644 (file)
@@ -20,6 +20,7 @@
 #include <h/tws.h>
 #include <h/mime.h>
 #include <h/mhparse.h>
 #include <h/tws.h>
 #include <h/mime.h>
 #include <h/mhparse.h>
+#include <h/utils.h>
 
 
 /*
 
 
 /*
index 71ae644..1154f46 100644 (file)
@@ -12,6 +12,7 @@
 #include <h/mh.h>
 #include <h/tws.h>
 #include <h/picksbr.h>
 #include <h/mh.h>
 #include <h/tws.h>
 #include <h/picksbr.h>
+#include <h/utils.h>
 
 #ifdef TIME_WITH_SYS_TIME
 # include <sys/time.h>
 
 #ifdef TIME_WITH_SYS_TIME
 # include <sys/time.h>
index aff49a0..2fe45a1 100644 (file)
@@ -16,6 +16,7 @@
 #include <h/aliasbr.h>
 #include <h/dropsbr.h>
 #include <h/mime.h>
 #include <h/aliasbr.h>
 #include <h/dropsbr.h>
 #include <h/mime.h>
+#include <h/utils.h>
 
 #include <h/tws.h>
 #include <h/mts.h>
 
 #include <h/tws.h>
 #include <h/mts.h>
index b1c0782..e5fa527 100644 (file)
@@ -10,6 +10,7 @@
  */
 
 #include <h/mh.h>
  */
 
 #include <h/mh.h>
+#include <h/utils.h>
 
 
 static struct swit switches[] = {
 
 
 static struct swit switches[] = {
index 5773b56..b068d49 100644 (file)
@@ -11,6 +11,7 @@
 
 #include <h/mh.h>
 #include <h/mime.h>
 
 #include <h/mh.h>
 #include <h/mime.h>
+#include <h/utils.h>
 
 static struct swit switches[] = {
 #define CHECKMIMESW          0
 
 static struct swit switches[] = {
 #define CHECKMIMESW          0
index 993a141..e51f869 100644 (file)
@@ -32,6 +32,7 @@
 #include <h/signals.h>
 #include <h/tws.h>
 #include <h/mts.h>
 #include <h/signals.h>
 #include <h/tws.h>
 #include <h/mts.h>
+#include <h/utils.h>
 
 #include <pwd.h>
 #include <signal.h>
 
 #include <pwd.h>
 #include <signal.h>
index 5a7d943..e2b43bd 100644 (file)
@@ -19,6 +19,7 @@
 #include <h/dropsbr.h>
 #include <h/tws.h>
 #include <h/mts.h>
 #include <h/dropsbr.h>
 #include <h/tws.h>
 #include <h/mts.h>
+#include <h/utils.h>
 
 #define        uptolow(c)      ((isalpha(c) && isupper (c)) ? tolower (c) : c)
 
 
 #define        uptolow(c)      ((isalpha(c) && isupper (c)) ? tolower (c) : c)