]> diplodocus.org Git - nmh/blobdiff - sbr/m_convert.c
print_sw.c: Move interface to own file.
[nmh] / sbr / m_convert.c
index 566b02a5286fdf185f32f7611f46fb024a781d71..d5d069053092d2bf3c8af7b4e056be3f2f2d1c00 100644 (file)
@@ -5,8 +5,10 @@
  * complete copyright information.
  */
 
-#include <h/mh.h>
-#include <h/utils.h>
+#include "h/mh.h"
+#include "seq_getnum.h"
+#include "error.h"
+#include "h/utils.h"
 
 /*
  * error codes for sequence
@@ -37,7 +39,7 @@ static int attr (struct msgs *, char *);
 int
 m_convert (struct msgs *mp, char *name)
 {
-    int first, last, found, count, is_range, err;
+    int first, last, found, count, err;
     char *bp, *cp;
 
     /* check if user defined sequence */
@@ -54,7 +56,6 @@ m_convert (struct msgs *mp, char *name)
      */
 
     found = 0;
-    is_range = 1;
 
     /*
      * Check for special "new" sequence, which
@@ -129,9 +130,7 @@ rangerr:
 
     } else if (*cp == ':' || *cp == '=') {
 
-       if (*cp == '=')
-           is_range = 0;
-
+        bool is_range = *cp == ':';
        cp++;
 
        if (*cp == '-') {
@@ -293,16 +292,16 @@ m_conv (struct msgs *mp, char *str, int call)
     delimp = cp;
 
     if (!strcmp (buf, "first"))
-       return (mp->hghmsg || !(mp->msgflags & ALLOW_NEW)
-               ? mp->lowmsg : BADMSG);
+       return mp->hghmsg || !(mp->msgflags & ALLOW_NEW) ?
+            mp->lowmsg : BADMSG;
 
     if (!strcmp (buf, "last")) {
        convdir = -1;
-       return (mp->hghmsg || !(mp->msgflags & ALLOW_NEW) ? mp->hghmsg : BADMSG);
+       return mp->hghmsg || !(mp->msgflags & ALLOW_NEW) ? mp->hghmsg : BADMSG;
     }
 
     if (!strcmp (buf, "cur") || !strcmp (buf, "."))
-       return (mp->curmsg > 0 ? mp->curmsg : BADMSG);
+       return mp->curmsg > 0 ? mp->curmsg : BADMSG;
 
     if (!strcmp (buf, "prev")) {
        convdir = -1;
@@ -349,9 +348,7 @@ attr (struct msgs *mp, char *cp)
     char op;
     int i, j;
     int found,
-       inverted = 0,
        count = 0,              /* range given?  else use entire sequence */
-       just_one = 0,           /* want entire sequence or range */
        first = 0,
        start = 0;
 
@@ -364,16 +361,19 @@ attr (struct msgs *mp, char *cp)
     }
 
     /* Check for sequence negation */
+    bool inverted = false;
     if ((dp = context_find (nsequence)) && *dp != '\0' && ssequal (dp, cp)) {
-       inverted = 1;
+       inverted = true;
        cp += strlen (dp);
     }
 
     convdir = 1;       /* convert direction */
 
-    for (dp = cp; *dp && isalnum((unsigned char) *dp); dp++)
+    for (dp = cp; isalnum((unsigned char)*dp); dp++)
        continue;
 
+    bool just_one = *dp == '='; /* want entire sequence or range */
+
     if (*dp == ':') {
        bp = dp++;
        count = 1;
@@ -454,8 +454,6 @@ attr (struct msgs *mp, char *cp)
        if (count == 0 || *ep)
            return BADLST;
 
-       just_one = 1;
-
        op = *bp;
        *bp = '\0';     /* temporarily terminate sequence name */
     }