diff --git a/lex.c b/lex.c index eb92d6fc..6906037b 100644 --- a/lex.c +++ b/lex.c @@ -1,4 +1,4 @@ -char *rcs_lex = "$Id: lex.c,v 2.39 1996/11/08 19:08:30 roberto Exp roberto $"; +char *rcs_lex = "$Id: lex.c,v 2.40 1996/11/21 14:44:04 roberto Exp roberto $"; #include @@ -85,7 +85,7 @@ static int inclinenumber (int pragma_allowed) char *buff = luaI_buffer(MINBUFF+1); int i = 0; next(); /* skip $ */ - while (isalnum(current)) { + while (isalnum((unsigned char)current)) { if (i >= MINBUFF) luaI_syntaxerror("pragma too long"); buff[i++] = current; next(); @@ -259,7 +259,9 @@ int luaY_lex (void) case '_': { TaggedString *ts; - do { save_and_next(); } while (isalnum(current) || current == '_'); + do { + save_and_next(); + } while (isalnum((unsigned char)current) || current == '_'); save(0); ts = lua_createstring(yytext); if (ts->marked > 2) @@ -281,7 +283,7 @@ int luaY_lex (void) } else return CONC; /* .. */ } - else if (!isdigit(current)) return '.'; + else if (!isdigit((unsigned char)current)) return '.'; /* current is a digit: goes through to number */ a=0.0; goto fraction; @@ -292,7 +294,7 @@ int luaY_lex (void) do { a=10.0*a+(current-'0'); save_and_next(); - } while (isdigit(current)); + } while (isdigit((unsigned char)current)); if (current == '.') { save_and_next(); if (current == '.') @@ -301,7 +303,7 @@ int luaY_lex (void) } fraction: { double da=0.1; - while (isdigit(current)) + while (isdigit((unsigned char)current)) { a+=(current-'0')*da; da/=10.0; @@ -315,11 +317,12 @@ int luaY_lex (void) save_and_next(); neg=(current=='-'); if (current == '+' || current == '-') save_and_next(); - if (!isdigit(current)) { save(0); return WRONGTOKEN; } + if (!isdigit((unsigned char)current)) { + save(0); return WRONGTOKEN; } do { e=10.0*e+(current-'0'); save_and_next(); - } while (isdigit(current)); + } while (isdigit((unsigned char)current)); for (ea=neg?0.1:10.0; e>0; e>>=1) { if (e & 1) a*=ea; diff --git a/strlib.c b/strlib.c index cb5537c2..776e3e37 100644 --- a/strlib.c +++ b/strlib.c @@ -3,7 +3,7 @@ ** String library to LUA */ -char *rcs_strlib="$Id: strlib.c,v 1.32 1996/11/07 20:26:19 roberto Exp roberto $"; +char *rcs_strlib="$Id: strlib.c,v 1.33 1996/11/20 13:47:59 roberto Exp roberto $"; #include #include @@ -154,7 +154,7 @@ static void str_lower (void) char *s = lua_check_string(1, "strlower"); luaI_addchar(0); while (*s) - luaI_addchar(tolower(*s++)); + luaI_addchar(tolower((unsigned char)*s++)); lua_pushstring(luaI_addchar(0)); } @@ -166,7 +166,7 @@ static void str_upper (void) char *s = lua_check_string(1, "strupper"); luaI_addchar(0); while (*s) - luaI_addchar(toupper(*s++)); + luaI_addchar(toupper((unsigned char)*s++)); lua_pushstring(luaI_addchar(0)); } @@ -222,18 +222,18 @@ char *item_end (char *p) static int matchclass (int c, int cl) { int res; - switch (tolower(cl)) { - case 'a' : res = isalpha(c); break; - case 'c' : res = iscntrl(c); break; - case 'd' : res = isdigit(c); break; - case 'l' : res = islower(c); break; - case 'p' : res = ispunct(c); break; - case 's' : res = isspace(c); break; - case 'u' : res = isupper(c); break; - case 'w' : res = isalnum(c); break; + switch (tolower((unsigned char)cl)) { + case 'a' : res = isalpha((unsigned char)c); break; + case 'c' : res = iscntrl((unsigned char)c); break; + case 'd' : res = isdigit((unsigned char)c); break; + case 'l' : res = islower((unsigned char)c); break; + case 'p' : res = ispunct((unsigned char)c); break; + case 's' : res = isspace((unsigned char)c); break; + case 'u' : res = isupper((unsigned char)c); break; + case 'w' : res = isalnum((unsigned char)c); break; default: return (cl == c); } - return (islower(cl) ? res : !res); + return (islower((unsigned char)cl) ? res : !res); } int singlematch (int c, char *p) @@ -333,7 +333,7 @@ static char *match (char *s, char *p, int level) return res; } case ESC: - if (isdigit(*(p+1))) { /* capture */ + if (isdigit((unsigned char)*(p+1))) { /* capture */ int l = check_cap(*(p+1), level); if (strncmp(capture[l].init, s, capture[l].len) == 0) { /* return match(p+2, s+capture[l].len, level); */ @@ -415,7 +415,7 @@ static void add_s (lua_Object newp) if (lua_isstring(newp)) { char *news = lua_getstring(newp); while (*news) { - if (*news != ESC || !isdigit(*++news)) + if (*news != ESC || !isdigit((unsigned char)*++news)) luaI_addchar(*news++); else { int l = check_cap(*news++, num_captures);