# Replace ctype macros, which all expect int argument in the range 0..255 # or EOF (typically -1). I have left a few instances of isspace() and # friends where the input comes from fgetc() or prot_getc(), and # consequently is in the expected range. # # Mostly automatic using find and sed, but I did go back and remove # casts to (unsigned char) [correct but redundant], and (int) [typically # incorrect if the source is signed char, probably put there to stop # the compiler moaning]. # # (Second attempt at this patch) # diff -udNr cyrus-imapd-2.3.14/imap/append.c cyrus-imapd/imap/append.c --- cyrus-imapd-2.3.14/imap/append.c 2009-03-16 00:17:14.000000000 +0000 +++ cyrus-imapd/imap/append.c 2009-03-27 14:33:27.000000000 +0000 @@ -69,6 +69,7 @@ #include "seen.h" #include "retry.h" #include "quota.h" +#include "util.h" #include "message_guid.h" @@ -1047,7 +1048,7 @@ /* see what the last one is */ p = *msgrange + len - 1; - while (isdigit((int) *p) && p > *msgrange) p--; + while (Uisdigit(*p) && p > *msgrange) p--; /* second time, p == msgrange here */ if (*p == ':') wasrange = 1; p++; @@ -1103,7 +1104,7 @@ tail = seenuids + oldlen; /* Scan back to last uid */ - while (tail > seenuids && isdigit((int) tail[-1])) tail--; + while (tail > seenuids && Uisdigit(tail[-1])) tail--; for (p = tail, last_seen=0; *p; p++) last_seen = last_seen * 10 + *p - '0'; if (last_seen && last_seen >= start-1) { if (tail > seenuids && tail[-1] == ':') p = tail - 1; diff -udNr cyrus-imapd-2.3.14/imap/ctl_mboxlist.c cyrus-imapd/imap/ctl_mboxlist.c --- cyrus-imapd-2.3.14/imap/ctl_mboxlist.c 2009-02-09 05:01:56.000000000 +0000 +++ cyrus-imapd/imap/ctl_mboxlist.c 2009-03-27 14:33:27.000000000 +0000 @@ -578,7 +578,7 @@ continue; } *p++ = '\0'; - if (isdigit((int) *p)) { + if (Uisdigit(*p)) { /* new style dump */ mbtype = strtol(p, &p, 10); /* skip trailing space */ diff -udNr cyrus-imapd-2.3.14/imap/cyr_expire.c cyrus-imapd/imap/cyr_expire.c --- cyrus-imapd-2.3.14/imap/cyr_expire.c 2009-02-09 05:01:56.000000000 +0000 +++ cyrus-imapd/imap/cyr_expire.c 2009-03-27 14:33:27.000000000 +0000 @@ -326,7 +326,7 @@ p++; for (i = 0 ; i < 7; i++) { - if (!isxdigit(p[i])) return(0); + if (!Uisxdigit(p[i])) return(0); } if (p[8] != '\0') return(0); diff -udNr cyrus-imapd-2.3.14/imap/global.c cyrus-imapd/imap/global.c --- cyrus-imapd-2.3.14/imap/global.c 2009-02-09 05:01:56.000000000 +0000 +++ cyrus-imapd/imap/global.c 2009-03-27 14:33:27.000000000 +0000 @@ -150,10 +150,10 @@ /* Look up default partition */ config_defpartition = config_getstring(IMAPOPT_DEFAULTPARTITION); for (p = (char *)config_defpartition; *p; p++) { - if (!isalnum((unsigned char) *p)) + if (!Uisalnum(*p)) fatal("defaultpartition option contains non-alphanumeric character", EC_CONFIG); - if (isupper((unsigned char) *p)) *p = tolower((unsigned char) *p); + if (Uisupper(*p)) *p = tolower((unsigned char) *p); } /* Look up umask */ @@ -354,7 +354,7 @@ while (*val) { char *p; - for (p = (char *) val; *p && !isspace((int) *p); p++); + for (p = (char *) val; *p && !Uisspace(*p); p++); len = p-val; if(len >= sizeof(buf)) len = sizeof(buf) - 1; @@ -365,7 +365,7 @@ return 1; } val = p; - while (*val && isspace((int) *val)) val++; + while (*val && Uisspace(*val)) val++; } return 0; @@ -548,12 +548,12 @@ realm++; while (*val) { if (!strncasecmp(val, realm, strlen(realm)) && - (!val[strlen(realm)] || isspace((int) val[strlen(realm)]))) { + (!val[strlen(realm)] || Uisspace(val[strlen(realm)]))) { break; } /* not this realm, try next one */ - while (*val && !isspace((int) *val)) val++; - while (*val && isspace((int) *val)) val++; + while (*val && !Uisspace(*val)) val++; + while (*val && Uisspace(*val)) val++; } if (!*val) { sasl_seterror(conn, 0, "cross-realm login %s denied", diff -udNr cyrus-imapd-2.3.14/imap/imapd.c cyrus-imapd/imap/imapd.c --- cyrus-imapd-2.3.14/imap/imapd.c 2009-03-16 00:17:14.000000000 +0000 +++ cyrus-imapd/imap/imapd.c 2009-03-27 14:33:27.000000000 +0000 @@ -1049,10 +1049,10 @@ eatline(imapd_in, c); continue; } - if (islower((unsigned char) cmd.s[0])) + if (Uislower(cmd.s[0])) cmd.s[0] = toupper((unsigned char) cmd.s[0]); for (p = &cmd.s[1]; *p; p++) { - if (isupper((unsigned char) *p)) *p = tolower((unsigned char) *p); + if (Uisupper(*p)) *p = tolower((unsigned char) *p); } /* if we need to force a kick, do so */ @@ -2748,7 +2748,7 @@ /* Read size from literal */ isnowait = 0; *size = 0; - for (++p; *p && isdigit((int) *p); p++) { + for (++p; *p && Uisdigit(*p); p++) { sawdigit++; if (*size > (UINT_MAX - (*p - '0')) / 10) return IMAP_MESSAGE_TOO_LARGE; @@ -3638,10 +3638,10 @@ */ #define PARSE_PARTIAL(start_octet, octet_count) \ (start_octet) = (octet_count) = 0; \ - if (*p == '<' && isdigit((int) p[1])) { \ - (start_octet) = p[1] - '0'; \ + if (*p == '<' && Uisdigit(p[1])) { \ + (start_octet) = p[1] - '0'; \ p += 2; \ - while (isdigit((int) *p)) { \ + while (Uisdigit((int) *p)) { \ (start_octet) = \ (start_octet) * 10 + *p++ - '0'; \ } \ @@ -3651,7 +3651,7 @@ p[0] = '>'; p[1] = '\0'; /* clip off the octet count \ (its not used in the reply) */ \ p += 2; \ - while (isdigit((int) *p)) { \ + while (Uisdigit(*p)) { \ (octet_count) = \ (octet_count) * 10 + *p++ - '0'; \ } \ @@ -3731,10 +3731,10 @@ else { fetchitems |= FETCH_SETSEEN; } - while (isdigit((int) *p) || *p == '.') { - if (*p == '.' && !isdigit((int) p[-1])) break; + while (Uisdigit(*p) || *p == '.') { + if (*p == '.' && !Uisdigit(p[-1])) break; /* Part number cannot begin with '0' */ - if (*p == '0' && !isdigit((int) p[-1])) break; + if (*p == '0' && !Uisdigit(p[-1])) break; p++; } @@ -3772,10 +3772,10 @@ else { fetchitems |= FETCH_SETSEEN; } - while (isdigit((int) *p) || *p == '.') { - if (*p == '.' && !isdigit((int) p[-1])) break; + while (Uisdigit(*p) || *p == '.') { + if (*p == '.' && !Uisdigit(p[-1])) break; /* Obsolete section 0 can only occur before close brace */ - if (*p == '0' && !isdigit((int) p[-1]) && p[1] != ']') break; + if (*p == '0' && !Uisdigit(p[-1]) && p[1] != ']') break; p++; } @@ -4161,7 +4161,7 @@ memset(&fetchargs, 0, sizeof(struct fetchargs)); for (pc = msgno; *pc; pc++) { - if (!isdigit((int) *pc)) break; + if (!Uisdigit(*pc)) break; } if (*pc || !*msgno) { prot_printf(imapd_out, "%s BAD Invalid message number\r\n", tag); @@ -4193,8 +4193,8 @@ else { fetchargs.fetchitems = FETCH_SETSEEN; } - while (isdigit((int) *p) || *p == '.') { - if (*p == '.' && (p == section || !isdigit((int) p[1]))) break; + while (Uisdigit(*p) || *p == '.') { + if (*p == '.' && (p == section || !Uisdigit(p[1]))) break; p++; } if (p == section || *p != ']' || p[1]) { @@ -4212,7 +4212,7 @@ } for (pc = start; *pc; pc++) { - if (!isdigit((int) *pc)) break; + if (!Uisdigit(*pc)) break; prev = fetchargs.start_octet; fetchargs.start_octet = fetchargs.start_octet*10 + *pc - '0'; if(fetchargs.start_octet < prev) { @@ -4229,7 +4229,7 @@ prev = fetchargs.octet_count; for (pc = count; *pc; pc++) { - if (!isdigit((int) *pc)) break; + if (!Uisdigit(*pc)) break; prev = fetchargs.octet_count; fetchargs.octet_count = fetchargs.octet_count*10 + *pc - '0'; if(fetchargs.octet_count < prev) { @@ -6606,7 +6606,7 @@ if (arg.s[0] == '\0') goto badlist; newquota = 0; for (p = arg.s; *p; p++) { - if (!isdigit((int) *p)) goto badlist; + if (!Uisdigit(*p)) goto badlist; newquota = newquota * 10 + *p - '0'; if (newquota < 0) goto badlist; /* overflow */ } @@ -7650,7 +7650,7 @@ if (c != ' ') goto missingarg; c = getword(imapd_in, &arg); size = 0; - for (p = arg.s; *p && isdigit((int) *p); p++) { + for (p = arg.s; *p && Uisdigit(*p); p++) { size = size * 10 + *p - '0'; /* if (size < 0) goto badnumber; */ } @@ -7665,7 +7665,7 @@ !strcmp(criteria.s, "modseq")) { if (c != ' ') goto missingarg; c = getword(imapd_in, &arg); - for (p = arg.s; *p && isdigit((int) *p); p++) { + for (p = arg.s; *p && Uisdigit(*p); p++) { searchargs->modseq = searchargs->modseq * 10 + *p - '0'; } if (!arg.s || *p) goto badnumber; @@ -7777,7 +7777,7 @@ if (c != ' ') goto missingarg; c = getword(imapd_in, &arg); size = 0; - for (p = arg.s; *p && isdigit((int) *p); p++) { + for (p = arg.s; *p && Uisdigit(*p); p++) { size = size * 10 + *p - '0'; /* if (size < 0) goto badnumber; */ } @@ -9686,7 +9686,7 @@ const char *c; unsigned char msn, lsn; - for (c = hex, i = 0; *c && isxdigit((int) *c); c++) { + for (c = hex, i = 0; *c && Uisxdigit(*c); c++) { msn = (*c > '9') ? tolower((int) *c) - 'a' + 10 : *c - '0'; c++; lsn = (*c > '9') ? tolower((int) *c) - 'a' + 10 : *c - '0'; diff -udNr cyrus-imapd-2.3.14/imap/imap_proxy.c cyrus-imapd/imap/imap_proxy.c --- cyrus-imapd-2.3.14/imap/imap_proxy.c 2009-02-09 05:01:56.000000000 +0000 +++ cyrus-imapd/imap/imap_proxy.c 2009-03-27 14:33:27.000000000 +0000 @@ -62,6 +62,7 @@ #include "mboxname.h" #include "mupdate-client.h" #include "prot.h" +#include "util.h" #include "xmalloc.h" #include "xstrlcat.h" @@ -271,7 +272,7 @@ eol[i-1] == '\n' && eol[i-2] == '\r' && eol[i-3] == '}') { /* possible literal */ i -= 4; - while (i > 0 && eol[i] != '{' && isdigit((int) eol[i])) { + while (i > 0 && eol[i] != '{' && Uisdigit(eol[i])) { i--; } if (eol[i] == '{') { @@ -392,7 +393,7 @@ nonsynch = 1; i--; } - while (i > 0 && eol[i] != '{' && isdigit((int) eol[i])) { + while (i > 0 && eol[i] != '{' && Uisdigit(eol[i])) { i--; } if (eol[i] == '{') { diff -udNr cyrus-imapd-2.3.14/imap/index.c cyrus-imapd/imap/index.c --- cyrus-imapd-2.3.14/imap/index.c 2009-03-16 00:17:16.000000000 +0000 +++ cyrus-imapd/imap/index.c 2009-03-27 14:33:27.000000000 +0000 @@ -3894,7 +3894,7 @@ * resetting the end of the string as we go. */ for (x = s + strlen(s) - 1; x >= s;) { - if (isspace((int) *x)) { /* whitespace? */ + if (Uisspace(*x)) { /* whitespace? */ *x = '\0'; /* yes, trim it */ x--; /* skip past it */ } @@ -3914,7 +3914,7 @@ * skipping over stuff we don't care about. */ for (base = s; base;) { - if (isspace((int) *base)) base++; /* whitespace? */ + if (Uisspace(*base)) base++; /* whitespace? */ /* possible refwd */ else if ((!strncasecmp(base, "re", 2) && /* "re"? */ @@ -3925,7 +3925,7 @@ (x = base + 2))) { /* yes, skip past it */ int count = 0; /* init counter */ - while (isspace((int) *x)) x++; /* skip whitespace */ + while (Uisspace(*x)) x++; /* skip whitespace */ if (*x == '[') { /* start of blob? */ for (x++; x;) { /* yes, get count */ @@ -3954,7 +3954,7 @@ break; /* no, we're done */ } - while (isspace((int) *x)) x++; /* skip whitespace */ + while (Uisspace(*x)) x++; /* skip whitespace */ if (*x == ':') { /* ending colon? */ base = x + 1; /* yes, skip past it */ diff -udNr cyrus-imapd-2.3.14/imap/lmtpengine.c cyrus-imapd/imap/lmtpengine.c --- cyrus-imapd-2.3.14/imap/lmtpengine.c 2008-10-08 16:47:08.000000000 +0100 +++ cyrus-imapd/imap/lmtpengine.c 2009-03-27 14:33:27.000000000 +0000 @@ -479,11 +479,11 @@ p++; if (*p == '[') { p++; - while (isdigit((int) *p) || *p == '.') p++; + while (Uisdigit(*p) || *p == '.') p++; if (*p++ != ']') return 0; } else { - while (isalnum((int) *p) || *p == '.' || *p == '-') p++; + while (Uisalnum(*p) || *p == '.' || *p == '-') p++; } if (*p == ',' && p[1] == '@') p++; else if (*p == ':' && p[1] != '@') p++; @@ -519,11 +519,11 @@ p++; if (*p == '[') { p++; - while (isdigit((int) *p) || *p == '.') p++; + while (Uisdigit(*p) || *p == '.') p++; if (*p++ != ']') return 0; } else { - while (isalnum((int) *p) || *p == '.' || *p == '-') p++; + while (Uisalnum(*p) || *p == '.' || *p == '-') p++; } } @@ -1424,7 +1424,7 @@ } tmp += 5; /* make sure we have a value */ - if (!isdigit((int) *tmp)) { + if (!Uisdigit(*tmp)) { prot_printf(pout, "501 5.5.2 SIZE requires a value\r\n"); goto nextcmd; @@ -1738,9 +1738,9 @@ if (strlen(s) < 3) return -1; /* check to make sure 0-2 are digits */ - if ((isdigit((int) s[0])==0) || - (isdigit((int) s[1])==0) || - (isdigit((int) s[2])==0)) + if ((Uisdigit(s[0])==0) || + (Uisdigit(s[1])==0) || + (Uisdigit(s[2])==0)) { return -1; } diff -udNr cyrus-imapd-2.3.14/imap/lmtp_sieve.c cyrus-imapd/imap/lmtp_sieve.c --- cyrus-imapd-2.3.14/imap/lmtp_sieve.c 2009-02-09 05:01:57.000000000 +0000 +++ cyrus-imapd/imap/lmtp_sieve.c 2009-03-27 14:33:27.000000000 +0000 @@ -625,7 +625,7 @@ /* check that subject is sane */ sl = strlen(src->subj); for (i = 0; i < sl; i++) - if (iscntrl((int) src->subj[i])) { + if (Uiscntrl(src->subj[i])) { src->subj[i] = '\0'; break; } diff -udNr cyrus-imapd-2.3.14/imap/mailbox.c cyrus-imapd/imap/mailbox.c --- cyrus-imapd-2.3.14/imap/mailbox.c 2009-02-09 05:25:20.000000000 +0000 +++ cyrus-imapd/imap/mailbox.c 2009-03-27 14:33:27.000000000 +0000 @@ -3072,7 +3072,7 @@ if (name[0] == '.') continue; /* skip non-message files */ - while (*p && isdigit((int)(*p))) p++; + while (*p && Uisdigit(*p)) p++; if (p[0] != '.' || p[1] != '\0') continue; if(newfname->len + strlen(name) >= sizeof(newfname->buf)) { diff -udNr cyrus-imapd-2.3.14/imap/mbdump.c cyrus-imapd/imap/mbdump.c --- cyrus-imapd-2.3.14/imap/mbdump.c 2009-02-09 05:01:58.000000000 +0000 +++ cyrus-imapd/imap/mbdump.c 2009-03-27 14:33:27.000000000 +0000 @@ -335,7 +335,7 @@ if (name[0] == '.') continue; /* skip non-message files */ - while (*p && isdigit((int)(*p))) p++; + while (*p && Uisdigit(*p)) p++; if (p[0] != '.' || p[1] != '\0') continue; /* ensure (number) is >= our target uid */ @@ -608,7 +608,7 @@ goto done; } for (p = data.s; *p; p++) { - if (!isdigit((int) *p)) { + if (!Uisdigit(*p)) { r = IMAP_PROTOCOL_ERROR; goto done; } diff -udNr cyrus-imapd-2.3.14/imap/mboxlist.c cyrus-imapd/imap/mboxlist.c --- cyrus-imapd-2.3.14/imap/mboxlist.c 2009-02-09 05:04:38.000000000 +0000 +++ cyrus-imapd/imap/mboxlist.c 2009-03-27 14:33:27.000000000 +0000 @@ -514,15 +514,15 @@ defaultacl = identifier = xstrdup(config_getstring(IMAPOPT_DEFAULTACL)); for (;;) { - while (*identifier && isspace((int) *identifier)) identifier++; + while (*identifier && Uisspace(*identifier)) identifier++; rights = identifier; - while (*rights && !isspace((int) *rights)) rights++; + while (*rights && !Uisspace(*rights)) rights++; if (!*rights) break; *rights++ = '\0'; - while (*rights && isspace((int) *rights)) rights++; + while (*rights && Uisspace(*rights)) rights++; if (!*rights) break; p = rights; - while (*p && !isspace((int) *p)) p++; + while (*p && !Uisspace(*p)) p++; if (*p) *p++ = '\0'; cyrus_acl_set(&acl, identifier, ACL_MODE_SET, cyrus_acl_strtomask(rights), (cyrus_acl_canonproc_t *)0, (void *)0); diff -udNr cyrus-imapd-2.3.14/imap/message.c cyrus-imapd/imap/message.c --- cyrus-imapd-2.3.14/imap/message.c 2009-03-06 03:52:55.000000000 +0000 +++ cyrus-imapd/imap/message.c 2009-03-27 14:33:27.000000000 +0000 @@ -906,7 +906,7 @@ if (!hdr) return; /* Find end of encoding token */ - for (p = hdr; *p && !isspace((int) *p) && *p != '('; p++) { + for (p = hdr; *p && !Uisspace(*p) && *p != '('; p++) { if (*p < ' ' || strchr(TSPECIALS, *p)) return; } len = p - hdr; @@ -919,7 +919,7 @@ *hdrp = xmalloc(len + 1); strlcpy(*hdrp, hdr, len + 1); for (p = *hdrp; *p; p++) { - if (islower((int) *p)) *p = toupper((int) *p); + if (Uislower(*p)) *p = toupper((int) *p); } } @@ -1025,7 +1025,7 @@ /* Find end of type token */ type = hdr; - for (; *hdr && !isspace((int) *hdr) && *hdr != '/' && *hdr != '('; hdr++) { + for (; *hdr && !Uisspace(*hdr) && *hdr != '/' && *hdr != '('; hdr++) { if (*hdr < ' ' || strchr(TSPECIALS, *hdr)) return; } typelen = hdr - type; @@ -1043,7 +1043,7 @@ /* Find end of subtype token */ subtype = hdr; - for (; *hdr && !isspace((int) *hdr) && *hdr != ';' && *hdr != '('; hdr++) { + for (; *hdr && !Uisspace(*hdr) && *hdr != ';' && *hdr != '('; hdr++) { if (*hdr < ' ' || strchr(TSPECIALS, *hdr)) return; } subtypelen = hdr - subtype; @@ -1058,12 +1058,12 @@ body->type = xmalloc(typelen + 1); strlcpy(body->type, type, typelen + 1); for (p = body->type; *p; p++) { - if (islower((int) *p)) *p = toupper((int) *p); + if (Uislower(*p)) *p = toupper((int) *p); } body->subtype = xmalloc(subtypelen + 1); strlcpy(body->subtype, subtype, subtypelen + 1); for (p = body->subtype; *p; p++) { - if (islower((int) *p)) *p = toupper((int) *p); + if (Uislower(*p)) *p = toupper((int) *p); } /* Parse parameter list */ @@ -1094,7 +1094,7 @@ /* Find end of disposition token */ disposition = hdr; - for (; *hdr && !isspace((int) *hdr) && *hdr != ';' && *hdr != '('; hdr++) { + for (; *hdr && !Uisspace(*hdr) && *hdr != ';' && *hdr != '('; hdr++) { if (*hdr < ' ' || strchr(TSPECIALS, *hdr)) return; } dispositionlen = hdr - disposition; @@ -1110,7 +1110,7 @@ strlcpy(body->disposition, disposition, dispositionlen + 1); for (p = body->disposition; *p; p++) { - if (islower((int) *p)) *p = toupper((int) *p); + if (Uislower(*p)) *p = toupper((int) *p); } /* Parse parameter list */ @@ -1142,7 +1142,7 @@ /* Find end of attribute */ attribute = hdr; - for (; *hdr && !isspace((int) *hdr) && *hdr != '=' && *hdr != '('; hdr++) { + for (; *hdr && !Uisspace(*hdr) && *hdr != '=' && *hdr != '('; hdr++) { if (*hdr < ' ' || strchr(TSPECIALS, *hdr)) return; } attributelen = hdr - attribute; @@ -1176,7 +1176,7 @@ if (!*hdr++) return; } else { - for (; *hdr && !isspace((int) *hdr) && *hdr != ';' && *hdr != '('; hdr++) { + for (; *hdr && !Uisspace(*hdr) && *hdr != ';' && *hdr != '('; hdr++) { if (*hdr < ' ' || strchr(TSPECIALS, *hdr)) return; } } @@ -1195,7 +1195,7 @@ strlcpy(param->attribute, attribute, attributelen + 1); for (p = param->attribute; *p; p++) { - if (islower((int) *p)) *p = toupper((int) *p); + if (Uislower(*p)) *p = toupper((int) *p); } param->value = xmalloc(valuelen + 1); if (*value == '\"') { @@ -1411,8 +1411,8 @@ /* Find end of value */ value = hdr; - for (; *hdr && !isspace((int) *hdr) && *hdr != ',' && *hdr != '('; hdr++) { - if (*hdr != '-' && !isalpha(((int) *hdr))) return; + for (; *hdr && !Uisspace(*hdr) && *hdr != ',' && *hdr != '('; hdr++) { + if (*hdr != '-' && !Uisalpha((*hdr))) return; } valuelen = hdr - value; @@ -1429,7 +1429,7 @@ strlcpy(param->value, value, valuelen + 1); for (p = param->value; *p; p++) { - if (islower((int) *p)) *p = toupper((int) *p); + if (Uislower(*p)) *p = toupper((int) *p); } /* Get ready to parse the next parameter */ @@ -1462,12 +1462,12 @@ message_parse_rfc822space(&hdr); if (!hdr) goto baddate; - if (isalpha((int) *hdr)) { + if (Uisalpha(*hdr)) { /* Day name -- skip over it */ hdr++; - if (!isalpha((int) *hdr)) goto baddate; + if (!Uisalpha(*hdr)) goto baddate; hdr++; - if (!isalpha((int) *hdr)) goto baddate; + if (!Uisalpha(*hdr)) goto baddate; hdr++; message_parse_rfc822space(&hdr); if (!hdr || *hdr++ != ',') goto baddate; @@ -1475,9 +1475,9 @@ if (!hdr) goto baddate; } - if (!isdigit((int) *hdr)) goto baddate; + if (!Uisdigit(*hdr)) goto baddate; tm.tm_mday = *hdr++ - '0'; - if (isdigit((int) *hdr)) { + if (Uisdigit(*hdr)) { tm.tm_mday = tm.tm_mday*10 + *hdr++ - '0'; } @@ -1485,11 +1485,11 @@ message_parse_rfc822space(&hdr); if (!hdr) goto baddate; month[0] = *hdr++; - if (!isalpha((int) month[0])) goto baddate; + if (!Uisalpha(month[0])) goto baddate; month[1] = *hdr++; - if (!isalpha((int) month[1])) goto baddate; + if (!Uisalpha(month[1])) goto baddate; month[2] = *hdr++; - if (!isalpha((int) month[2])) goto baddate; + if (!Uisalpha(month[2])) goto baddate; month[3] = '\0'; lcase(month); for (tm.tm_mon = 0; tm.tm_mon < 12; tm.tm_mon++) { @@ -1499,15 +1499,15 @@ /* Parse year */ message_parse_rfc822space(&hdr); - if (!hdr || !isdigit((int) *hdr)) goto baddate; + if (!hdr || !Uisdigit(*hdr)) goto baddate; tm.tm_year = *hdr++ - '0'; - if (!isdigit((int) *hdr)) goto baddate; + if (!Uisdigit(*hdr)) goto baddate; tm.tm_year = tm.tm_year * 10 + *hdr++ - '0'; - if (isdigit((int) *hdr)) { + if (Uisdigit(*hdr)) { if (tm.tm_year < 19) goto baddate; tm.tm_year -= 19; tm.tm_year = tm.tm_year * 10 + *hdr++ - '0'; - if (!isdigit((int) *hdr)) goto baddate; + if (!Uisdigit(*hdr)) goto baddate; tm.tm_year = tm.tm_year * 10 + *hdr++ - '0'; } else { if (tm.tm_year < 70) { @@ -1517,7 +1517,7 @@ tm.tm_year += 100; } } - if (isdigit((int) *hdr)) { + if (Uisdigit(*hdr)) { /* five-digit date */ goto baddate; } @@ -1525,23 +1525,23 @@ message_parse_rfc822space(&hdr); if (hdr && (flags & PARSE_TIME)) { /* Parse hour */ - if (!hdr || !isdigit((int) *hdr)) goto badtime; + if (!hdr || !Uisdigit(*hdr)) goto badtime; tm.tm_hour = *hdr++ - '0'; - if (!isdigit((int) *hdr)) goto badtime; + if (!Uisdigit(*hdr)) goto badtime; tm.tm_hour = tm.tm_hour * 10 + *hdr++ - '0'; if (!hdr || *hdr++ != ':') goto badtime; /* Parse min */ - if (!hdr || !isdigit((int) *hdr)) goto badtime; + if (!hdr || !Uisdigit(*hdr)) goto badtime; tm.tm_min = *hdr++ - '0'; - if (!isdigit((int) *hdr)) goto badtime; + if (!Uisdigit(*hdr)) goto badtime; tm.tm_min = tm.tm_min * 10 + *hdr++ - '0'; if (*hdr == ':') { /* Parse sec */ - if (!++hdr || !isdigit((int) *hdr)) goto badtime; + if (!++hdr || !Uisdigit(*hdr)) goto badtime; tm.tm_sec = *hdr++ - '0'; - if (!isdigit((int) *hdr)) goto badtime; + if (!Uisdigit(*hdr)) goto badtime; tm.tm_sec = tm.tm_sec * 10 + *hdr++ - '0'; } @@ -1552,22 +1552,22 @@ /* Parse numeric offset */ int east = (*hdr++ == '-'); - if (!hdr || !isdigit((int) *hdr)) goto badzone; + if (!hdr || !Uisdigit(*hdr)) goto badzone; zone_off = *hdr++ - '0'; - if (!hdr || !isdigit((int) *hdr)) goto badzone; + if (!hdr || !Uisdigit(*hdr)) goto badzone; zone_off = zone_off * 10 + *hdr++ - '0'; - if (!hdr || !isdigit((int) *hdr)) goto badzone; + if (!hdr || !Uisdigit(*hdr)) goto badzone; zone_off = zone_off * 6 + *hdr++ - '0'; - if (!hdr || !isdigit((int) *hdr)) goto badzone; + if (!hdr || !Uisdigit(*hdr)) goto badzone; zone_off = zone_off * 10 + *hdr++ - '0'; if (east) zone_off = -zone_off; } - else if (isalpha((unsigned char) *hdr)) { + else if (Uisalpha(*hdr)) { char zone[4]; zone[0] = *hdr++; - if (!isalpha((unsigned char) *hdr)) { + if (!Uisalpha(*hdr)) { /* Parse military (single-char) zone */ zone[1] = '\0'; lcase(zone); @@ -1584,7 +1584,7 @@ } else { zone[1] = *hdr++; - if (!isalpha((unsigned char) *hdr)) { + if (!Uisalpha(*hdr)) { /* Parse UT (universal time) */ zone[2] = '\0'; lcase(zone); @@ -1644,7 +1644,7 @@ int commentlevel = 0; if (!p) return; - while (*p && (isspace((int) *p) || *p == '(')) { + while (*p && (Uisspace(*p) || *p == '(')) { if (*p == '\n') { p++; if (*p != ' ' && *p != '\t') { @@ -1935,7 +1935,7 @@ len = strlen(boundaries[i]); if (!strncmp(s, boundaries[i], len)) { if (s[len] == '-' && s[len+1] == '-') *boundaryct = i; - else if (!rfc2046_strict && s[len] && !isspace((int) s[len])) { + else if (!rfc2046_strict && s[len] && !Uisspace(s[len])) { /* Allow substring matches in the boundary. * * If rfc2046_strict is enabled, boundaries containing diff -udNr cyrus-imapd-2.3.14/imap/message_guid.c cyrus-imapd/imap/message_guid.c --- cyrus-imapd-2.3.14/imap/message_guid.c 2008-03-24 17:09:18.000000000 +0000 +++ cyrus-imapd/imap/message_guid.c 2009-03-27 14:33:27.000000000 +0000 @@ -49,6 +49,7 @@ #include "assert.h" #include "global.h" #include "message_guid.h" +#include "util.h" #ifdef HAVE_SSL #include @@ -294,11 +295,11 @@ guid->status = GUID_NULL; for (i = 0; i < MESSAGE_GUID_SIZE; i++, v++) { - if (!isxdigit((int) *p)) return(0); + if (!Uisxdigit(*p)) return(0); msn = (*p > '9') ? tolower((int) *p) - 'a' + 10 : *p - '0'; p++; - if (!isxdigit((int) *p)) return(0); + if (!Uisxdigit(*p)) return(0); lsn = (*p > '9') ? tolower((int) *p) - 'a' + 10 : *p - '0'; p++; diff -udNr cyrus-imapd-2.3.14/imap/mupdate.c cyrus-imapd/imap/mupdate.c --- cyrus-imapd-2.3.14/imap/mupdate.c 2009-02-09 05:01:58.000000000 +0000 +++ cyrus-imapd/imap/mupdate.c 2009-03-27 14:33:27.000000000 +0000 @@ -755,11 +755,11 @@ goto nextcmd; } - if (islower((unsigned char) c->cmd.s[0])) { + if (Uislower(c->cmd.s[0])) { c->cmd.s[0] = toupper((unsigned char) c->cmd.s[0]); } for (p = &(c->cmd.s[1]); *p; p++) { - if (isupper((unsigned char) *p)) *p = tolower((unsigned char) *p); + if (Uisupper(*p)) *p = tolower((unsigned char) *p); } switch (c->cmd.s[0]) { diff -udNr cyrus-imapd-2.3.14/imap/mupdate-client.c cyrus-imapd/imap/mupdate-client.c --- cyrus-imapd-2.3.14/imap/mupdate-client.c 2008-10-08 16:47:08.000000000 +0100 +++ cyrus-imapd/imap/mupdate-client.c 2009-03-27 14:33:27.000000000 +0000 @@ -77,6 +77,7 @@ #include "mupdate.h" #include "prot.h" #include "protocol.h" +#include "util.h" #include "xmalloc.h" #include "xstrlcpy.h" #include "xstrlcat.h" @@ -500,11 +501,11 @@ break; } - if (islower((unsigned char) handle->cmd.s[0])) { + if (Uislower(handle->cmd.s[0])) { handle->cmd.s[0] = toupper((unsigned char) handle->cmd.s[0]); } for (p = &(handle->cmd.s[1]); *p; p++) { - if (islower((unsigned char) *p)) + if (Uislower(*p)) *p = toupper((unsigned char) *p); } diff -udNr cyrus-imapd-2.3.14/imap/nntpd.c cyrus-imapd/imap/nntpd.c --- cyrus-imapd-2.3.14/imap/nntpd.c 2009-02-09 05:01:58.000000000 +0000 +++ cyrus-imapd/imap/nntpd.c 2009-03-27 14:33:27.000000000 +0000 @@ -839,10 +839,10 @@ eatline(nntp_in, c); continue; } - if (islower((unsigned char) cmd.s[0])) + if (Uislower(cmd.s[0])) cmd.s[0] = toupper((unsigned char) cmd.s[0]); for (p = &cmd.s[1]; *p; p++) { - if (isupper((unsigned char) *p)) *p = tolower((unsigned char) *p); + if (Uisupper(*p)) *p = tolower((unsigned char) *p); } /* Ihave/Takethis only allowed for feeders */ @@ -1590,7 +1590,7 @@ char *p = str; int result = 0; - while (*p && isdigit((int) *p)) { + while (*p && Uisdigit(*p)) { result = result * 10 + *p++ - '0'; if (result < 0) { /* xxx overflow */ @@ -2921,7 +2921,7 @@ for (p = groups;; p += n) { /* skip whitespace */ - while (p && *p && (isspace((int) *p) || *p == ',')) p++; + while (p && *p && (Uisspace(*p) || *p == ',')) p++; if (!p || !*p) return 0; @@ -3098,7 +3098,7 @@ for (p = postto[0];; p += n) { /* skip whitespace */ while (p && *p && - (isspace((int) *p) || *p == ',')) p++; + (Uisspace(*p) || *p == ',')) p++; if (!p || !*p) break; /* find end of group name */ @@ -3359,7 +3359,7 @@ /* isolate newsgroup */ group = msg->control + 8; /* skip "newgroup" */ - while (isspace((int) *group)) group++; + while (Uisspace(*group)) group++; snprintf(mailboxname, sizeof(mailboxname), "%s%.*s", newsprefix, (int) strcspn(group, " \t\r\n"), group); @@ -3382,7 +3382,7 @@ /* isolate newsgroup */ group = msg->control + 7; /* skip "rmgroup" */ - while (isspace((int) *group)) group++; + while (Uisspace(*group)) group++; snprintf(mailboxname, sizeof(mailboxname), "%s%.*s", newsprefix, (int) strcspn(group, " \t\r\n"), group); @@ -3407,7 +3407,7 @@ /* isolate old newsgroup */ group = msg->control + 7; /* skip "mvgroup" */ - while (isspace((int) *group)) group++; + while (Uisspace(*group)) group++; len = strcspn(group, " \t\r\n"); snprintf(oldmailboxname, sizeof(oldmailboxname), "%s%.*s", @@ -3415,7 +3415,7 @@ /* isolate new newsgroup */ group += len; /* skip old newsgroup */ - while (isspace((int) *group)) group++; + while (Uisspace(*group)) group++; len = strcspn(group, " \t\r\n"); snprintf(newmailboxname, sizeof(newmailboxname), "%s%.*s", @@ -3530,7 +3530,7 @@ end = p; /* skip whitespace */ - while (p && *p && (isspace((int) *p) || *p == ',')) p++; + while (p && *p && (Uisspace(*p) || *p == ',')) p++; if (!p || !*p) break; @@ -3981,7 +3981,7 @@ while (cur_peer) { /* eat any leading whitespace */ - while (isspace(*cur_peer)) cur_peer++; + while (Uisspace(*cur_peer)) cur_peer++; /* find end of peer */ if ((next_peer = strchr(cur_peer, ' ')) || diff -udNr cyrus-imapd-2.3.14/imap/pop3d.c cyrus-imapd/imap/pop3d.c --- cyrus-imapd-2.3.14/imap/pop3d.c 2009-02-09 05:01:58.000000000 +0000 +++ cyrus-imapd/imap/pop3d.c 2009-03-27 14:33:27.000000000 +0000 @@ -787,12 +787,12 @@ if (p > inputbuf && p[-1] == '\r') *--p = '\0'; /* Parse into keword and argument */ - for (p = inputbuf; *p && !isspace((int) *p); p++); + for (p = inputbuf; *p && !Uisspace(*p); p++); if (*p) { *p++ = '\0'; arg = p; if (strcasecmp(inputbuf, "pass") != 0) { - while (*arg && isspace((int) *arg)) { + while (*arg && Uisspace(*arg)) { arg++; } } @@ -1440,10 +1440,10 @@ * must accept an optional second argument as an initial client * response (base64 encoded!). */ - while (*arg && !isspace((int) *arg)) { + while (*arg && !Uisspace(*arg)) { arg++; } - if (isspace((int) *arg)) { + if (Uisspace(*arg)) { /* null terminate authtype, get argument */ *arg++ = '\0'; } else { @@ -1772,11 +1772,11 @@ char *p = *ptr; int result = 0; - if (!isdigit((int) *p)) { + if (!Uisdigit(*p)) { *ptr = 0; return -1; } - while (*p && isdigit((int) *p)) { + while (*p && Uisdigit(*p)) { result = result * 10 + *p++ - '0'; if (result < 0) { /* xxx overflow */ @@ -1784,7 +1784,7 @@ } if (*p) { - while (*p && isspace((int) *p)) p++; + while (*p && Uisspace(*p)) p++; *ptr = p; } else *ptr = 0; diff -udNr cyrus-imapd-2.3.14/imap/reconstruct.c cyrus-imapd/imap/reconstruct.c --- cyrus-imapd-2.3.14/imap/reconstruct.c 2009-02-11 18:53:04.000000000 +0000 +++ cyrus-imapd/imap/reconstruct.c 2009-03-27 14:33:27.000000000 +0000 @@ -1006,11 +1006,11 @@ goto bail; } while ((dirent = readdir(dirp))!=NULL) { - if (!isdigit((int) (dirent->d_name[0])) || dirent->d_name[0] == '0') + if (!Uisdigit((dirent->d_name[0])) || dirent->d_name[0] == '0') continue; p = dirent->d_name; msg = 0; - while (isdigit((int) *p)) { + while (Uisdigit(*p)) { msg = msg * 10 + *p++ - '0'; } if (*p++ != '.') continue; diff -udNr cyrus-imapd-2.3.14/imap/seen_bigdb.c cyrus-imapd/imap/seen_bigdb.c --- cyrus-imapd-2.3.14/imap/seen_bigdb.c 2008-03-24 17:09:19.000000000 +0000 +++ cyrus-imapd/imap/seen_bigdb.c 2009-03-27 15:41:56.000000000 +0000 @@ -65,6 +65,7 @@ #include "mailbox.h" #include "imap_err.h" #include "exitcodes.h" +#include "util.h" #include "cyrusdb.h" #include "seen.h" @@ -208,7 +209,7 @@ *lastreadptr = strtol(data, &p, 10); data = p; *lastuidptr = strtol(data, &p, 10); data = p; *lastchangeptr = strtol(data, &p, 10); data = p; - while (isspace((int) *p) && p < dend) p++; data = p; + while (Uisspace(*p) && p < dend) p++; data = p; uidlen = dend - data; *seenuidsptr = xmalloc(uidlen + 1); memcpy(*seenuidsptr, data, uidlen); diff -udNr cyrus-imapd-2.3.14/imap/seen_db.c cyrus-imapd/imap/seen_db.c --- cyrus-imapd-2.3.14/imap/seen_db.c 2008-08-27 09:28:47.000000000 +0100 +++ cyrus-imapd/imap/seen_db.c 2009-03-27 14:33:27.000000000 +0000 @@ -253,10 +253,10 @@ *lastreadptr = strtol(buf, (char **) &p, 10); buf = p; *lastuidptr = strtol(buf, (char **) &p, 10); buf = p; *lastchangeptr = strtol(buf, (char **) &p, 10); buf = p; - while (isspace((int) *p)) p++; + while (Uisspace(*p)) p++; buf = p; /* Scan for end of uids */ - while (p < base + offset + linelen && !isspace((int) *p)) p++; + while (p < base + offset + linelen && !Uisspace(*p)) p++; *seenuidsptr = xmalloc(p - buf + 1); strlcpy(*seenuidsptr, buf, p - buf + 1); @@ -321,7 +321,7 @@ *lastreadptr = strtol(data, &p, 10); data = p; *lastuidptr = strtol(data, &p, 10); data = p; *lastchangeptr = strtol(data, &p, 10); data = p; - while (p < dend && isspace((int) *p)) p++; data = p; + while (p < dend && Uisspace(*p)) p++; data = p; uidlen = dend - data; *seenuidsptr = xmalloc(uidlen + 1); memcpy(*seenuidsptr, data, uidlen); diff -udNr cyrus-imapd-2.3.14/imap/seen_local.c cyrus-imapd/imap/seen_local.c --- cyrus-imapd-2.3.14/imap/seen_local.c 2008-03-24 17:09:19.000000000 +0000 +++ cyrus-imapd/imap/seen_local.c 2009-03-27 15:42:10.000000000 +0000 @@ -65,6 +65,7 @@ #include "retry.h" #include "mailbox.h" #include "imap_err.h" +#include "util.h" #include "xmalloc.h" #include "seen.h" @@ -188,7 +189,7 @@ left = length - namelen; /* Parse last-read timestamp */ - while (left && isdigit((int) *buf)) { + while (left && Uisdigit(*buf)) { *lastreadptr = *lastreadptr * 10 + *buf++ - '0'; left--; } @@ -198,7 +199,7 @@ } /* Parse last-read uid */ - while (left && isdigit((int) *buf)) { + while (left && Uisdigit(*buf)) { *lastuidptr = *lastuidptr * 10 + *buf++ - '0'; left--; } @@ -209,12 +210,12 @@ /* Scan for end of uids or last-change timestamp */ p = buf; - while (left && !isspace((int) *p)) { + while (left && !Uisspace(*p)) { p++; left--; } - if (left > 1 && p[0] == ' ' && isdigit((int) p[1])) { + if (left > 1 && p[0] == ' ' && Uisdigit(p[1])) { /* Have a last-change timestamp */ while (buf < p) { *lastchangeptr = *lastchangeptr * 10 + *buf++ - '0'; @@ -224,7 +225,7 @@ left--; /* Scan for end of uids */ - while (left && !isspace((int) *p)) { + while (left && !Uisspace(*p)) { p++; left--; } @@ -603,7 +604,7 @@ /* Parse last-read timestamp */ p++; lastread = 0; - while (p < endline && isdigit((int) *p)) { + while (p < endline && Uisdigit(*p)) { lastread = lastread * 10 + *p++ - '0'; } if (p >= endline || *p++ != ' ') { @@ -628,7 +629,7 @@ /* Parse last-read uid */ lastuidread = 0; - while (p < endline && isdigit((int) *p)) { + while (p < endline && Uisdigit(*p)) { lastuidread = lastuidread * 10 + *p++ - '0'; } if (p >= endline || *p++ != ' ' || lastuidread > uidtoobig) { @@ -643,9 +644,9 @@ space = memchr(p, ' ', endline - p); if (space && space+1 < endline && - space[0] == ' ' && isdigit((int) space[1])) { + space[0] == ' ' && Uisdigit(space[1])) { /* Have a last-change timestamp */ - while (p < space && isdigit((int) *p)) { + while (p < space && Uisdigit(*p)) { lastchange = lastchange * 10 + *p++ - '0'; } if (p != space) { @@ -673,7 +674,7 @@ while (p < space) { thisuid = 0; - while (p < space && isdigit((int) *p)) { + while (p < space && Uisdigit(*p)) { if (dst) *dst++ = *p; thisuid = thisuid * 10 + *p++ - '0'; } @@ -681,7 +682,7 @@ if (thisuid <= lastuid || thisuid > uidtoobig) { /* Remove this UID and trailing separator */ FIXING(); - while (isdigit((int) dst[-1])) dst--; + while (Uisdigit(dst[-1])) dst--; if (dst[-1] == ':') dst[-1] = ','; } else if (lastsep == ':' && *p == ':') { diff -udNr cyrus-imapd-2.3.14/imap/spool.c cyrus-imapd/imap/spool.c --- cyrus-imapd-2.3.14/imap/spool.c 2008-03-24 17:09:19.000000000 +0000 +++ cyrus-imapd/imap/spool.c 2009-03-27 14:33:27.000000000 +0000 @@ -91,7 +91,7 @@ { int x = 0; /* any CHAR except ' ', :, or a ctrl char */ - for (; !iscntrl((int) *header) && (*header != ' ') && (*header != ':'); + for (; !Uiscntrl(*header) && (*header != ' ') && (*header != ':'); header++) { x *= 256; x += *header; diff -udNr cyrus-imapd-2.3.14/imap/sync_server.c cyrus-imapd/imap/sync_server.c --- cyrus-imapd-2.3.14/imap/sync_server.c 2009-02-09 05:02:54.000000000 +0000 +++ cyrus-imapd/imap/sync_server.c 2009-03-27 14:33:27.000000000 +0000 @@ -635,10 +635,10 @@ continue; } - if (islower((unsigned char) cmd.s[0])) + if (Uislower(cmd.s[0])) cmd.s[0] = toupper((unsigned char) cmd.s[0]); for (p = &cmd.s[1]; *p; p++) { - if (isupper((unsigned char) *p)) *p = tolower((unsigned char) *p); + if (Uisupper(*p)) *p = tolower((unsigned char) *p); } /* Only Authenticate/Exit/Restart/Starttls @@ -1745,13 +1745,13 @@ { unsigned long uid; - if (!isdigit(*s)) { + if (!Uisdigit(*s)) { *first_uidp = *last_uidp = 0L; return(NULL); } uid = 0; - while (isdigit(*s)) { + while (Uisdigit(*s)) { uid *= 10; uid += (*s++) -'0'; } @@ -1767,7 +1767,7 @@ s++; uid = 0; - while (isdigit(*s)) { + while (Uisdigit(*s)) { uid *= 10; uid += (*s++) -'0'; } diff -udNr cyrus-imapd-2.3.14/imap/sync_support.c cyrus-imapd/imap/sync_support.c --- cyrus-imapd-2.3.14/imap/sync_support.c 2008-10-08 16:47:08.000000000 +0100 +++ cyrus-imapd/imap/sync_support.c 2009-03-27 14:33:27.000000000 +0000 @@ -1240,7 +1240,7 @@ return(IMAP_PROTOCOL_ERROR); /* Read size from literal */ - for (p = p + 1; *p && isdigit((int) *p); p++) { + for (p = p + 1; *p && Uisdigit(*p); p++) { sawdigit++; size = (size*10) + *p - '0'; } diff -udNr cyrus-imapd-2.3.14/imtest/imtest.c cyrus-imapd/imtest/imtest.c --- cyrus-imapd-2.3.14/imtest/imtest.c 2009-01-14 15:50:47.000000000 +0000 +++ cyrus-imapd/imtest/imtest.c 2009-03-27 14:33:27.000000000 +0000 @@ -83,6 +83,7 @@ #include "hash.h" #include "imparse.h" #include "iptostring.h" +#include "util.h" #include "xmalloc.h" #include "xstrlcat.h" #include "xstrlcpy.h" @@ -1716,12 +1717,12 @@ buf[len-1] == '\n' && buf[len-1] == '\r' && buf[len-2] == '}') { /* possible literal, with \r */ i = len-4; - while(i > 0 && buf[i] != '{' && isdigit((int)buf[i])) i--; + while(i > 0 && buf[i] != '{' && Uisdigit(buf[i])) i--; if(buf[i] == '{') text->inLiteral = atoi(buf + i + 1); } else if(len > 3 && buf[len-1] == '\n' && buf[len-2] == '}') { /* possible literal, no \r -- hack for terminals*/ i = len-3; - while(i > 0 && buf[i] != '{' && isdigit((int)buf[i])) i--; + while(i > 0 && buf[i] != '{' && Uisdigit(buf[i])) i--; if(buf[i] == '{') text->inLiteral = atoi(buf + i + 1); } diff -udNr cyrus-imapd-2.3.14/installsieve/lex.c cyrus-imapd/installsieve/lex.c --- cyrus-imapd-2.3.14/installsieve/lex.c 2008-03-24 20:33:11.000000000 +0000 +++ cyrus-imapd/installsieve/lex.c 2009-03-27 15:43:06.000000000 +0000 @@ -52,6 +52,7 @@ #include "lex.h" #include "codes.h" +#include "util.h" /* current state the lexer is in */ int lexer_state = LEXER_STATE_NORMAL; @@ -224,7 +225,7 @@ } break; case LEXER_STATE_NORMAL: - if (isalpha((unsigned char) ch)) { + if (Uisalpha(ch)) { lexer_state=LEXER_STATE_ATOM; *buff_ptr++ = tolower(ch); break; @@ -271,7 +272,7 @@ } break; case LEXER_STATE_ATOM: - if (!isalpha((unsigned char) ch)) { + if (!Uisalpha(ch)) { int token; buffer[ buff_ptr - buffer] = '\0'; diff -udNr cyrus-imapd-2.3.14/lib/auth_krb.c cyrus-imapd/lib/auth_krb.c --- cyrus-imapd-2.3.14/lib/auth_krb.c 2008-03-24 17:43:08.000000000 +0000 +++ cyrus-imapd/lib/auth_krb.c 2009-03-27 14:33:27.000000000 +0000 @@ -48,6 +48,7 @@ #include "auth.h" #include "exitcodes.h" #include "xmalloc.h" +#include "util.h" #ifdef HAVE_KRB @@ -148,20 +149,20 @@ { int i; - while (isspace(*src)) src++; + while (Uisspace(*src)) src++; if (!*src) return 0; - for (i = 0; *src && !isspace(*src); i++) { + for (i = 0; *src && !Uisspace(*src); i++) { if (i >= MAX_K_NAME_SZ) return 0; *principal++ = *src++; } *principal = 0; - if (!isspace(*src)) return 0; /* Need at least one separator */ - while (isspace(*src)) src++; + if (!Uisspace(*src)) return 0; /* Need at least one separator */ + while (Uisspace(*src)) src++; if (!*src) return 0; - for (i = 0; *src && !isspace(*src); i++) { + for (i = 0; *src && !Uisspace(*src); i++) { if (i >= MAX_K_NAME_SZ) return 0; *localuser++ = *src++; } @@ -214,7 +215,7 @@ /* Upcase realm name */ for (p = realm; *p; p++) { - if (islower(*p)) *p = toupper(*p); + if (Uislower(*p)) *p = toupper(*p); } if (*realm) { @@ -280,7 +281,7 @@ /* Upcase realm name */ for (p = realm; *p; p++) { - if (islower(*p)) *p = toupper(*p); + if (Uislower(*p)) *p = toupper(*p); } if (*realm) { diff -udNr cyrus-imapd-2.3.14/lib/auth_unix.c cyrus-imapd/lib/auth_unix.c --- cyrus-imapd-2.3.14/lib/auth_unix.c 2008-08-26 20:20:39.000000000 +0100 +++ cyrus-imapd/lib/auth_unix.c 2009-03-27 14:33:27.000000000 +0000 @@ -52,6 +52,7 @@ #include "auth.h" #include "libcyr_cfg.h" #include "xmalloc.h" +#include "util.h" struct auth_state { char userid[81]; @@ -190,7 +191,7 @@ username_tolower = libcyrus_config_getswitch(CYRUSOPT_USERNAME_TOLOWER); sawalpha = 0; for(p = retbuf; *p; p++) { - if (username_tolower && isupper((unsigned char)*p)) + if (username_tolower && Uisupper(*p)) *p = tolower((unsigned char)*p); switch (allowedchars[*(unsigned char*) p]) { diff -udNr cyrus-imapd-2.3.14/lib/charset.c cyrus-imapd/lib/charset.c --- cyrus-imapd-2.3.14/lib/charset.c 2008-03-24 17:43:08.000000000 +0000 +++ cyrus-imapd/lib/charset.c 2009-03-27 14:33:27.000000000 +0000 @@ -303,7 +303,7 @@ * whitespace and is between two 1522-words. */ if (eatspace) { - for (p = s; p < (start-1) && isspace((int) *p); p++); + for (p = s; p < (start-1) && Uisspace(*p); p++); if (p < (start-1)) eatspace = 0; } if (!eatspace) { diff -udNr cyrus-imapd-2.3.14/lib/cyrusdb_sql.c cyrus-imapd/lib/cyrusdb_sql.c --- cyrus-imapd-2.3.14/lib/cyrusdb_sql.c 2008-07-30 17:03:38.000000000 +0100 +++ cyrus-imapd/lib/cyrusdb_sql.c 2009-03-27 14:33:27.000000000 +0000 @@ -54,6 +54,7 @@ #include "exitcodes.h" #include "libcyr_cfg.h" #include "xmalloc.h" +#include "util.h" extern void fatal(const char *, int); @@ -503,7 +504,7 @@ host[0] = '\0'; /* loop till we find some text */ - while (!isalnum(host[0])) host++; + while (!Uisalnum(host[0])) host++; } syslog(LOG_DEBUG, diff -udNr cyrus-imapd-2.3.14/lib/getaddrinfo.c cyrus-imapd/lib/getaddrinfo.c --- cyrus-imapd-2.3.14/lib/getaddrinfo.c 2008-03-24 17:43:08.000000000 +0000 +++ cyrus-imapd/lib/getaddrinfo.c 2009-03-27 14:33:27.000000000 +0000 @@ -69,6 +69,8 @@ #include #include +#include "util.h" + static struct addrinfo * malloc_ai(int port, u_long addr, int socktype, int proto) { @@ -155,7 +157,7 @@ } } if (servname) { - if (isdigit((int)*servname)) + if (Uisdigit(*servname)) port = htons(atoi(servname)); else { struct servent *se; diff -udNr cyrus-imapd-2.3.14/lib/imapurl.c cyrus-imapd/lib/imapurl.c --- cyrus-imapd-2.3.14/lib/imapurl.c 2008-09-22 13:58:35.000000000 +0100 +++ cyrus-imapd/lib/imapurl.c 2009-03-27 14:33:27.000000000 +0000 @@ -53,6 +53,7 @@ #include "imapurl.h" #include "xmalloc.h" +#include "util.h" /* hexadecimal lookup table */ static const char hex[] = "0123456789ABCDEF"; @@ -466,7 +467,7 @@ src += 19; if (*src == '.') { /* skip fractional secs */ - while (isdigit((int) *(++src))); + while (Uisdigit(*(++src))); } /* handle offset */ diff -udNr cyrus-imapd-2.3.14/lib/imclient.c cyrus-imapd/lib/imclient.c --- cyrus-imapd-2.3.14/lib/imclient.c 2008-03-24 17:43:09.000000000 +0000 +++ cyrus-imapd/lib/imclient.c 2009-03-27 14:33:27.000000000 +0000 @@ -781,7 +781,7 @@ } else { replytag = 0; - while (isdigit((unsigned char) *p)) { + while (Uisdigit(*p)) { replytag = replytag * 10 + *p++ - '0'; } if (*p++ != ' ') { @@ -793,9 +793,9 @@ } /* parse num, if there */ - if (replytag == 0 && isdigit((unsigned char) *p)) { + if (replytag == 0 && Uisdigit(*p)) { reply.msgno = 0; - while (isdigit((unsigned char) *p)) { + while (Uisdigit(*p)) { reply.msgno = reply.msgno * 10 + *p++ - '0'; } if (*p++ != ' ') { @@ -835,10 +835,10 @@ /* Scan back and see if the end of the line introduces a literal */ if (!iscompletion && endreply > imclient->replystart+2 && endreply[-1] == '\r' && endreply[-2] == '}' && - isdigit((unsigned char) endreply[-3])) { + Uisdigit(endreply[-3])) { p = endreply - 4; while (p > imclient->replystart && - isdigit((unsigned char) *p)) { + Uisdigit(*p)) { p--; } if (p > imclient->replystart + 2 && *p == '{' && @@ -847,7 +847,7 @@ /* Parse the size of the literal */ literallen = 0; p++; - while (isdigit((unsigned char) *p)) { + while (Uisdigit(*p)) { literallen = literallen*10 + *p++ -'0'; } @@ -909,10 +909,10 @@ if (!(imclient->callback[keywordindex].flags & CALLBACK_NOLITERAL)) { if (endreply > imclient->replystart+2 && endreply[-1] == '\r' && endreply[-2] == '}' && - isdigit((unsigned char) endreply[-3])) { + Uisdigit(endreply[-3])) { p = endreply - 4; while (p > imclient->replystart && - isdigit((unsigned char) *p)) { + Uisdigit(*p)) { p--; } if (p > imclient->replystart + 2 && *p == '{' && @@ -921,7 +921,7 @@ /* Parse the size of the literal */ literallen = 0; p++; - while (isdigit((unsigned char) *p)) { + while (Uisdigit(*p)) { literallen = literallen*10 + *p++ -'0'; } @@ -1310,7 +1310,7 @@ /* stop looping on command completion */ if (!imclient->readytxt) break; - if (isspace((unsigned char) *imclient->readytxt)) { + if (Uisspace(*imclient->readytxt)) { inlen = 0; } else { inlen = imclient_decodebase64(imclient->readytxt); diff -udNr cyrus-imapd-2.3.14/lib/imparse.c cyrus-imapd/lib/imparse.c --- cyrus-imapd-2.3.14/lib/imparse.c 2008-03-24 17:43:09.000000000 +0000 +++ cyrus-imapd/lib/imparse.c 2009-03-27 14:33:27.000000000 +0000 @@ -47,6 +47,7 @@ #include #include "imparse.h" +#include "util.h" /* * Parse a word from the string starting at the pointer pointed to by 's'. @@ -63,7 +64,7 @@ *retval = *s; for (;;) { c = *(*s)++; - if (!c || isspace(c) || c == '(' || c == ')' || c == '\"') { + if (!c || Uisspace(c) || c == '(' || c == ')' || c == '\"') { (*s)[-1] = '\0'; return c; } @@ -131,7 +132,7 @@ case '{': /* Literal */ (*s)++; - while (isdigit(c = *(*s)++)) { + while (Uisdigit(c = *(*s)++)) { sawdigit = 1; len = len*10 + c - '0'; } @@ -178,26 +179,26 @@ while ((c = *s)) { if (c == ',') { if (!len) return 0; - if (!isdigit((int) s[-1]) && s[-1] != '*') return 0; + if (!Uisdigit(s[-1]) && s[-1] != '*') return 0; sawcolon = 0; } else if (c == ':') { if (sawcolon || !len) return 0; - if (!isdigit((int) s[-1]) && s[-1] != '*') return 0; + if (!Uisdigit(s[-1]) && s[-1] != '*') return 0; sawcolon = 1; } else if (c == '*') { if (len && s[-1] != ',' && s[-1] != ':') return 0; - if (isdigit((int) s[1])) return 0; + if (Uisdigit(s[1])) return 0; } - else if (!isdigit(c)) { + else if (!Uisdigit(c)) { return 0; } s++; len++; } if (len == 0) return 0; - if (!isdigit((int) s[-1]) && s[-1] != '*') return 0; + if (!Uisdigit(s[-1]) && s[-1] != '*') return 0; return 1; } @@ -208,7 +209,7 @@ { if (!*s) return 0; for (; *s; s++) { - if (!isdigit((int) *s)) return 0; + if (!Uisdigit(*s)) return 0; } return 1; } diff -udNr cyrus-imapd-2.3.14/lib/libconfig.c cyrus-imapd/lib/libconfig.c --- cyrus-imapd-2.3.14/lib/libconfig.c 2008-09-23 18:34:38.000000000 +0100 +++ cyrus-imapd/lib/libconfig.c 2009-03-27 14:33:27.000000000 +0000 @@ -60,6 +60,7 @@ #include "xmalloc.h" #include "xstrlcat.h" #include "xstrlcpy.h" +#include "util.h" #define CONFIGHASHSIZE 30 /* relatively small, * because it is for overflow only */ @@ -264,10 +265,10 @@ /* Look up default partition */ config_defpartition = config_getstring(IMAPOPT_DEFAULTPARTITION); for (p = (char *)config_defpartition; *p; p++) { - if (!isalnum((unsigned char) *p)) + if (!Uisalnum(*p)) fatal("defaultpartition option contains non-alphanumeric character", EC_CONFIG); - if (isupper((unsigned char) *p)) *p = tolower((unsigned char) *p); + if (Uisupper(*p)) *p = tolower((unsigned char) *p); } if ((config_need_data & CONFIG_NEED_PARTITION_DATA) && (!config_defpartition || !config_partitiondir(config_defpartition))) { @@ -370,15 +371,15 @@ service_specific = 0; /* remove leading whitespace */ - for (p = buf; *p && isspace((int) *p); p++); + for (p = buf; *p && Uisspace(*p); p++); /* skip comments */ if (!*p || *p == '#') continue; fullkey = key = p; if (*p == '@') p++; /* allow @ as the first char (for directives) */ - while (*p && (isalnum((int) *p) || *p == '-' || *p == '_')) { - if (isupper((unsigned char) *p)) *p = tolower((unsigned char) *p); + while (*p && (Uisalnum(*p) || *p == '-' || *p == '_')) { + if (Uisupper(*p)) *p = tolower((unsigned char) *p); p++; } if (*p != ':') { @@ -390,10 +391,10 @@ *p++ = '\0'; /* remove leading whitespace */ - while (*p && isspace((int) *p)) p++; + while (*p && Uisspace(*p)) p++; /* remove trailing whitespace */ - for (q = p + strlen(p) - 1; q > p && isspace((int) *q); q--) { + for (q = p + strlen(p) - 1; q > p && Uisspace(*q); q--) { *q = '\0'; } @@ -553,7 +554,7 @@ while (*p) { /* find the end of the first value */ - for (; *q && !isspace((int) *q); q++); + for (; *q && !Uisspace(*q); q++); if (*q) *q++ = '\0'; /* see if its a legal value */ @@ -574,7 +575,7 @@ imapopts[opt].val.x |= e->val; /* find the start of the next value */ - for (p = q; *p && isspace((int) *p); p++); + for (p = q; *p && Uisspace(*p); p++); q = p; } diff -udNr cyrus-imapd-2.3.14/lib/mkchartable.c cyrus-imapd/lib/mkchartable.c --- cyrus-imapd-2.3.14/lib/mkchartable.c 2008-03-24 17:43:09.000000000 +0000 +++ cyrus-imapd/lib/mkchartable.c 2009-03-27 14:33:27.000000000 +0000 @@ -49,6 +49,7 @@ #include #include #include "xmalloc.h" +#include "util.h" #define XX 127 /* @@ -235,7 +236,7 @@ while (fgets(buf, sizeof(buf), mapfile)) { line++; p = buf; - while (*p && isspace(*(unsigned char*)p)) p++; + while (*p && Uisspace(*p)) p++; if (!*p || *p == '#') continue; /* Unicode character */ @@ -530,7 +531,7 @@ p = buf + strlen(buf); if (p > buf && p[-1] == '\n') p[-1] = '\0'; p = buf; - while (*p && isspace(*(unsigned char*)p)) p++; + while (*p && Uisspace(*p)) p++; if (!*p || *p == '#') continue; if (*p == ':') { @@ -545,14 +546,14 @@ thisstate = curstate; thischar = i = 0; - while (!isspace(*(unsigned char*)p)) { + while (!Uisspace(*p)) { c = HEXCHAR(*p); i++; p++; if (c == XX) goto syntaxerr; thischar = thischar*16 + c; } - while (*p && isspace(*(unsigned char*)p)) p++; + while (*p && Uisspace(*p)) p++; if (i > 4) goto syntaxerr; if (i > 2) { @@ -613,7 +614,7 @@ if (*p == ':' || *p == '>' || *p == '<') { p = table[thisstate].ch[thischar].action = xstrdup(p); - while (*p && !isspace(*(unsigned char*)p)) p++; + while (*p && !Uisspace(*p)) p++; *p = '\0'; continue; } @@ -799,7 +800,7 @@ } p = table[table_num].name; - while (*p && !isspace(*(unsigned char*)p)) p++; + while (*p && !Uisspace(*p)) p++; if (*p) *p++ = '\0'; while (*p) { if (*p == '<') table[table_num].endaction = "RET"; diff -udNr cyrus-imapd-2.3.14/lib/parseaddr.c cyrus-imapd/lib/parseaddr.c --- cyrus-imapd-2.3.14/lib/parseaddr.c 2008-03-24 17:43:09.000000000 +0000 +++ cyrus-imapd/lib/parseaddr.c 2009-03-27 14:33:27.000000000 +0000 @@ -50,6 +50,7 @@ #include "parseaddr.h" #include "xmalloc.h" +#include "util.h" static char parseaddr_unspecified_domain[] = "unspecified-domain"; @@ -221,7 +222,7 @@ } \ (s)--; \ } \ - else if (!isspace(_c)) break; \ + else if (!Uisspace(_c)) break; \ (s)++; \ } \ } @@ -255,7 +256,7 @@ *dst++ = c; } } - else if (isspace(c) || c == '(') { + else if (Uisspace(c) || c == '(') { src--; SKIPWHITESPACE(src); *dst++ = ' '; @@ -293,7 +294,7 @@ for (;;) { c = *src++; - if (isalnum(c) || c == '-' || c == '[' || c == ']' || c == ':') { + if (Uisalnum(c) || c == '-' || c == '[' || c == ']' || c == ':') { *dst++ = c; if (commentp) *commentp = 0; } @@ -320,7 +321,7 @@ SKIPWHITESPACE(src); } } - else if (!isspace(c)) { + else if (!Uisspace(c)) { if (dst > *domainp && dst[-1] == '.') dst--; *dst = '\0'; *inp = src; @@ -346,14 +347,14 @@ for (;;) { c = *src++; - if (isalnum(c) || c == '-' || c == '[' || c == ']' || + if (Uisalnum(c) || c == '-' || c == '[' || c == ']' || c == ',' || c == '@') { *dst++ = c; } else if (c == '.') { if (dst > *routep && dst[-1] != '.') *dst++ = c; } - else if (isspace(c) || c == '(') { + else if (Uisspace(c) || c == '(') { src--; SKIPWHITESPACE(src); } diff -udNr cyrus-imapd-2.3.14/lib/util.c cyrus-imapd/lib/util.c --- cyrus-imapd-2.3.14/lib/util.c 2008-03-24 17:43:09.000000000 +0000 +++ cyrus-imapd/lib/util.c 2009-03-27 14:33:27.000000000 +0000 @@ -273,7 +273,7 @@ } else { c = tolower(*name); - if (!isascii(c) || !islower(c)) c = 'q'; + if (!Uisascii(c) || !Uislower(c)) c = 'q'; } return c; diff -udNr cyrus-imapd-2.3.14/lib/util.h cyrus-imapd/lib/util.h --- cyrus-imapd-2.3.14/lib/util.h 2008-03-24 17:43:09.000000000 +0000 +++ cyrus-imapd/lib/util.h 2009-03-27 14:33:27.000000000 +0000 @@ -48,6 +48,16 @@ #ifndef INCLUDED_UTIL_H #define INCLUDED_UTIL_H +#define Uisalnum(c) isalnum((int)((unsigned char)(c))) +#define Uisalpha(c) isalpha((int)((unsigned char)(c))) +#define Uisascii(c) isascii((int)((unsigned char)(c))) +#define Uiscntrl(c) iscntrl((int)((unsigned char)(c))) +#define Uisdigit(c) isdigit((int)((unsigned char)(c))) +#define Uislower(c) islower((int)((unsigned char)(c))) +#define Uisspace(c) isspace((int)((unsigned char)(c))) +#define Uisupper(c) isupper((int)((unsigned char)(c))) +#define Uisxdigit(c) isxdigit((int)((unsigned char)(c))) + extern const unsigned char convert_to_lowercase[256]; extern const unsigned char convert_to_uppercase[256]; diff -udNr cyrus-imapd-2.3.14/master/master.c cyrus-imapd/master/master.c --- cyrus-imapd-2.3.14/master/master.c 2008-10-08 14:12:41.000000000 +0100 +++ cyrus-imapd/master/master.c 2009-03-27 14:33:27.000000000 +0000 @@ -1248,13 +1248,13 @@ if (!p || !*p) return NULL; /* sanity check */ while (*p) { - while (*p && isspace((int) *p)) p++; /* skip whitespace */ + while (*p && Uisspace(*p)) p++; /* skip whitespace */ if (!(i % 10)) tokens = xrealloc(tokens, (i+10) * sizeof(char *)); /* got a token */ tokens[i++] = p; - while (*p && !isspace((int) *p)) p++; + while (*p && !Uisspace(*p)) p++; /* p is whitespace or end of cmd */ if (*p) *p++ = '\0'; diff -udNr cyrus-imapd-2.3.14/master/masterconf.c cyrus-imapd/master/masterconf.c --- cyrus-imapd-2.3.14/master/masterconf.c 2008-03-24 17:47:41.000000000 +0000 +++ cyrus-imapd/master/masterconf.c 2009-03-27 14:33:27.000000000 +0000 @@ -135,7 +135,7 @@ } else { /* one word */ for (i = 0; i < 255; i++) { - if (isspace((int) *p)) break; + if (Uisspace(*p)) break; v[i] = *p++; } } @@ -152,8 +152,8 @@ const char *val = masterconf_getstring(e, key, NULL); if (!val) return def; - if (!isdigit((int) *val) && - (*val != '-' || !isdigit((int) val[1]))) return def; + if (!Uisdigit(*val) && + (*val != '-' || !Uisdigit(val[1]))) return def; return atoi(val); } @@ -189,7 +189,7 @@ /* remove EOL character */ if (buf[strlen(buf)-1] == '\n') buf[strlen(buf)-1] = '\0'; /* remove starting whitespace */ - for (p = buf; *p && isspace((int) *p); p++); + for (p = buf; *p && Uisspace(*p); p++); /* remove comments */ q = strchr(p, '#'); @@ -199,7 +199,7 @@ if (!*p) continue; if (*p == '}') break; - for (q = p; isalnum((int) *q); q++) ; + for (q = p; Uisalnum(*q); q++) ; if (q) { *q = '\0'; q++; } if (q - p > 0) { @@ -238,7 +238,7 @@ lineno++; if (buf[strlen(buf)-1] == '\n') buf[strlen(buf)-1] = '\0'; - for (p = buf; *p && isspace((int) *p); p++); + for (p = buf; *p && Uisspace(*p); p++); /* remove comments */ q = strchr(p, '#'); @@ -249,7 +249,7 @@ if (level == 0 && *p == *section && !strncasecmp(p, section, seclen) && - !isalnum((int) p[seclen])) { + !Uisalnum(p[seclen])) { for (p += seclen; *p; p++) { if (*p == '{') level++; if (*p == '}') level--; diff -udNr cyrus-imapd-2.3.14/netnews/readconfig.c cyrus-imapd/netnews/readconfig.c --- cyrus-imapd-2.3.14/netnews/readconfig.c 2008-03-24 19:06:32.000000000 +0000 +++ cyrus-imapd/netnews/readconfig.c 2009-03-27 14:33:27.000000000 +0000 @@ -79,6 +79,7 @@ #include "imclient.h" #include "imparse.h" #include "wildmat.h" +#include "util.h" #define NUM_STORAGE_CLASSES 100 @@ -193,7 +194,7 @@ break; SawDot = TRUE; } - else if (!isdigit( (int)*p)) + else if (!Uisdigit(*p)) break; if (*p) { (void)fprintf(stderr, "Line %d, bad `%c' character in %s field\n", @@ -277,7 +278,7 @@ else p = buff + strlen(buff); while (--p >= buff) { - if (isspace((int)*p)) + if (Uisspace(*p)) *p = '\0'; else break; diff -udNr cyrus-imapd-2.3.14/netnews/remotepurge.c cyrus-imapd/netnews/remotepurge.c --- cyrus-imapd-2.3.14/netnews/remotepurge.c 2008-03-24 19:06:32.000000000 +0000 +++ cyrus-imapd/netnews/remotepurge.c 2009-03-27 14:33:27.000000000 +0000 @@ -74,6 +74,7 @@ #include "imparse.h" #include "imclient.h" +#include "util.h" #include "xmalloc.h" #include "exitcodes.h" @@ -299,7 +300,7 @@ s = reply->text; - while (isdigit((int) *s)) { + while (Uisdigit(*s)) { num = 0; while ((*s!='\0') && (*s!=' ')) diff -udNr cyrus-imapd-2.3.14/ptclient/afskrb.c cyrus-imapd/ptclient/afskrb.c --- cyrus-imapd-2.3.14/ptclient/afskrb.c 2008-03-24 18:34:22.000000000 +0000 +++ cyrus-imapd/ptclient/afskrb.c 2009-03-27 14:33:27.000000000 +0000 @@ -45,6 +45,7 @@ #include #include "ptloader.h" #include "exitcodes.h" +#include "util.h" #include "xmalloc.h" #ifdef HAVE_AFSKRB @@ -103,7 +104,7 @@ size_t len; char *p; - for (p = (char *) val; *p && !isspace((int) *p); p++); + for (p = (char *) val; *p && !Uisspace(*p); p++); len = p-val; if(len >= sizeof(buf)) len = sizeof(buf) - 1; @@ -114,7 +115,7 @@ return 1; } val = p; - while (*val && isspace((int) *val)) val++; + while (*val && Uisspace(*val)) val++; } return 0; @@ -277,20 +278,20 @@ { int i; - while (isspace(*src)) src++; + while (Uisspace(*src)) src++; if (!*src) return 0; - for (i = 0; *src && !isspace(*src); i++) { + for (i = 0; *src && !Uisspace(*src); i++) { if (i >= MAX_K_NAME_SZ) return 0; *principal++ = *src++; } *principal = 0; - if (!isspace(*src)) return 0; /* Need at least one separator */ - while (isspace(*src)) src++; + if (!Uisspace(*src)) return 0; /* Need at least one separator */ + while (Uisspace(*src)) src++; if (!*src) return 0; - for (i = 0; *src && !isspace(*src); i++) { + for (i = 0; *src && !Uisspace(*src); i++) { if (i >= MAX_K_NAME_SZ) return 0; *localuser++ = *src++; } @@ -342,7 +343,7 @@ /* Upcase realm name */ for (p = realm; *p; p++) { - if (islower(*p)) *p = toupper(*p); + if (Uislower(*p)) *p = toupper(*p); } if (*realm) { @@ -405,7 +406,7 @@ /* Upcase realm name */ for (p = realm; *p; p++) { - if (islower(*p)) *p = toupper(*p); + if (Uislower(*p)) *p = toupper(*p); } if (*realm) { diff -udNr cyrus-imapd-2.3.14/ptclient/ldap.c cyrus-imapd/ptclient/ldap.c --- cyrus-imapd-2.3.14/ptclient/ldap.c 2008-04-10 19:03:47.000000000 +0100 +++ cyrus-imapd/ptclient/ldap.c 2009-03-27 14:33:27.000000000 +0000 @@ -45,6 +45,7 @@ #include #include "ptloader.h" #include "exitcodes.h" +#include "util.h" #ifdef HAVE_LDAP @@ -252,7 +253,7 @@ username_tolower = config_getswitch(IMAPOPT_USERNAME_TOLOWER); sawalpha = 0; for(p = retbuf+i; *p; p++) { - if (username_tolower && isupper((unsigned char)*p)) + if (username_tolower && Uisupper(*p)) *p = tolower((unsigned char)*p); switch (allowedchars[*(unsigned char*) p]) { @@ -934,7 +935,7 @@ int j; strcpy((*newstate)->groups[i].id, "group:"); for(j =0; j < strlen(vals[i]); j++) { - if(isupper(vals[i][j])) + if(Uisupper(vals[i][j])) vals[i][j]=tolower(vals[i][j]); } strlcat((*newstate)->groups[i].id, vals[i], @@ -1068,7 +1069,7 @@ int j; for(j =0; j < strlen(vals[0]); j++) { - if(isupper(vals[0][j])) + if(Uisupper(vals[0][j])) vals[0][j]=tolower(vals[0][j]); } diff -udNr cyrus-imapd-2.3.14/sieve/bc_eval.c cyrus-imapd/sieve/bc_eval.c --- cyrus-imapd-2.3.14/sieve/bc_eval.c 2008-03-24 20:08:46.000000000 +0000 +++ cyrus-imapd/sieve/bc_eval.c 2009-03-27 14:33:27.000000000 +0000 @@ -58,6 +58,7 @@ #include "xmalloc.h" #include "xstrlcpy.h" #include "xstrlcat.h" +#include "util.h" #include #include @@ -255,7 +256,7 @@ if (interp->getheader(m, buf, &body) == SIEVE_OK) { /* we don't deal with comments, etc. here */ /* skip leading white-space */ - while (*body[0] && isspace((int) *body[0])) body[0]++; + while (*body[0] && Uisspace(*body[0])) body[0]++; if (strcasecmp(body[0], "no")) l = SIEVE_DONE; } @@ -265,7 +266,7 @@ if (interp->getheader(m, buf, &body) == SIEVE_OK) { /* we don't deal with comments, etc. here */ /* skip leading white-space */ - while (*body[0] && isspace((int) *body[0])) body[0]++; + while (*body[0] && Uisspace(*body[0])) body[0]++; if (!strcasecmp(body[0], "junk") || !strcasecmp(body[0], "bulk") || !strcasecmp(body[0], "list")) diff -udNr cyrus-imapd-2.3.14/sieve/comparator.c cyrus-imapd/sieve/comparator.c --- cyrus-imapd-2.3.14/sieve/comparator.c 2009-02-03 05:14:51.000000000 +0000 +++ cyrus-imapd/sieve/comparator.c 2009-03-27 14:33:27.000000000 +0000 @@ -57,6 +57,7 @@ #include "sieve.h" #include "bytecode.h" #include "xmalloc.h" +#include "util.h" /*!!! uses B_CONTAINS not CONTAINS, etc, only works with bytecode*/ @@ -343,14 +344,14 @@ unsigned text_digit_len; unsigned pat_digit_len; - if (isdigit((int) *pat)) { - if (isdigit((int) *text)) { + if (Uisdigit(*pat)) { + if (Uisdigit(*text)) { /* Count how many digits each string has */ for (text_digit_len = 0; - tlen-- && isdigit((int) text[text_digit_len]); + tlen-- && Uisdigit(text[text_digit_len]); text_digit_len++); for (pat_digit_len = 0; - isdigit((int) pat[pat_digit_len]); + Uisdigit(pat[pat_digit_len]); pat_digit_len++); if (text_digit_len < pat_digit_len) { @@ -393,7 +394,7 @@ } else { return 1; } - } else if (isdigit((int) *text)) { + } else if (Uisdigit(*text)) { return -1; } else { return 0; /* both not digits */ diff -udNr cyrus-imapd-2.3.14/sieve/test.c cyrus-imapd/sieve/test.c --- cyrus-imapd-2.3.14/sieve/test.c 2008-03-24 20:08:46.000000000 +0000 +++ cyrus-imapd/sieve/test.c 2009-03-27 14:33:27.000000000 +0000 @@ -68,6 +68,7 @@ #include "tree.h" #include "sieve.h" #include "imap/message.h" +#include "util.h" #include "xstrlcat.h" #include "xstrlcpy.h" @@ -106,7 +107,7 @@ { int x = 0; /* any CHAR except ' ', :, or a ctrl char */ - for (; !iscntrl(*header) && (*header != ' ') && (*header != ':'); + for (; !Uiscntrl(*header) && (*header != ' ') && (*header != ':'); header++) { x *= 256; x += *header; diff -udNr cyrus-imapd-2.3.14/timsieved/lex.c cyrus-imapd/timsieved/lex.c --- cyrus-imapd-2.3.14/timsieved/lex.c 2008-03-24 20:20:57.000000000 +0000 +++ cyrus-imapd/timsieved/lex.c 2009-03-27 14:33:27.000000000 +0000 @@ -61,6 +61,7 @@ #include "actions.h" #include "libconfig.h" #include "global.h" +#include "util.h" #include "xmalloc.h" int token_lookup (char *str, int len __attribute__((unused))) @@ -304,7 +305,7 @@ return STRING; case LEXER_STATE_NUMBER: - if (isdigit((unsigned char) ch)) { + if (Uisdigit(ch)) { unsigned long newcount = tmpnum * 10 + (ch - '0'); if (newcount < tmpnum) @@ -321,12 +322,12 @@ break; case LEXER_STATE_NORMAL: - if (isalpha((unsigned char) ch)) { + if (Uisalpha(ch)) { lexer_state=LEXER_STATE_ATOM; *buff_ptr++ = tolower(ch); break; } - if (isdigit((unsigned char) ch)) { + if (Uisdigit(ch)) { lexer_state=LEXER_STATE_NUMBER; tmpnum = ch -'0'; break; @@ -359,7 +360,7 @@ } break; case LEXER_STATE_ATOM: - if (!isalpha((unsigned char) ch)) { + if (!Uisalpha(ch)) { int token; buffer[ buff_ptr - buffer] = '\0';