]> diplodocus.org Git - nmh/blobdiff - uip/picksbr.c
prototypes.h: Delete default_done() prototype.
[nmh] / uip / picksbr.c
index ca330b966646c86454ed3e2dfccddcc3232ffd8e..4d4d99a1de3bdd7c9bddd066c1c958f9dfa8e347 100644 (file)
@@ -116,7 +116,7 @@ static unsigned char cc[] = {
 #define        pinform         if (!talked++) inform
 
 struct nexus {
-    int (*n_action)();
+    int (*n_action)(struct nexus *n, FILE *fp, int msgnum, long start, long stop);
 
     union {
        /* for {OR,AND,NOT}action */
@@ -180,7 +180,7 @@ static struct nexus *parse(void);
 static struct nexus *nexp1(void);
 static struct nexus *nexp2(void);
 static struct nexus *nexp3(void);
-static struct nexus *newnexus(int (*)(struct nexus *n,
+static struct nexus *newnexus(int (*action)(struct nexus *n,
     FILE *fp, int msgnum, long start, long stop));
 
 static int ORaction(struct nexus *n, FILE *fp, int msgnum,
@@ -519,8 +519,10 @@ PRaction (struct nexus *n, int level)
                dasctime (&n->n_tws, TW_NULL));
        return;
     }
-    fprintf (stderr, "UNKNOWN(0x%x)\n",
-            (unsigned int)(unsigned long) (*n->n_action));
+
+    generic_pointer gp;
+    gp.f = (void (*)(void))n->n_action;
+    fprintf(stderr, "UNKNOWN(%p)\n", gp.v);
 }
 
 
@@ -642,21 +644,23 @@ cerror: ;
 static int
 GREPaction(struct nexus *n, FILE *fp, int msgnum, long start, long stop)
 {
-    int c, body, lf;
+    int c;
+    bool body;
+    bool lf;
     long pos = start;
     char *p1, *p2, *ebp, *cbp;
     char ibuf[BUFSIZ];
     NMH_UNUSED (msgnum);
 
     fseek (fp, start, SEEK_SET);
-    body = 0;
+    body = false;
     ebp = cbp = ibuf;
     for (;;) {
        if (body && n->n_header)
            return 0;
        p1 = linebuf;
        p2 = cbp;
-       lf = 0;
+       lf = false;
        for (;;) {
            if (p2 >= ebp) {
                if (fgets (ibuf, sizeof ibuf, fp) == NULL
@@ -675,16 +679,16 @@ GREPaction(struct nexus *n, FILE *fp, int msgnum, long start, long stop)
                    --p2;
                    break;
                }
-                lf = 0;
+                lf = false;
            }
            if (c == '\n') {
                if (body)
                    break;
                 if (lf) {
-                    body++;
+                    body = true;
                     break;
                 }
-                lf++;
+                lf = true;
                 /* Unfold by skipping the newline. */
                 c = 0;
            }
@@ -699,7 +703,7 @@ GREPaction(struct nexus *n, FILE *fp, int msgnum, long start, long stop)
 
        /* Attempt to decode as a MIME header.  If it's the last header,
           body will be 1 and lf will be at least 1. */
-       if ((body == 0 || lf > 0)  &&
+       if ((!body || lf)  &&
            decode_rfc2047 (linebuf, decoded_linebuf, sizeof decoded_linebuf)) {
            p1 = decoded_linebuf;
        }
@@ -794,7 +798,7 @@ advance (char *alp, char *aep)
                do {
                    lp--;
                    if (advance ((char *) lp, (char *) ep))
-                       return (1);
+                       return 1;
                } while (lp > curlp);
                return 0;
 
@@ -813,14 +817,14 @@ cclass (unsigned char *aset, int ac, int af)
 
     set = aset;
     if ((c = ac) == 0)
-       return (0);
+       return 0;
 
     n = *set++;
     while (n--)
        if (*set++ == c || set[-1] == cc[c])
-           return (af);
+           return af;
 
-    return (!af);
+    return !af;
 }
 
 
@@ -925,20 +929,21 @@ TWSaction(struct nexus *n, FILE *fp, int msgnum, long start, long stop)
     char *bp;
     char buf[NMH_BUFSIZ], name[NAMESZ];
     struct tws *tw;
-    m_getfld_state_t gstate = 0;
+    m_getfld_state_t gstate;
     NMH_UNUSED (stop);
 
     fseek (fp, start, SEEK_SET);
+    gstate = m_getfld_state_init(fp);
     for (bp = NULL;;) {
        int bufsz = sizeof buf;
-       switch (state = m_getfld (&gstate, name, buf, &bufsz, fp)) {
+       switch (state = m_getfld2(&gstate, name, buf, &bufsz)) {
            case FLD: 
            case FLDPLUS: 
-                mh_xfree(bp);
+                free(bp);
                bp = mh_xstrdup(buf);
                while (state == FLDPLUS) {
                    bufsz = sizeof buf;
-                   state = m_getfld (&gstate, name, buf, &bufsz, fp);
+                   state = m_getfld2(&gstate, name, buf, &bufsz);
                    bp = add (buf, bp);
                }
                if (!strcasecmp (name, n->n_datef))
@@ -951,11 +956,11 @@ TWSaction(struct nexus *n, FILE *fp, int msgnum, long start, long stop)
            case FMTERR: 
                if (state == LENERR || state == FMTERR)
                    inform("format error in message %d", msgnum);
-                mh_xfree(bp);
+                free(bp);
                return 0;
 
            default: 
-               adios (NULL, "internal error -- you lose");
+               die("internal error -- you lose");
        }
        break;
     }
@@ -968,6 +973,6 @@ TWSaction(struct nexus *n, FILE *fp, int msgnum, long start, long stop)
        state = n->n_after ? (twsort (tw, &n->n_tws) > 0)
            : (twsort (tw, &n->n_tws) < 0);
 
-    mh_xfree(bp);
+    free(bp);
     return state;
 }