]> granicus.if.org Git - neomutt/commitdiff
revert dodgy type changes
authorRichard Russon <rich@flatcap.org>
Mon, 11 Jun 2018 10:46:46 +0000 (11:46 +0100)
committerRichard Russon <rich@flatcap.org>
Mon, 11 Jun 2018 10:46:50 +0000 (11:46 +0100)
Some of the type changes I introduced in 309ecbf4 would cause problems
when strtol() and atoi() return errors.

mutt/regex.c

index f78340bf36aa76a5539c38585bbf19cd7898e5b8..44db928576a9997ebdf754715e05d8973ed9927a 100644 (file)
@@ -280,7 +280,6 @@ int mutt_replacelist_add(struct ReplaceList **rl, const char *pat,
 {
   struct ReplaceList *t = NULL, *last = NULL;
   struct Regex *rx = NULL;
-  size_t n;
   const char *p = NULL;
 
   if (!pat || !*pat || !templ)
@@ -337,7 +336,7 @@ int mutt_replacelist_add(struct ReplaceList **rl, const char *pat,
   {
     if (*p == '%')
     {
-      n = atoi(++p);
+      int n = atoi(++p);
       if (n > t->nmatch)
         t->nmatch = n;
       while (*p && isdigit((int) *p))
@@ -380,7 +379,6 @@ char *mutt_replacelist_apply(struct ReplaceList *rl, char *buf, size_t buflen, c
   static char twinbuf[2][LONG_STRING];
   int switcher = 0;
   char *p = NULL;
-  size_t n;
   size_t cpysize, tlen;
   char *src = NULL, *dst = NULL;
 
@@ -438,7 +436,7 @@ char *mutt_replacelist_apply(struct ReplaceList *rl, char *buf, size_t buflen, c
             }
             else
             {
-              n = strtoul(p, &p, 10);             /* get subst number */
+              long n = strtoul(p, &p, 10);        /* get subst number */
               while (isdigit((unsigned char) *p)) /* skip subst token */
                 p++;
               for (int i = pmatch[n].rm_so;
@@ -530,10 +528,9 @@ bool mutt_replacelist_match(struct ReplaceList *rl, char *buf, size_t buflen, co
         if (*p == '%')
         {
           char *e = NULL; /* used as pointer to end of integer backreference in strtol() call */
-          size_t n;
 
           p++; /* skip over % char */
-          n = strtol(p, &e, 10);
+          long n = strtol(p, &e, 10);
           /* Ensure that the integer conversion succeeded (e!=p) and bounds check.  The upper bound check
            * should not strictly be necessary since add_to_spam_list() finds the largest value, and
            * the static array above is always large enough based on that value. */