Factor trim format function out
[mmh] / sbr / m_convert.c
index 734bdb5..d187a34 100644 (file)
@@ -10,6 +10,7 @@
 /* FIXME: This code needs rework! Rewrite as a parser? */
 
 #include <h/mh.h>
+#include <ctype.h>
 
 /*
 ** error codes for sequence
@@ -35,23 +36,6 @@ static char *delimp;  /* delimiter pointer */
 static int m_conv(struct msgs *, char *, int);
 static int attr(struct msgs *, char *);
 
-
-static void
-addtosel(struct msgs *mp, int msg)
-{
-       if (is_selected(mp, msg)) {
-               return;  /* dont select twice */
-       }
-       set_selected(mp, msg);
-       mp->numsel++;
-       if (mp->lowsel == 0 || msg < mp->lowsel) {
-               mp->lowsel = msg;
-       }
-       if (msg > mp->hghsel) {
-               mp->hghsel = msg;
-       }
-}
-
 int
 m_convert(struct msgs *mp, char *name)
 {
@@ -80,7 +64,7 @@ m_convert(struct msgs *mp, char *name)
        ** Also, it is available in any folder.
        */
        if ((mp->msgflags & ALLOW_BEYOND) && strcmp(cp, seq_beyond)==0) {
-               addtosel(mp, getbeyond(mp));
+               set_selected(mp, getbeyond(mp));
                return 1;
        }
 
@@ -225,7 +209,7 @@ badelim:
        /* Cycle through the range and select the messages that exist. */
        for (found=0; first <= last; first++) {
                if (does_exist(mp, first)) {
-                       addtosel(mp, first);
+                       set_selected(mp, first);
                        found++;
                }
        }
@@ -248,8 +232,8 @@ badelim:
 static int
 m_conv(struct msgs *mp, char *str, int call)
 {
-       register int i;
-       register unsigned char *cp, *bp;
+       int i;
+       unsigned char *cp, *bp;
        unsigned char buf[16];  /* for reserved sequence name */
 
        convdir = 1;
@@ -272,7 +256,7 @@ m_conv(struct msgs *mp, char *str, int call)
                        return BADNUM;
        }
 
-       for (bp = buf; isalpha(*cp) && (bp - buf < sizeof(buf) - 1); ) {
+       for (bp = buf; isalpha(*cp) && (bp - buf < (int)sizeof(buf) - 1); ) {
                *bp++ = *cp++;
        }
        *bp++ = '\0';
@@ -333,9 +317,9 @@ m_conv(struct msgs *mp, char *str, int call)
 static int
 attr(struct msgs *mp, char *cp)
 {
-       register unsigned char *dp;
+       unsigned char *dp;
        char *bp = NULL;
-       register int i, j;
+       int i, j;
        int found;
        int inverted = 0;
        int range = 0;  /* no range */
@@ -426,7 +410,7 @@ attr(struct msgs *mp, char *cp)
                if (does_exist(mp, j)
                                && inverted ? !in_sequence(mp, i, j) :
                                in_sequence(mp, i, j)) {
-                       addtosel(mp, j);
+                       set_selected(mp, j);
                        found++;
 
                        /*