* uip/mhlistsbr.c, uip/mhlsbr.c, uip/picksbr.c: cast
[mmh] / uip / replsbr.c
index 0b0ba6e..a415346 100644 (file)
@@ -12,6 +12,7 @@
 #include <h/mh.h>
 #include <h/addrsbr.h>
 #include <h/fmt_scan.h>
+#include <h/utils.h>
 #include <sys/file.h>          /* L_SET */
 #include <errno.h>
 
@@ -78,7 +79,8 @@ replout (FILE *inb, char *msg, char *drft, struct msgs *mp, int outputlinelen,
     register char **ap;
     register struct comp **savecomp;
     int        char_read = 0, format_len, mask;
-    char name[NAMESZ], *scanl, *cp;
+    char name[NAMESZ], *scanl;
+    unsigned char *cp;
     FILE *out;
 
     mask = umask(~m_gmprot());
@@ -104,8 +106,7 @@ replout (FILE *inb, char *msg, char *drft, struct msgs *mp, int outputlinelen,
     *--savecomp = NULL;                /* point at zero'd end minus 1 */
 
     for (i = ncomps; i--; )
-       if (!(*nxtbuf++ = malloc(SBUFSIZ)))
-           adios (NULL, "unable to allocate component buffer");
+       *nxtbuf++ = mh_xmalloc(SBUFSIZ);
 
     nxtbuf = compbuffers;              /* point at start */
     tmpbuf = *nxtbuf++;
@@ -159,10 +160,12 @@ replout (FILE *inb, char *msg, char *drft, struct msgs *mp, int outputlinelen,
                 */
                if ((cptr = wantcomp[CHASH(name)]))
                    do {
-                       if (!strcasecmp(name, cptr->c_name)) {
+                       if (!mh_strcasecmp(name, cptr->c_name)) {
                            char_read += msg_count;
                            if (! cptr->c_text) {
-                               cptr->c_text = tmpbuf;
+                               i = strlen(cptr->c_text = tmpbuf) - 1;
+                               if (tmpbuf[i] == '\n')
+                                   tmpbuf[i] = '\0';
                                *--savecomp = cptr;
                                tmpbuf = *nxtbuf++;
                            } else {
@@ -230,7 +233,7 @@ finished:
        }
     }
     i = format_len + char_read + 256;
-    scanl = malloc ((size_t) i + 2);
+    scanl = mh_xmalloc ((size_t) i + 2);
     dat[0] = 0;
     dat[1] = 0;
     dat[2] = 0;
@@ -291,11 +294,9 @@ static unsigned int bufsiz=0;      /* current size of buf */
                int i = dst - buf;\
                int n = last_dst - buf;\
                bufsiz += ((dst + len - bufend) / BUFINCR + 1) * BUFINCR;\
-               buf = realloc (buf, bufsiz);\
+               buf = mh_xrealloc (buf, bufsiz);\
                dst = buf + i;\
                last_dst = buf + n;\
-               if (! buf)\
-                   adios (NULL, "formataddr: couldn't get buffer space");\
                bufend = buf + bufsiz;\
            }
 
@@ -324,9 +325,7 @@ formataddr (char *orig, char *str)
 
     /* if we don't have a buffer yet, get one */
     if (bufsiz == 0) {
-       buf = malloc (BUFINCR);
-       if (! buf)
-           adios (NULL, "formataddr: couldn't allocate buffer space");
+       buf = mh_xmalloc (BUFINCR);
        last_dst = buf;         /* XXX */
        bufsiz = BUFINCR - 6;  /* leave some slop */
        bufend = buf + bufsiz;
@@ -393,8 +392,8 @@ insert (struct mailname *np)
        return 0;
 
     for (mp = &mq; mp->m_next; mp = mp->m_next) {
-       if (!strcasecmp (np->m_host, mp->m_next->m_host)
-               && !strcasecmp (np->m_mbox, mp->m_next->m_mbox))
+       if (!mh_strcasecmp (np->m_host, mp->m_next->m_host)
+               && !mh_strcasecmp (np->m_mbox, mp->m_next->m_mbox))
            return 0;
     }
     if (!ccme && ismymbox (np))