Rearranged whitespace (and comments) in all the code!
[mmh] / sbr / fmt_addr.c
index be9b483..bfb42d8 100644 (file)
@@ -1,4 +1,3 @@
-
 /*
  * fmt_addr.c -- format an address field (from fmt_scan)
  *
 #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 *last_dst;         /* buf ptr at end of last call */
-static unsigned int bufsiz;    /* current size of buf         */
+static char *buf;            /* our current working buffer  */
+static char *bufend;         /* end of working buffer       */
+static char *last_dst;       /* buf ptr at end of last call */
+static unsigned int bufsiz;  /* current size of buf         */
 
-#define BUFINCR 512            /* how much to expand buf when if fills */
+#define BUFINCR 512  /* how much to expand buf when if fills */
 
 #define CPY(s) { cp = (s); while ((*dst++ = *cp++)) ; --dst; }
 
 /* check if there's enough room in buf for str.  add more mem if needed */
 #define CHECKMEM(str) \
-           if ((len = strlen (str)) >= bufend - dst) {\
+       if ((len = strlen (str)) >= bufend - dst) {\
                int i = dst - buf;\
                int n = last_dst - buf;\
                bufsiz += ((dst + len - bufend) / BUFINCR + 1) * BUFINCR;\
@@ -31,7 +30,7 @@ static unsigned int bufsiz;   /* current size of buf         */
                dst = buf + i;\
                last_dst = buf + n;\
                bufend = buf + bufsiz;\
-           }
+       }
 
 
 /* fmt_scan will call this routine if the user includes the function
@@ -51,64 +50,64 @@ static unsigned int bufsiz; /* current size of buf         */
 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;
-
-    /* if we don't have a buffer yet, get one */
-    if (bufsiz == 0) {
-       buf = mh_xmalloc (BUFINCR);
-       last_dst = buf;         /* XXX */
-       bufsiz = BUFINCR - 6;  /* leave some slop */
-       bufend = buf + bufsiz;
-    }
-    /*
-     * If "orig" points to our buffer we can just pick up where we
-     * left off.  Otherwise we have to copy orig into our buffer.
-     */
-    if (orig == buf)
-       dst = last_dst;
-    else if (!orig || !*orig) {
-       dst = buf;
-       *dst = '\0';
-    } else {
-       dst = last_dst;         /* XXX */
-       CHECKMEM (orig);
-       CPY (orig);
-    }
+       register int len;
+       register int isgroup;
+       register char *dst;
+       register char *cp;
+       register char *sp;
+       register struct mailname *mp = NULL;
 
-    /* concatenate all the new addresses onto 'buf' */
-    for (isgroup = 0; (cp = getname (str)); ) {
-       if ((mp = getm (cp, NULL, 0, fmt_norm, NULL)) == NULL)
-           continue;
-
-       if (isgroup && (mp->m_gname || !mp->m_ingrp)) {
-           *dst++ = ';';
-           isgroup = 0;
+       /* if we don't have a buffer yet, get one */
+       if (bufsiz == 0) {
+               buf = mh_xmalloc (BUFINCR);
+               last_dst = buf;  /* XXX */
+               bufsiz = BUFINCR - 6;  /* leave some slop */
+               bufend = buf + bufsiz;
        }
-       /* if we get here we're going to add an address */
-       if (dst != buf) {
-           *dst++ = ',';
-           *dst++ = ' ';
+       /*
+        * If "orig" points to our buffer we can just pick up where we
+        * left off.  Otherwise we have to copy orig into our buffer.
+        */
+       if (orig == buf)
+               dst = last_dst;
+       else if (!orig || !*orig) {
+               dst = buf;
+               *dst = '\0';
+       } else {
+               dst = last_dst;  /* XXX */
+               CHECKMEM (orig);
+               CPY (orig);
        }
-       if (mp->m_gname) {
-           CHECKMEM (mp->m_gname);
-           CPY (mp->m_gname);
-           isgroup++;
+
+       /* concatenate all the new addresses onto 'buf' */
+       for (isgroup = 0; (cp = getname (str)); ) {
+               if ((mp = getm (cp, NULL, 0, fmt_norm, NULL)) == NULL)
+                       continue;
+
+               if (isgroup && (mp->m_gname || !mp->m_ingrp)) {
+                       *dst++ = ';';
+                       isgroup = 0;
+               }
+               /* if we get here we're going to add an address */
+               if (dst != buf) {
+                       *dst++ = ',';
+                       *dst++ = ' ';
+               }
+               if (mp->m_gname) {
+                       CHECKMEM (mp->m_gname);
+                       CPY (mp->m_gname);
+                       isgroup++;
+               }
+               sp = adrformat (mp);
+               CHECKMEM (sp);
+               CPY (sp);
+               mnfree (mp);
        }
-       sp = adrformat (mp);
-       CHECKMEM (sp);
-       CPY (sp);
-       mnfree (mp);
-    }
 
-    if (isgroup)
-       *dst++ = ';';
+       if (isgroup)
+               *dst++ = ';';
 
-    *dst = '\0';
-    last_dst = dst;
-    return (buf);
+       *dst = '\0';
+       last_dst = dst;
+       return (buf);
 }