Commit 553ef91d authored by Vincent Lefevre's avatar Vincent Lefevre

Some functions/macros like isspace take an int and require the

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).
parent 8fe7e1b4
......@@ -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)
......
......@@ -844,7 +844,7 @@ static int address_header_decode (char **h)
ADDRESS *a = NULL;
switch (tolower (*s))
switch (tolower ((unsigned char) *s))
{
case 'r':
{
......
......@@ -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;
......
......@@ -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)
{
......
......@@ -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')
{
......
......@@ -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);
......
......@@ -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);
......
......@@ -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, '^');
......
......@@ -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';
......
......@@ -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);
......
......@@ -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')
......
......@@ -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;
}
......
......@@ -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);
......
......@@ -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);
......
......@@ -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]);
}
}
......
......@@ -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++;
......
......@@ -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
{
......
......@@ -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;
......
......@@ -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);
}
......
......@@ -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++;
......
......@@ -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]));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment