]> diplodocus.org Git - nmh/blobdiff - sbr/m_convert.c
More code converted to use argsplit().
[nmh] / sbr / m_convert.c
index 8acfb1a931b4221750b005ec1d541b28135d2a6c..496978ee9fbfdc4b9a7220a4f0e4baad0f7067bc 100644 (file)
@@ -2,8 +2,6 @@
 /*
  * m_convert.c -- parse a message range or sequence and set SELECTED
  *
 /*
  * m_convert.c -- parse a message range or sequence and set SELECTED
  *
- * $Id$
- *
  * This code is Copyright (c) 2002, by the authors of nmh.  See the
  * COPYRIGHT file in the root directory of the nmh distribution for
  * complete copyright information.
  * This code is Copyright (c) 2002, by the authors of nmh.  See the
  * COPYRIGHT file in the root directory of the nmh distribution for
  * complete copyright information.
@@ -40,7 +38,8 @@ int
 m_convert (struct msgs *mp, char *name)
 {
     int first, last, found, range, err;
 m_convert (struct msgs *mp, char *name)
 {
     int first, last, found, range, err;
-    char *bp, *cp;
+    unsigned char *bp;
+    char *cp;
 
     /* check if user defined sequence */
     err = attr (mp, cp = name);
 
     /* check if user defined sequence */
     err = attr (mp, cp = name);
@@ -182,6 +181,18 @@ single:
         * check if message is in-range and exists.
         */
        if (mp->msgflags & ALLOW_NEW) {
         * check if message is in-range and exists.
         */
        if (mp->msgflags & ALLOW_NEW) {
+           /*
+            * We can get into a case where the "cur" sequence is way out
+            * of range, and because it's allowed to not exist (think
+            * of "rmm; next") it doesn't get checked to make sure it's
+            * within the range of messages in seq_init().  So if our
+            * desired sequence is out of range of the allocated folder
+            * limits simply reallocate the folder so it's within range.
+            */
+           if (first < mp->lowoff || first > mp->hghoff)
+               mp = folder_realloc(mp, first < mp->lowoff ? first : mp->lowoff,
+                                   first > mp->hghoff ? first : mp->hghoff);
+
            set_select_empty (mp, first);
        } else {
            if (first > mp->hghmsg
            set_select_empty (mp, first);
        } else {
            if (first > mp->hghmsg
@@ -225,7 +236,7 @@ single:
 
 /*
  * Convert the various message names to
 
 /*
  * Convert the various message names to
- * there numeric value.
+ * their numeric values.
  *
  * n     (integer)
  * prev
  *
  * n     (integer)
  * prev
@@ -240,8 +251,8 @@ static int
 m_conv (struct msgs *mp, char *str, int call)
 {
     register int i;
 m_conv (struct msgs *mp, char *str, int call)
 {
     register int i;
-    register char *cp, *bp;
-    char buf[16];
+    register unsigned char *cp, *bp;
+    unsigned char buf[16];
 
     convdir = 1;
     cp = bp = str;
 
     convdir = 1;
     cp = bp = str;
@@ -264,10 +275,10 @@ m_conv (struct msgs *mp, char *str, int call)
 #ifdef LOCALE
     /* doesn't enforce lower case */
     for (bp = buf; (isalpha(*cp) || *cp == '.')
 #ifdef LOCALE
     /* doesn't enforce lower case */
     for (bp = buf; (isalpha(*cp) || *cp == '.')
-               && (bp - buf < sizeof(buf) - 1); )
+           && (bp - buf < (int) sizeof(buf) - 1); )
 #else
     for (bp = buf; ((*cp >= 'a' && *cp <= 'z') || *cp == '.')
 #else
     for (bp = buf; ((*cp >= 'a' && *cp <= 'z') || *cp == '.')
-               && (bp - buf < sizeof(buf) - 1); )
+           && (bp - buf < (int) sizeof(buf) - 1); )
 #endif /* LOCALE */
     {
        *bp++ = *cp++;
 #endif /* LOCALE */
     {
        *bp++ = *cp++;
@@ -326,7 +337,7 @@ m_conv (struct msgs *mp, char *str, int call)
 static int
 attr (struct msgs *mp, char *cp)
 {
 static int
 attr (struct msgs *mp, char *cp)
 {
-    register char *dp;
+    register unsigned char *dp;
     char *bp = NULL;
     register int i, j;
     int found,
     char *bp = NULL;
     register int i, j;
     int found,