In-sourced copyip() and could make the code simpler.
authormarkus schnalke <meillo@marmaro.de>
Sat, 24 Mar 2012 13:02:18 +0000 (14:02 +0100)
committermarkus schnalke <meillo@marmaro.de>
Sat, 24 Mar 2012 13:02:18 +0000 (14:02 +0100)
The function had had a bad name and it's use in mhl.c was complex, anyway.

h/prototypes.h
sbr/Makefile.in
sbr/copyip.c [deleted file]
uip/mhbuild.c
uip/mhl.c

index b05535d..3c0dc3c 100644 (file)
@@ -36,7 +36,6 @@ int context_foil(char *);
 void context_read(void);
 void context_replace(char *, char *);
 void context_save(void);
-char **copyip(char **, char **, int);
 void cpydata(int, int, char *, char *);
 void cpydgst(int, int, char *, char *);
 int decode_rfc2047(char *, char *, size_t);
index d96807c..5de54a2 100644 (file)
@@ -49,7 +49,7 @@ SRCS = addrsbr.c ambigsw.c brkstring.c  \
        check_charset.c concat.c context_del.c  \
        context_find.c context_foil.c context_read.c  \
        context_replace.c context_save.c \
-       copyip.c cpydata.c cpydgst.c crawl_folders.c  \
+       cpydata.c cpydgst.c crawl_folders.c  \
        discard.c done.c dtime.c dtimep.c  \
        error.c ext_hook.c folder_addmsg.c folder_delmsgs.c  \
        folder_free.c folder_pack.c folder_read.c  \
diff --git a/sbr/copyip.c b/sbr/copyip.c
deleted file mode 100644 (file)
index e5ded82..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
-** copyip.c -- copy a string array and return pointer to end
-**
-** 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>
-
-
-char **
-copyip(char **p, char **q, int len_q)
-{
-       while (*p && --len_q > 0)
-               *q++ = *p++;
-       *q = NULL;
-
-       return q;
-}
index 3432ccc..3ed31f9 100644 (file)
@@ -1058,8 +1058,14 @@ use_forw:
                struct msgs *mp;
 
                if (ci->ci_magic) {
+                       int i;
+
                        ap = brkstring(ci->ci_magic, " ", "\n");
-                       copyip(ap, arguments, MAXARGS);
+                       for (i=0; ap[i] && i<MAXARGS-1; i++) {
+                               arguments[i] = ap[i];
+                       }
+                       arguments[i] = NULL;
+
                } else {
                        arguments[0] = seq_cur;
                        arguments[1] = NULL;
index 38926b6..c1c5355 100644 (file)
--- a/uip/mhl.c
+++ b/uip/mhl.c
@@ -407,7 +407,7 @@ static void
 mhl_format(char *file, int width)
 {
        int i;
-       char *bp, *cp, **ip;
+       char *bp, *cp;
        char *ap, buffer[BUFSIZ], name[NAMESZ];
        struct mcomp *c1;
        struct stat st;
@@ -443,7 +443,7 @@ mhl_format(char *file, int width)
                global.c_width = i;
        global.c_cwidth = -1;
        global.c_flags = 0;
-       *(ip = ignores) = NULL;
+       *ignores = NULL;
 
        while (vfgets(fp, &ap) == OK) {
                bp = ap;
@@ -470,25 +470,20 @@ mhl_format(char *file, int width)
                        ** it to the end of the current "ignores" list.
                        */
                        if (!mh_strcasecmp(name, "ignores")) {
-                               char **tmparray, **p;
+                               char **tmparray;
                                int n = 0;
 
                                /* split the fields */
                                tmparray = brkstring(getcpy(++parptr), ",",
                                                NULL);
-
-                               /* count number of fields split */
-                               p = tmparray;
-                               while (*p++)
-                                       n++;
-
                                /*
                                ** copy pointers to split fields
                                ** to ignores array
                                */
-                               ip = copyip(tmparray, ip,
-                                               MAXARGS - num_ignores);
-                               num_ignores += n;
+                               while (tmparray[n] && num_ignores<MAXARGS-1) {
+                                       ignores[num_ignores++] = tmparray[n++];
+                               }
+                               ignores[num_ignores] = NULL;
                                continue;
                        }
                        parptr = bp;