]> granicus.if.org Git - mutt/commitdiff
Some functions/macros like isspace take an int and require the
authorVincent Lefevre <vincent@vinc17.net>
Thu, 24 Jul 2003 18:40:50 +0000 (18:40 +0000)
committerVincent Lefevre <vincent@vinc17.net>
Thu, 24 Jul 2003 18:40:50 +0000 (18:40 +0000)
argument to have the value of an unsigned char (or EOF). Under
Solaris, gcc complains when the argument is a char (as this is a
possible bug, on platforms where char is signed, like Solaris). The
attached patch fixes such problems (well, perhaps I've changed more
than necessary, but this doesn't hurt).

21 files changed:
alias.c
copy.c
handler.c
imap/command.c
imap/imap.c
imap/message.c
imap/util.c
init.c
intl/l10nflist.c
intl/loadmsgcat.c
intl/localealias.c
keymap.c
lib.c
makedoc.c
muttlib.c
pattern.c
rfc2047.c
rfc2231.c
rfc822.c
strcasecmp.c
url.c

diff --git a/alias.c b/alias.c
index 990df9594cd6cee05019ef7966c8cde268cfcf16..6be0baf5a73b8fac1ba2c55f937e66f72e40bebc 100644 (file)
--- a/alias.c
+++ b/alias.c
@@ -353,7 +353,7 @@ retry_name:
 static int check_alias_name_char (char c)
 {
   return (c == '-' || c == '_' || c == '+' || c == '=' || c == '.' ||
-         isalnum (c));
+         isalnum ((unsigned char) c));
 }
 
 int mutt_check_alias_name (const char *s, char *d)
diff --git a/copy.c b/copy.c
index dfc4f2d6b864ad495ae8793db02d6cd5a3b93686..7d4e9c73d1acf6498f22d6b19ad3ea50a2302b94 100644 (file)
--- a/copy.c
+++ b/copy.c
@@ -844,7 +844,7 @@ static int address_header_decode (char **h)
 
   ADDRESS *a = NULL;
 
