]> diplodocus.org Git - nmh/blobdiff - uip/fmttest.c
fdcompare.c: Move interface to own file.
[nmh] / uip / fmttest.c
index 91a83a5fac3d9d9c87400f984a3c339936752fc3..798b573d3bebfb4896fa022ee152ca565a2b55a5 100644 (file)
@@ -5,12 +5,24 @@
  * complete copyright information.
  */
 
-#include <h/mh.h>
-#include <h/fmt_scan.h>
-#include <h/fmt_compile.h>
-#include <h/utils.h>
-#include <h/scansbr.h>
-#include <h/addrsbr.h>
+#include "h/mh.h"
+#include "sbr/folder_read.h"
+#include "sbr/folder_free.h"
+#include "sbr/context_save.h"
+#include "sbr/context_replace.h"
+#include "sbr/context_find.h"
+#include "sbr/brkstring.h"
+#include "sbr/ambigsw.h"
+#include "sbr/path.h"
+#include "sbr/print_version.h"
+#include "sbr/print_help.h"
+#include "sbr/seq_getnum.h"
+#include "sbr/error.h"
+#include "h/fmt_scan.h"
+#include "h/fmt_compile.h"
+#include "h/utils.h"
+#include "h/scansbr.h"
+#include "h/addrsbr.h"
 #include "h/done.h"
 #include "sbr/m_maildir.h"
 #include "sbr/terminal.h"
@@ -102,8 +114,8 @@ static char *test_concataddr(char *, char *);
 static int insert(struct mailname *);
 static void mlistfree(void);
 
-static int nodupcheck = 0;     /* If set, no check for duplicates */
-static int ccme = 0;           /* Should I cc myself? */
+static bool nodupcheck;        /* If set, no check for duplicates */
+static bool ccme;              /* Should I cc myself? */
 static struct mailname mq;     /* Mail addresses to check for duplicates */
 static char *dummy = "dummy";
 
@@ -116,8 +128,12 @@ main (int argc, char **argv)
     struct format *fmt;
     struct comp *cptr;
     struct msgs_array msgs = { 0, 0, NULL }, compargs = { 0, 0, NULL};
-    int dump = 0, i;
-    int outputsize = 0, dupaddrs = 1, trace = 0, files = 0;
+    bool dump = false;
+    int i;
+    int outputsize = 0;
+    bool dupaddrs = true;
+    bool trace = false;
+    int files = 0;
     int colwidth = -1, msgnum = -1, msgcur = -1, msgsize = -1, msgunseen = -1;
     enum mode_t mode = MESSAGE;
     int dat[5];
@@ -185,10 +201,10 @@ main (int argc, char **argv)
                    continue;
 
                case TRACESW:
-                   trace++;
+                   trace = true;
                    continue;
                case NTRACESW:
-                   trace = 0;
+                   trace = false;
                    continue;
 
                case ADDRSW:
@@ -201,7 +217,7 @@ main (int argc, char **argv)
                case MESSAGESW:
                    mode = MESSAGE;
                    defformat = FORMAT;
-                   dupaddrs = 0;
+                   dupaddrs = false;
                    continue;
                case DATESW:
                    mode = DATE;
@@ -216,17 +232,17 @@ main (int argc, char **argv)
                    continue;
 
                case DUPADDRSW:
-                   dupaddrs++;
+                   dupaddrs = true;
                    continue;
                case NDUPADDRSW:
-                   dupaddrs = 0;
+                   dupaddrs = false;
                    continue;
 
                case CCMESW:
-                   ccme++;
+                   ccme = true;
                    continue;
                case NCCMESW:
-                   ccme = 0;
+                   ccme = false;
                    continue;
 
                case WIDTHSW:
@@ -256,10 +272,10 @@ main (int argc, char **argv)
                    continue;
 
                case DUMPSW:
-                   dump++;
+                   dump = true;
                    continue;
                case NDUMPSW:
-                   dump = 0;
+                   dump = false;
                    continue;
 
            }
@@ -336,11 +352,11 @@ main (int argc, char **argv)
      * callback, do that now.  Also, prime ismymbox if we use it.
      */
 
-    if (dupaddrs == 0 || trace) {
+    if (!dupaddrs || trace) {
        ZERO(&cb);
        cbp = &cb;
 
-       if (dupaddrs == 0) {
+       if (!dupaddrs) {
            cb.formataddr = test_formataddr;
            cb.concataddr = test_concataddr;
            if (!ccme)
@@ -721,19 +737,20 @@ test_trace(void *context, struct format *fmt, int num, char *str,
           const char *outbuf)
 {
     struct trace_context *ctx = (struct trace_context *) context;
-    int changed = 0;
+    bool changed = false;
 
     dumpone(fmt);
 
     if (num != ctx->num) {
        printf("num=%d", num);
        ctx->num = num;
-       changed++;
+       changed = true;
     }
 
     if (str != ctx->str) {
-       if (changed++)
+       if (changed)
             putchar(' ');
+        changed = true;
        fputs("str=", stdout);
        litputs(str);
        ctx->str = str;
@@ -1210,7 +1227,7 @@ test_formataddr (char *orig, char *str)
 {
     int len;
     char error[BUFSIZ];
-    int isgroup;
+    bool isgroup;
     char *dst;
     char *cp;
     char *sp;
@@ -1239,14 +1256,14 @@ test_formataddr (char *orig, char *str)
     }
 
     /* concatenate all the new addresses onto 'buf' */
-    for (isgroup = 0; (cp = getname (str)); ) {
+    for (isgroup = false; (cp = getname (str)); ) {
        if ((mp = getm (cp, NULL, 0, error, sizeof(error))) == NULL) {
            fprintf(stderr, "bad address \"%s\" -- %s\n", cp, error);
            continue;
        }
        if (isgroup && (mp->m_gname || !mp->m_ingrp)) {
            *dst++ = ';';
-           isgroup = 0;
+           isgroup = false;
        }
        if (insert (mp)) {
            /* if we get here we're going to add an address */
@@ -1257,7 +1274,7 @@ test_formataddr (char *orig, char *str)
            if (mp->m_gname) {
                CHECKMEM (mp->m_gname);
                CPY (mp->m_gname);
-               isgroup++;
+               isgroup = true;
            }
            sp = adrformat (mp);
            CHECKMEM (sp);
@@ -1283,9 +1300,9 @@ test_concataddr(char *orig, char *str)
 {
     char *cp;
 
-    nodupcheck = 1;
+    nodupcheck = true;
     cp = test_formataddr(orig, str);
-    nodupcheck = 0;
+    nodupcheck = false;
     return cp;
 }