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

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