-  switch (tolower (*s))
+  switch (tolower ((unsigned char) *s))
   {
     case 'r': 
     {
index fead17c2e0aeeace0133d137390b1c05be412a1d..49bba437d9b6b2d3237d83d3ad092bf982abcd05 100644 (file)
--- a/handler.c
+++ b/handler.c
@@ -154,7 +154,9 @@ static int qp_decode_triple (char *s, char *d)
     return 1;
   
   /* quoted-printable triple */
-  if (*s == '=' && isxdigit (*(s+1)) && isxdigit (*(s+2)))
+  if (*s == '=' &&
+      isxdigit ((unsigned char) *(s+1)) &&
+      isxdigit ((unsigned char) *(s+2)))
   {
     *d = (hexval (*(s+1)) << 4) | hexval (*(s+2));
     return 0;
index fb01bd209d252a49d9698a097b71405539a00093..214c281c4646ba6c152e6b8c0275409734699fa7 100644 (file)
@@ -308,7 +308,7 @@ static int cmd_handle_untagged (IMAP_DATA* idata)
 
   s = imap_next_word (idata->cmd.buf);
 
-  if ((idata->state == IMAP_SELECTED) && isdigit (*s))
+  if ((idata->state == IMAP_SELECTED) && isdigit ((unsigned char) *s))
   {
     pn = s;
     s = imap_next_word (s);
@@ -525,7 +525,7 @@ static void cmd_parse_myrights (IMAP_DATA* idata, char* s)
   /* zero out current rights set */
   memset (idata->rights, 0, sizeof (idata->rights));
 
-  while (*s && !isspace(*s))
+  while (*s && !isspace((unsigned char) *s))
   {
     switch (*s) 
     {
index f10ae281cf3bb6dd207c63798b2d841ecaee02a6..a890e7ad1f7d2e29e405f823817c3960c7f147ae 100644 (file)
@@ -1234,7 +1234,7 @@ int imap_mailbox_check (char* path, int new)
       {
        s = imap_next_word (s);
        s = imap_next_word (s);
-       if (isdigit (*s))
+       if (isdigit ((unsigned char) *s))
        {
          if (*s != '0')
          {
index 47136fdaba5fea4abad31654d78b9f7862480346..bcc4b3e380cbbfd4b2412b7ca58b31d086ff5958 100644 (file)
@@ -852,7 +852,7 @@ static int msg_parse_fetch (IMAP_HEADER *h, char *s)
       s += 11;
       SKIPWS (s);
       ptmp = tmp;
-      while (isdigit (*s))
+      while (isdigit ((unsigned char) *s))
         *ptmp++ = *s++;
       *ptmp = 0;
       h->content_length = atoi (tmp);
index ae72edb70301242fe414616651d7adb78af856a6..18d055a58e213e5026579b909e6e75ffe6337e77 100644 (file)
@@ -310,7 +310,7 @@ int imap_get_literal_count(const char *buf, long *bytes)
     return (-1);
   pc++;
   pn = pc;
-  while (isdigit (*pc))
+  while (isdigit ((unsigned char) *pc))
     pc++;
   *pc = 0;
   *bytes = atoi(pn);
diff --git a/init.c b/init.c
index ab283524a594579fd28e01b03c3cc263aae1ce4a..80fcc94fe835ddb43dc24fc9ffcd8480df50d23a 100644 (file)
--- a/init.c
+++ b/init.c
@@ -139,7 +139,8 @@ int mutt_extract_token (BUFFER *dest, BUFFER *tok, int flags)
        case 'C':
            if (!*tok->dptr)
                return -1; /* premature end of token */
-         mutt_buffer_addch (dest, (toupper (*tok->dptr) - '@') & 0x7f);
+         mutt_buffer_addch (dest, (toupper ((unsigned char) *tok->dptr)
+                                    - '@') & 0x7f);
          tok->dptr++;
          break;
        case 'r':
@@ -180,7 +181,7 @@ int mutt_extract_token (BUFFER *dest, BUFFER *tok, int flags)
       else if (ch == '[')
        mutt_buffer_addch (dest, '\033');
       else if (isalpha ((unsigned char) ch))
-       mutt_buffer_addch (dest, toupper (ch) - '@');
+       mutt_buffer_addch (dest, toupper ((unsigned char) ch) - '@');
       else
       {
        mutt_buffer_addch (dest, '^');
index 533e94be889cd25dcfb3dcd11a9ddbde751b5128..8e2605bc3e5e771af41952b54f694fa6109ba6ef 100644 (file)
@@ -356,11 +356,11 @@ _nl_normalize_codeset (codeset, name_len)
   size_t cnt;
 
   for (cnt = 0; cnt < name_len; ++cnt)
-    if (isalnum (codeset[cnt]))
+    if (isalnum ((unsigned char) codeset[cnt]))
       {
        ++len;
 
-       if (isalpha (codeset[cnt]))
+       if (isalpha ((unsigned char) codeset[cnt]))
          only_digit = 0;
       }
 
@@ -374,9 +374,9 @@ _nl_normalize_codeset (codeset, name_len)
        wp = retval;
 
       for (cnt = 0; cnt < name_len; ++cnt)
-       if (isalpha (codeset[cnt]))
-         *wp++ = tolower (codeset[cnt]);
-       else if (isdigit (codeset[cnt]))
+       if (isalpha ((unsigned char) codeset[cnt]))
+         *wp++ = tolower ((unsigned char) codeset[cnt]);
+       else if (isdigit ((unsigned char) codeset[cnt]))
          *wp++ = codeset[cnt];
 
       *wp = '\0';
index f99ebee3adbbeae32e76f2f4dee693268110cf21..a06134a1d3a30af7439ed24c1210972014d47eb7 100644 (file)
@@ -508,7 +508,7 @@ _nl_load_domain (domain_file, domainbinding)
          struct parse_args args;
 
          nplurals += 9;
-         while (*nplurals != '\0' && isspace (*nplurals))
+         while (*nplurals != '\0' && isspace ((unsigned char) *nplurals))
            ++nplurals;
 #if defined HAVE_STRTOUL || defined _LIBC
          n = strtoul (nplurals, &endp, 10);
index 91e7acc9c7013e2ea19a778d16729485625fdd6e..f57d76442eb40a4bb50de90f2a590024cb86c89e 100644 (file)
@@ -244,21 +244,21 @@ read_alias_file (fname, fname_len)
 
       cp = buf;
       /* Ignore leading white space.  */
-      while (isspace (cp[0]))
+      while (isspace ((unsigned char) cp[0]))
        ++cp;
 
       /* A leading '#' signals a comment line.  */
       if (cp[0] != '\0' && cp[0] != '#')
        {
          alias = cp++;
-         while (cp[0] != '\0' && !isspace (cp[0]))
+         while (cp[0] != '\0' && !isspace ((unsigned char) cp[0]))
            ++cp;
          /* Terminate alias name.  */
          if (cp[0] != '\0')
            *cp++ = '\0';
 
          /* Now look for the beginning of the value.  */
-         while (isspace (cp[0]))
+         while (isspace ((unsigned char) cp[0]))
            ++cp;
 
          if (cp[0] != '\0')
@@ -267,7 +267,7 @@ read_alias_file (fname, fname_len)
              size_t value_len;
 
              value = cp++;
-             while (cp[0] != '\0' && !isspace (cp[0]))
+             while (cp[0] != '\0' && !isspace ((unsigned char) cp[0]))
                ++cp;
              /* Terminate value.  */
              if (cp[0] == '\n')
index 6fa4729ecb626306c757f5cce0b9eefa9c41fa33..5a5d9142b0a1d94702e1ea4194bde76ccd8ca073 100644 (file)
--- a/keymap.c
+++ b/keymap.c
@@ -120,7 +120,10 @@ static int parse_fkey(char *s)
  */
 static int parse_keycode (const char *s)
 {
-  if (isdigit (s[1]) && isdigit (s[2]) && isdigit (s[3]) && s[4] == '>')
+  if (isdigit ((unsigned char) s[1]) &&
+      isdigit ((unsigned char) s[2]) &&
+      isdigit ((unsigned char) s[3]) &&
+      s[4] == '>')
   {
     return (s[3] - '0') + (s[2] - '0') * 8 + (s[1] - '0') * 64;
   }
diff --git a/lib.c b/lib.c
index 71c2c39fac84d46c2110be2a08ec5cd8d8520a33..aeece74e6d6ed83d7aba2cf13b237b6973070338 100644 (file)
--- a/lib.c
+++ b/lib.c
@@ -170,7 +170,7 @@ char *mutt_strlower (char *s)
 
   while (*p)
   {
-    *p = tolower (*p);
+    *p = tolower ((unsigned char) *p);
     p++;
   }
 
@@ -608,7 +608,10 @@ const char *mutt_stristr (const char *haystack, const char *needle)
 
   while (*(p = haystack))
   {
-    for (q = needle; *p && *q && tolower (*p) == tolower (*q); p++, q++)
+    for (q = needle;
+         *p && *q &&
+           tolower ((unsigned char) *p) == tolower ((unsigned char) *q);
+         p++, q++)
       ;
     if (!*q)
       return (haystack);
index 842c1175d29a84d7c9058c17f8f42be9473e4637..4d3011ebd949eab0f99299ab9f071aaea15b9304 100644 (file)
--- a/makedoc.c
+++ b/makedoc.c
@@ -218,7 +218,7 @@ static void makedoc (FILE *in, FILE *out)
 
 static char *skip_ws (char *s)
 {
-  while (*s && isspace (*s))
+  while (*s && isspace ((unsigned char) *s))
     s++;
 
   return s;
@@ -300,7 +300,7 @@ static char *get_token (char *d, size_t l, char *s)
     }
     else if (!is_quoted && strchr (single_char_tokens, *t))
       break;
-    else if (!is_quoted && isspace (*t))
+    else if (!is_quoted && isspace ((unsigned char) *t))
       break;
     else
       *d++ = *t;
@@ -486,14 +486,14 @@ static void pretty_default (char *t, size_t l, const char *s, int type)
     {
       /* heuristic! */
       strncpy (t, s + 5, l);
-      for (; *t; t++) *t = tolower (*t);
+      for (; *t; t++) *t = tolower ((unsigned char) *t);
       break;
     }
     case DT_MAGIC:
     {
       /* heuristic! */
       strncpy (t, s + 2, l);
-      for (; *t; t++) *t = tolower (*t);
+      for (; *t; t++) *t = tolower ((unsigned char) *t);
       break;
     }
     case DT_STR:
@@ -1188,7 +1188,7 @@ static int handle_docline (char *l, FILE *out, int docstat)
       else
       {
        ref = s;
-       while (isalnum (*s) || *s == '-' || *s == '_')
+       while (isalnum ((unsigned char) *s) || *s == '-' || *s == '_')
          ++s;
 
        docstat = commit_buff (buff, &d, out, docstat);
index 7994c95d2c294e884d44bf4c8c19b811d4164e76..9b75b834cf463f744325b0957993bc68848b791e 100644 (file)
--- a/muttlib.c
+++ b/muttlib.c
@@ -521,7 +521,7 @@ char *mutt_gecos_name (char *dest, size_t destlen, struct passwd *pw)
       memmove (&dest[idx + pwnl], &dest[idx + 1],
               MAX(destlen - idx - pwnl - 1, 0));
       memcpy (&dest[idx], pw->pw_name, MIN(destlen - idx - 1, pwnl));
-      dest[idx] = toupper (dest[idx]);
+      dest[idx] = toupper ((unsigned char) dest[idx]);
     }
   }
       
index 606f6db15f61890d6613a160b313e7d99796f10f..013e7c6a68282e5d6df06f189e427caf50a13eb4 100644 (file)
--- a/pattern.c
+++ b/pattern.c
@@ -278,12 +278,12 @@ int eat_range (pattern_t *pat, BUFFER *s, BUFFER *err)
     }
     else
       pat->min = strtol (s->dptr, &tmp, 0);
-    if (toupper (*tmp) == 'K') /* is there a prefix? */
+    if (toupper ((unsigned char) *tmp) == 'K') /* is there a prefix? */
     {
       pat->min *= 1024;
       tmp++;
     }
-    else if (toupper (*tmp) == 'M')
+    else if (toupper ((unsigned char) *tmp) == 'M')
     {
       pat->min *= 1048576;
       tmp++;
@@ -312,12 +312,12 @@ int eat_range (pattern_t *pat, BUFFER *s, BUFFER *err)
   {
     /* range maximum */
     pat->max = strtol (tmp, &tmp, 0);
-    if (toupper (*tmp) == 'K')
+    if (toupper ((unsigned char) *tmp) == 'K')
     {
       pat->max *= 1024;
       tmp++;
     }
-    else if (toupper (*tmp) == 'M')
+    else if (toupper ((unsigned char) *tmp) == 'M')
     {
       pat->max *= 1048576;
       tmp++;
index c0097b1bf241a45d8435c32914440345fd16fe02..8e2dd4997739aa4515e0355230b6dc57d8497c65 100644 (file)
--- a/rfc2047.c
+++ b/rfc2047.c
@@ -606,9 +606,9 @@ static int rfc2047_decode_word (char *d, const char *s, size_t len)
        charset[t-pp] = '\0';
        break;
       case 3:
-       if (toupper (*pp) == 'Q')
+       if (toupper ((unsigned char) *pp) == 'Q')
          enc = ENCQUOTEDPRINTABLE;
-       else if (toupper (*pp) == 'B')
+       else if (toupper ((unsigned char) *pp) == 'B')
          enc = ENCBASE64;
        else
        {
index 6d4268106e625b7d242582b813dae97c2a28ac5d..a6d264b36a0803d1a4df599a5b17ef7d316f1f35 100644 (file)
--- a/rfc2231.c
+++ b/rfc2231.c
@@ -135,7 +135,7 @@ void rfc2231_decode_parameters (PARAMETER **headp)
     else
     {
       *s = '\0'; s++; /* let s point to the first character of index. */
-      for (t = s; *t && isdigit (*t); t++)
+      for (t = s; *t && isdigit ((unsigned char) *t); t++)
        ;
       encoded = (*t == '*');
       *t = '\0';
@@ -208,7 +208,9 @@ static void rfc2231_decode_one (char *dest, char *src)
 
   for (d = dest; *src; src++)
   {
-    if (*src == '%' && isxdigit (*(src + 1)) && isxdigit (*(src + 2)))
+    if (*src == '%' &&
+        isxdigit ((unsigned char) *(src + 1)) &&
+        isxdigit ((unsigned char) *(src + 2)))
     {
       *d++ = (hexval (*(src + 1)) << 4) | (hexval (*(src + 2)));
       src += 2;
index b3b9397899fbde4e4a366404dd64e388193a16c9..2732f52b0f463d00ab1867365d944d7f9d8aa23f 100644 (file)
--- a/rfc822.c
+++ b/rfc822.c
@@ -174,7 +174,7 @@ next_token (const char *s, char *token, size_t *tokenlen, size_t tokenmax)
   }
   while (*s)
   {
-    if (ISSPACE (*s) || is_special (*s))
+    if (ISSPACE ((unsigned char) *s) || is_special (*s))
       break;
     if (*tokenlen < tokenmax)
       token[(*tokenlen)++] = *s;
@@ -345,7 +345,7 @@ ADDRESS *rfc822_parse_adrlist (ADDRESS *top, const char *s)
   while (last && last->next)
     last = last->next;
 
-  ws_pending = isspace (*s);
+  ws_pending = isspace ((unsigned char) *s);
   
   SKIPWS (s);
   begin = s;
@@ -479,7 +479,7 @@ ADDRESS *rfc822_parse_adrlist (ADDRESS *top, const char *s)
       }
       s = ps;
     }
-    ws_pending = isspace (*s);
+    ws_pending = isspace ((unsigned char) *s);
     SKIPWS (s);
   }
   
index d96895ea19dbcaf50071a0b46d1d7c5df9c2bc4a..51e6e101f7f47f71fc5d0989801f0bb907fabb79 100644 (file)
@@ -9,8 +9,8 @@ int strncasecmp (char *s1, char *s2, size_t n)
   
   while (*s1 && *s2 && l < n)
   {
-    c1 = tolower (*s1);
-    c2 = tolower (*s2);
+    c1 = tolower ((unsigned char) *s1);
+    c2 = tolower ((unsigned char) *s2);
     if (c1 != c2)
       return (c1 - c2);
     s1++;
@@ -29,8 +29,8 @@ int strcasecmp (char *s1, char *s2)
   
   while (*s1 && *s2)
   {
-    c1 = tolower (*s1);
-    c2 = tolower (*s2);
+    c1 = tolower ((unsigned char) *s1);
+    c2 = tolower ((unsigned char) *s2);
     if (c1 != c2)
       return (c1 - c2);
     s1++;
diff --git a/url.c b/url.c
index 046151d02dfaa789878dd5f50951f22f4835df11..ae2a22dfa02a25f80b920d02f9941803cab990bf 100644 (file)
--- a/url.c
+++ b/url.c
@@ -50,7 +50,8 @@ static void url_pct_decode (char *s)
   for (d = s; *s; s++)
   {
     if (*s == '%' && s[1] && s[2] &&
-       isxdigit (s[1]) && isxdigit (s[2]) &&
+       isxdigit ((unsigned char) s[1]) &&
+        isxdigit ((unsigned char) s[2]) &&
        hexval (s[1]) >= 0 && hexval (s[2]) >= 0)
     {
       *d++ = (hexval (s[1]) << 4) | (hexval (s[2]));