X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/a259594cc41e41bfbb90562d3977b8194d1446f5..85bb87a28dff30d9e90ec80ab33cd97a3f07cb9d:/sbr/m_convert.c diff --git a/sbr/m_convert.c b/sbr/m_convert.c index bbefc99a..56b63233 100644 --- a/sbr/m_convert.c +++ b/sbr/m_convert.c @@ -2,8 +2,6 @@ /* * 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. @@ -142,7 +140,7 @@ rangerr: } if ((range = atoi (bp = cp)) == 0) goto badlist; - while (isdigit (*bp)) + while (isdigit ((unsigned char) *bp)) bp++; if (*bp) goto badelim; @@ -182,6 +180,18 @@ single: * 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 @@ -239,14 +249,14 @@ single: static int m_conv (struct msgs *mp, char *str, int call) { - register int i; - register char *cp, *bp; + int i; + char *cp, *bp; char buf[16]; convdir = 1; cp = bp = str; - if (isdigit (*cp)) { - while (isdigit (*bp)) + if (isdigit ((unsigned char) *cp)) { + while (isdigit ((unsigned char) *bp)) bp++; delimp = bp; i = atoi (cp); @@ -263,11 +273,11 @@ m_conv (struct msgs *mp, char *str, int call) #ifdef LOCALE /* doesn't enforce lower case */ - for (bp = buf; (isalpha(*cp) || *cp == '.') - && (bp - buf < sizeof(buf) - 1); ) + for (bp = buf; (isalpha((unsigned char) *cp) || *cp == '.') + && (bp - buf < (int) sizeof(buf) - 1); ) #else for (bp = buf; ((*cp >= 'a' && *cp <= 'z') || *cp == '.') - && (bp - buf < sizeof(buf) - 1); ) + && (bp - buf < (int) sizeof(buf) - 1); ) #endif /* LOCALE */ { *bp++ = *cp++; @@ -326,9 +336,9 @@ m_conv (struct msgs *mp, char *str, int call) static int attr (struct msgs *mp, char *cp) { - register char *dp; + char *dp; char *bp = NULL; - register int i, j; + int i, j; int found, inverted = 0, range = 0, /* no range */ @@ -348,7 +358,7 @@ attr (struct msgs *mp, char *cp) convdir = 1; /* convert direction */ - for (dp = cp; *dp && isalnum(*dp); dp++) + for (dp = cp; *dp && isalnum((unsigned char) *dp); dp++) continue; if (*dp == ':') { @@ -361,7 +371,7 @@ attr (struct msgs *mp, char *cp) * seq:first (or) * seq:last */ - if (isalpha (*dp)) { + if (isalpha ((unsigned char) *dp)) { if (!strcmp (dp, "prev")) { convdir = -1; first = (mp->curmsg > 0) && (mp->curmsg <= mp->hghmsg) @@ -396,7 +406,7 @@ attr (struct msgs *mp, char *cp) } if ((range = atoi(dp)) == 0) return BADLST; - while (isdigit (*dp)) + while (isdigit ((unsigned char) *dp)) dp++; if (*dp) return BADLST;