diff options
Diffstat (limited to 'strlib.c')
-rw-r--r-- | strlib.c | 30 |
1 files changed, 15 insertions, 15 deletions
@@ -3,7 +3,7 @@ | |||
3 | ** String library to LUA | 3 | ** String library to LUA |
4 | */ | 4 | */ |
5 | 5 | ||
6 | char *rcs_strlib="$Id: strlib.c,v 1.32 1996/11/07 20:26:19 roberto Exp roberto $"; | 6 | char *rcs_strlib="$Id: strlib.c,v 1.33 1996/11/20 13:47:59 roberto Exp roberto $"; |
7 | 7 | ||
8 | #include <string.h> | 8 | #include <string.h> |
9 | #include <stdio.h> | 9 | #include <stdio.h> |
@@ -154,7 +154,7 @@ static void str_lower (void) | |||
154 | char *s = lua_check_string(1, "strlower"); | 154 | char *s = lua_check_string(1, "strlower"); |
155 | luaI_addchar(0); | 155 | luaI_addchar(0); |
156 | while (*s) | 156 | while (*s) |
157 | luaI_addchar(tolower(*s++)); | 157 | luaI_addchar(tolower((unsigned char)*s++)); |
158 | lua_pushstring(luaI_addchar(0)); | 158 | lua_pushstring(luaI_addchar(0)); |
159 | } | 159 | } |
160 | 160 | ||
@@ -166,7 +166,7 @@ static void str_upper (void) | |||
166 | char *s = lua_check_string(1, "strupper"); | 166 | char *s = lua_check_string(1, "strupper"); |
167 | luaI_addchar(0); | 167 | luaI_addchar(0); |
168 | while (*s) | 168 | while (*s) |
169 | luaI_addchar(toupper(*s++)); | 169 | luaI_addchar(toupper((unsigned char)*s++)); |
170 | lua_pushstring(luaI_addchar(0)); | 170 | lua_pushstring(luaI_addchar(0)); |
171 | } | 171 | } |
172 | 172 | ||
@@ -222,18 +222,18 @@ char *item_end (char *p) | |||
222 | static int matchclass (int c, int cl) | 222 | static int matchclass (int c, int cl) |
223 | { | 223 | { |
224 | int res; | 224 | int res; |
225 | switch (tolower(cl)) { | 225 | switch (tolower((unsigned char)cl)) { |
226 | case 'a' : res = isalpha(c); break; | 226 | case 'a' : res = isalpha((unsigned char)c); break; |
227 | case 'c' : res = iscntrl(c); break; | 227 | case 'c' : res = iscntrl((unsigned char)c); break; |
228 | case 'd' : res = isdigit(c); break; | 228 | case 'd' : res = isdigit((unsigned char)c); break; |
229 | case 'l' : res = islower(c); break; | 229 | case 'l' : res = islower((unsigned char)c); break; |
230 | case 'p' : res = ispunct(c); break; | 230 | case 'p' : res = ispunct((unsigned char)c); break; |
231 | case 's' : res = isspace(c); break; | 231 | case 's' : res = isspace((unsigned char)c); break; |
232 | case 'u' : res = isupper(c); break; | 232 | case 'u' : res = isupper((unsigned char)c); break; |
233 | case 'w' : res = isalnum(c); break; | 233 | case 'w' : res = isalnum((unsigned char)c); break; |
234 | default: return (cl == c); | 234 | default: return (cl == c); |
235 | } | 235 | } |
236 | return (islower(cl) ? res : !res); | 236 | return (islower((unsigned char)cl) ? res : !res); |
237 | } | 237 | } |
238 | 238 | ||
239 | int singlematch (int c, char *p) | 239 | int singlematch (int c, char *p) |
@@ -333,7 +333,7 @@ static char *match (char *s, char *p, int level) | |||
333 | return res; | 333 | return res; |
334 | } | 334 | } |
335 | case ESC: | 335 | case ESC: |
336 | if (isdigit(*(p+1))) { /* capture */ | 336 | if (isdigit((unsigned char)*(p+1))) { /* capture */ |
337 | int l = check_cap(*(p+1), level); | 337 | int l = check_cap(*(p+1), level); |
338 | if (strncmp(capture[l].init, s, capture[l].len) == 0) { | 338 | if (strncmp(capture[l].init, s, capture[l].len) == 0) { |
339 | /* return match(p+2, s+capture[l].len, level); */ | 339 | /* return match(p+2, s+capture[l].len, level); */ |
@@ -415,7 +415,7 @@ static void add_s (lua_Object newp) | |||
415 | if (lua_isstring(newp)) { | 415 | if (lua_isstring(newp)) { |
416 | char *news = lua_getstring(newp); | 416 | char *news = lua_getstring(newp); |
417 | while (*news) { | 417 | while (*news) { |
418 | if (*news != ESC || !isdigit(*++news)) | 418 | if (*news != ESC || !isdigit((unsigned char)*++news)) |
419 | luaI_addchar(*news++); | 419 | luaI_addchar(*news++); |
420 | else { | 420 | else { |
421 | int l = check_cap(*news++, num_captures); | 421 | int l = check_cap(*news++, num_captures); |