Use uppercase version of `ctype` macros e.g. `ISSPACE`; fix #4338

parent 1e14afa4
...@@ -6,6 +6,15 @@ ...@@ -6,6 +6,15 @@
** immediately. It's a REPL... ** immediately. It's a REPL...
*/ */
#include <mruby.h>
#include <mruby/array.h>
#include <mruby/proc.h>
#include <mruby/compile.h>
#include <mruby/dump.h>
#include <mruby/string.h>
#include <mruby/variable.h>
#include <mruby/throw.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
...@@ -49,15 +58,6 @@ ...@@ -49,15 +58,6 @@
#define SIGJMP_BUF jmp_buf #define SIGJMP_BUF jmp_buf
#endif #endif
#include <mruby.h>
#include <mruby/array.h>
#include <mruby/proc.h>
#include <mruby/compile.h>
#include <mruby/dump.h>
#include <mruby/string.h>
#include <mruby/variable.h>
#include <mruby/throw.h>
#ifdef ENABLE_READLINE #ifdef ENABLE_READLINE
static const char history_file_name[] = ".mirb_history"; static const char history_file_name[] = ".mirb_history";
...@@ -373,7 +373,7 @@ check_keyword(const char *buf, const char *word) ...@@ -373,7 +373,7 @@ check_keyword(const char *buf, const char *word)
size_t len = strlen(word); size_t len = strlen(word);
/* skip preceding spaces */ /* skip preceding spaces */
while (*p && isspace((unsigned char)*p)) { while (*p && ISSPACE(*p)) {
p++; p++;
} }
/* check keyword */ /* check keyword */
...@@ -383,7 +383,7 @@ check_keyword(const char *buf, const char *word) ...@@ -383,7 +383,7 @@ check_keyword(const char *buf, const char *word)
p += len; p += len;
/* skip trailing spaces */ /* skip trailing spaces */
while (*p) { while (*p) {
if (!isspace((unsigned char)*p)) return 0; if (!ISSPACE(*p)) return 0;
p++; p++;
} }
return 1; return 1;
......
...@@ -4888,10 +4888,10 @@ parser_yylex(parser_state *p) ...@@ -4888,10 +4888,10 @@ parser_yylex(parser_state *p)
} }
newtok(p); newtok(p);
/* need support UTF-8 if configured */ /* need support UTF-8 if configured */
if ((isalnum(c) || c == '_')) { if ((ISALNUM(c) || c == '_')) {
int c2 = nextc(p); int c2 = nextc(p);
pushback(p, c2); pushback(p, c2);
if ((isalnum(c2) || c2 == '_')) { if ((ISALNUM(c2) || c2 == '_')) {
goto ternary; goto ternary;
} }
} }
...@@ -5459,7 +5459,7 @@ parser_yylex(parser_state *p) ...@@ -5459,7 +5459,7 @@ parser_yylex(parser_state *p)
} }
else { else {
term = nextc(p); term = nextc(p);
if (isalnum(term)) { if (ISALNUM(term)) {
yyerror(p, "unknown type of %string"); yyerror(p, "unknown type of %string");
return 0; return 0;
} }
...@@ -5603,7 +5603,7 @@ parser_yylex(parser_state *p) ...@@ -5603,7 +5603,7 @@ parser_yylex(parser_state *p)
do { do {
tokadd(p, c); tokadd(p, c);
c = nextc(p); c = nextc(p);
} while (c >= 0 && isdigit(c)); } while (c >= 0 && ISDIGIT(c));
pushback(p, c); pushback(p, c);
if (last_state == EXPR_FNAME) goto gvar; if (last_state == EXPR_FNAME) goto gvar;
tokfix(p); tokfix(p);
...@@ -5645,7 +5645,7 @@ parser_yylex(parser_state *p) ...@@ -5645,7 +5645,7 @@ parser_yylex(parser_state *p)
} }
return 0; return 0;
} }
else if (isdigit(c)) { else if (ISDIGIT(c)) {
if (p->tidx == 1) { if (p->tidx == 1) {
yyerror_i(p, "'@%c' is not allowed as an instance variable name", c); yyerror_i(p, "'@%c' is not allowed as an instance variable name", c);
} }
...@@ -5802,7 +5802,7 @@ parser_yylex(parser_state *p) ...@@ -5802,7 +5802,7 @@ parser_yylex(parser_state *p)
mrb_sym ident = intern_cstr(tok(p)); mrb_sym ident = intern_cstr(tok(p));
pylval.id = ident; pylval.id = ident;
if (last_state != EXPR_DOT && islower(tok(p)[0]) && local_var_p(p, ident)) { if (last_state != EXPR_DOT && ISLOWER(tok(p)[0]) && local_var_p(p, ident)) {
p->lstate = EXPR_END; p->lstate = EXPR_END;
} }
} }
......
...@@ -627,7 +627,7 @@ unpack_a(mrb_state *mrb, const void *src, int slen, mrb_value ary, long count, u ...@@ -627,7 +627,7 @@ unpack_a(mrb_state *mrb, const void *src, int slen, mrb_value ary, long count, u
} }
} }
else if (!(flags & PACK_FLAG_a)) { /* "A" */ else if (!(flags & PACK_FLAG_a)) { /* "A" */
while (copylen > 0 && (sptr[copylen - 1] == '\0' || isspace(sptr[copylen - 1]))) { while (copylen > 0 && (sptr[copylen - 1] == '\0' || ISSPACE(sptr[copylen - 1]))) {
copylen--; copylen--;
} }
} }
...@@ -1072,9 +1072,9 @@ alias: ...@@ -1072,9 +1072,9 @@ alias:
/* read suffix [0-9*_!<>] */ /* read suffix [0-9*_!<>] */
while (tmpl->idx < tlen) { while (tmpl->idx < tlen) {
ch = tptr[tmpl->idx++]; ch = tptr[tmpl->idx++];
if (isdigit(ch)) { if (ISDIGIT(ch)) {
count = ch - '0'; count = ch - '0';
while (tmpl->idx < tlen && isdigit(tptr[tmpl->idx])) { while (tmpl->idx < tlen && ISDIGIT(tptr[tmpl->idx])) {
count = count * 10 + (tptr[tmpl->idx++] - '0'); count = count * 10 + (tptr[tmpl->idx++] - '0');
if (count < 0) { if (count < 0) {
mrb_raise(mrb, E_RUNTIME_ERROR, "too big template length"); mrb_raise(mrb, E_RUNTIME_ERROR, "too big template length");
......
...@@ -2844,7 +2844,7 @@ mrb_float_read(const char *string, char **endPtr) ...@@ -2844,7 +2844,7 @@ mrb_float_read(const char *string, char **endPtr)
*/ */
p = string; p = string;
while (isspace(*p)) { while (ISSPACE(*p)) {
p += 1; p += 1;
} }
if (*p == '-') { if (*p == '-') {
...@@ -2867,7 +2867,7 @@ mrb_float_read(const char *string, char **endPtr) ...@@ -2867,7 +2867,7 @@ mrb_float_read(const char *string, char **endPtr)
for (mantSize = 0; ; mantSize += 1) for (mantSize = 0; ; mantSize += 1)
{ {
c = *p; c = *p;
if (!isdigit(c)) { if (!ISDIGIT(c)) {
if ((c != '.') || (decPt >= 0)) { if ((c != '.') || (decPt >= 0)) {
break; break;
} }
...@@ -2952,7 +2952,7 @@ mrb_float_read(const char *string, char **endPtr) ...@@ -2952,7 +2952,7 @@ mrb_float_read(const char *string, char **endPtr)
} }
expSign = FALSE; expSign = FALSE;
} }
while (isdigit(*p)) { while (ISDIGIT(*p)) {
exp = exp * 10 + (*p - '0'); exp = exp * 10 + (*p - '0');
if (exp > 19999) { if (exp > 19999) {
exp = 19999; exp = 19999;
......
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