diff options
author | Steve Bennett <steveb@workware.net.au> | 2010-10-22 09:57:01 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2010-11-17 07:57:39 +1000 |
commit | b93609dd51bb92f9a7d466159f4128a6f5e59cc1 (patch) | |
tree | bb8701c470e1b1ceae8008a472b8582e02422e3b | |
parent | edd90ef17325be11342427123d809be005025d79 (diff) | |
download | jimtcl-b93609dd51bb92f9a7d466159f4128a6f5e59cc1.zip jimtcl-b93609dd51bb92f9a7d466159f4128a6f5e59cc1.tar.gz jimtcl-b93609dd51bb92f9a7d466159f4128a6f5e59cc1.tar.bz2 |
For ctype macros, cast to unsigned char
Instead of unsigned. Add UCHAR() macro for this.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
-rw-r--r-- | jim-signal.c | 2 | ||||
-rw-r--r-- | jim-win32.c | 2 | ||||
-rw-r--r-- | jim.c | 28 | ||||
-rw-r--r-- | jim.h | 2 |
4 files changed, 18 insertions, 16 deletions
diff --git a/jim-signal.c b/jim-signal.c index 458a328..01732dd 100644 --- a/jim-signal.c +++ b/jim-signal.c @@ -137,7 +137,7 @@ static int find_signal_by_name(Jim_Interp *interp, const char *name) if (strncasecmp(name, "sig", 3) == 0) { pt += 3; } - if (isdigit((unsigned)pt[0])) { + if (isdigit(UCHAR(pt[0]))) { i = atoi(pt); if (i > 0 && i < MAX_SIGNALS) { return i; diff --git a/jim-win32.c b/jim-win32.c index 2a6e1b9..d1469a6 100644 --- a/jim-win32.c +++ b/jim-win32.c @@ -60,7 +60,7 @@ Win32ErrorObj(Jim_Interp *interp, const char * szPrefix, DWORD dwError) msgObj = Jim_NewStringObj(interp, szPrefix, -1); if (dwLen > 0) { char *p = lpBuffer + dwLen - 1; /* remove cr-lf at end */ - for ( ; p && *p && isspace((unsigned)*p); p--) + for ( ; p && *p && isspace(UCHAR(*p)); p--) ; *++p = 0; Jim_AppendString(interp, msgObj, ": ", 2); @@ -407,7 +407,7 @@ static int JimCheckConversion(const char *str, const char *endptr) if (endptr[0] != '\0') { while (*endptr) { - if (!isspace((unsigned)*endptr)) { + if (!isspace(UCHAR(*endptr))) { return JIM_ERR; } endptr++; @@ -434,10 +434,10 @@ int Jim_DoubleToString(char *buf, double doubleValue) /* Add a final ".0" if it's a number. But not * for NaN or InF */ while (*buf) { - if (*buf == '.' || isalpha((unsigned)*buf)) { + if (*buf == '.' || isalpha(UCHAR(*buf))) { /* inf -> Inf, nan -> Nan */ if (*buf == 'i' || *buf == 'n') { - *buf = toupper((unsigned)*buf); + *buf = toupper(UCHAR(*buf)); } return len; } @@ -4377,7 +4377,7 @@ int Jim_Collect(Jim_Interp *interp) if (p[41] != '>' || p[19] != '>' || p[20] != '.') break; for (i = 21; i <= 40; i++) - if (!isdigit((unsigned)p[i])) + if (!isdigit(UCHAR(p[i]))) break; /* Get the ID */ memcpy(buf, p + 21, 20); @@ -6417,7 +6417,7 @@ int SetIndexFromAny(Jim_Interp *interp, Jim_Obj *objPtr) str = endptr; } /* The only thing left should be spaces */ - while (isspace((unsigned)*str)) { + while (isspace(UCHAR(*str))) { str++; } if (*str) { @@ -7410,7 +7410,7 @@ static const struct Jim_ExprOperator Jim_ExprOperators[] = { static int JimParseExpression(struct JimParserCtx *pc) { /* Discard spaces and quoted newline */ - while (isspace((unsigned)*pc->p) || (*(pc->p) == '\\' && *(pc->p + 1) == '\n')) { + while (isspace(UCHAR(*pc->p)) || (*(pc->p) == '\\' && *(pc->p + 1) == '\n')) { pc->p++; pc->len--; } @@ -7488,8 +7488,8 @@ int JimParseExprNumber(struct JimParserCtx *pc) pc->tt = JIM_TT_EXPR_INT; pc->tstart = pc->p; pc->tline = pc->linenr; - while (isdigit((unsigned)*pc->p) - || (allowhex && isxdigit((unsigned)*pc->p)) + while (isdigit(UCHAR(*pc->p)) + || (allowhex && isxdigit(UCHAR(*pc->p))) || (allowdot && *pc->p == '.') || (pc->p - pc->tstart == 1 && *pc->tstart == '0' && (*pc->p == 'x' || *pc->p == 'X')) ) { @@ -7504,7 +7504,7 @@ int JimParseExprNumber(struct JimParserCtx *pc) pc->p++; pc->len--; if (!allowhex && (*pc->p == 'e' || *pc->p == 'E') && (pc->p[1] == '-' || pc->p[1] == '+' - || isdigit((unsigned)pc->p[1]))) { + || isdigit(UCHAR(pc->p[1])))) { pc->p += 2; pc->len -= 2; pc->tt = JIM_TT_EXPR_DOUBLE; @@ -7565,7 +7565,7 @@ int JimParseExprOperator(struct JimParserCtx *pc) const char *p = pc->p + bestLen; int len = pc->len - bestLen; - while (len && isspace((unsigned)*p)) { + while (len && isspace(UCHAR(*p))) { len--; p++; } @@ -8573,7 +8573,7 @@ static Jim_Obj *JimScanAString(Jim_Interp *interp, const char *sdescr, const cha int c; int n; - if (!sdescr && isspace(*str)) + if (!sdescr && isspace(UCHAR(*str))) break; /* EOS via WS if unspecified */ n = utf8_tounicode(str, &c); @@ -8609,8 +8609,8 @@ static int ScanOneEntry(Jim_Interp *interp, const char *str, long pos, * the string-to-be-parsed accordingly */ for (i = 0; str[pos] && descr->prefix[i]; ++i) { /* If prefix require, skip WS */ - if (isspace((unsigned)descr->prefix[i])) - while (str[pos] && isspace((unsigned)str[pos])) + if (isspace(UCHAR(descr->prefix[i]))) + while (str[pos] && isspace(UCHAR(str[pos]))) ++pos; else if (descr->prefix[i] != str[pos]) break; /* Prefix do not match here, leave the loop */ @@ -8624,7 +8624,7 @@ static int ScanOneEntry(Jim_Interp *interp, const char *str, long pos, } /* For all but following conversion, skip leading WS */ if (descr->type != 'c' && descr->type != '[' && descr->type != 'n') - while (isspace((unsigned)str[pos])) + while (isspace(UCHAR(str[pos]))) ++pos; /* Determine how much skipped/scanned so far */ scanned = pos - anchor; @@ -119,6 +119,8 @@ extern "C" { # endif #endif +#define UCHAR(c) ((unsigned char)(c)) + /* ----------------------------------------------------------------------------- * Exported defines * ---------------------------------------------------------------------------*/ |