]> diplodocus.org Git - nmh/blobdiff - sbr/fmt_addr.c
uip/mhparse.c: Fix body starting a byte too soon when no blank line.
[nmh] / sbr / fmt_addr.c
index 2e4bff61ea835bee5cbd0133e17ef6c9bed37cd8..8e2e5456f1713c0f98b6b0c1ff5e632e6fec9747 100644 (file)
@@ -1,8 +1,4 @@
-
-/*
- * fmt_addr.c -- format an address field (from fmt_scan)
- *
- * $Id$
+/* fmt_addr.c -- format an address field (from fmt_scan)
  *
  * This code is Copyright (c) 2002, by the authors of nmh.  See the
  * COPYRIGHT file in the root directory of the nmh distribution for
  *
  * This code is Copyright (c) 2002, by the authors of nmh.  See the
  * COPYRIGHT file in the root directory of the nmh distribution for
@@ -12,6 +8,7 @@
 #include <h/mh.h>
 #include <h/addrsbr.h>
 #include <h/fmt_scan.h>
 #include <h/mh.h>
 #include <h/addrsbr.h>
 #include <h/fmt_scan.h>
+#include <h/utils.h>
 
 static char *buf;              /* our current working buffer  */
 static char *bufend;           /* end of working buffer       */
 
 static char *buf;              /* our current working buffer  */
 static char *bufend;           /* end of working buffer       */
@@ -28,11 +25,9 @@ static unsigned int bufsiz;  /* current size of buf         */
                int i = dst - buf;\
                int n = last_dst - buf;\
                bufsiz += ((dst + len - bufend) / BUFINCR + 1) * BUFINCR;\
                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;\
                dst = buf + i;\
                last_dst = buf + n;\
-               if (! buf)\
-                   adios (NULL, "formataddr: couldn't get buffer space");\
                bufend = buf + bufsiz;\
            }
 
                bufend = buf + bufsiz;\
            }
 
@@ -54,18 +49,16 @@ static unsigned int bufsiz; /* current size of buf         */
 char *
 formataddr (char *orig, char *str)
 {
 char *
 formataddr (char *orig, char *str)
 {
-    register int len;
-    register int isgroup;
-    register char *dst;
-    register char *cp;
-    register char *sp;
-    register struct mailname *mp = NULL;
+    int len;
+    int isgroup;
+    char *dst;
+    char *cp;
+    char *sp;
+    struct mailname *mp = NULL;
 
     /* if we don't have a buffer yet, get one */
     if (bufsiz == 0) {
 
     /* 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;
        last_dst = buf;         /* XXX */
        bufsiz = BUFINCR - 6;  /* leave some slop */
        bufend = buf + bufsiz;
@@ -87,7 +80,7 @@ formataddr (char *orig, char *str)
 
     /* concatenate all the new addresses onto 'buf' */
     for (isgroup = 0; (cp = getname (str)); ) {
 
     /* concatenate all the new addresses onto 'buf' */
     for (isgroup = 0; (cp = getname (str)); ) {
-       if ((mp = getm (cp, NULL, 0, fmt_norm, NULL)) == NULL)
+       if ((mp = getm (cp, NULL, 0, NULL, 0)) == NULL)
            continue;
 
        if (isgroup && (mp->m_gname || !mp->m_ingrp)) {
            continue;
 
        if (isgroup && (mp->m_gname || !mp->m_ingrp)) {
@@ -117,3 +110,8 @@ formataddr (char *orig, char *str)
     last_dst = dst;
     return (buf);
 }
     last_dst = dst;
     return (buf);
 }
+
+char *concataddr (char *orig, char *str)
+{
+    return formataddr(orig, str);
+}