diff options
Diffstat (limited to 'engines/sword25/util/lua/llex.cpp')
-rw-r--r-- | engines/sword25/util/lua/llex.cpp | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/engines/sword25/util/lua/llex.cpp b/engines/sword25/util/lua/llex.cpp index 464ab3ec15..f8433d3afa 100644 --- a/engines/sword25/util/lua/llex.cpp +++ b/engines/sword25/util/lua/llex.cpp @@ -5,9 +5,7 @@ */ -#include <ctype.h> -#include <stdio.h> -#include <string.h> +#include "common/util.h" #define llex_c #define LUA_CORE @@ -188,7 +186,7 @@ static void trydecpoint (LexState *ls, SemInfo *seminfo) { sprintf(buf, "%.1f", 1.0); ls->decpoint = '.'; for (i = 0; buf[i]; i++) { - if (!isspace(static_cast<unsigned char>(buf[i])) && !isdigit(static_cast<unsigned char>(buf[i]))) { + if (!Common::isSpace(buf[i]) && !Common::isDigit(buf[i])) { ls->decpoint = buf[i]; break; } @@ -204,13 +202,13 @@ static void trydecpoint (LexState *ls, SemInfo *seminfo) { /* LUA_NUMBER */ static void read_numeral (LexState *ls, SemInfo *seminfo) { - lua_assert(isdigit(ls->current)); + lua_assert(Common::isDigit(ls->current)); do { save_and_next(ls); - } while (isdigit(ls->current) || ls->current == '.'); + } while (Common::isDigit(ls->current) || ls->current == '.'); if (check_next(ls, "Ee")) /* `E'? */ check_next(ls, "+-"); /* optional exponent sign */ - while (isalnum(ls->current) || ls->current == '_') + while (Common::isAlnum(ls->current) || ls->current == '_') save_and_next(ls); save(ls, '\0'); buffreplace(ls, '.', ls->decpoint); /* follow locale for decimal point */ @@ -313,7 +311,7 @@ static void read_string (LexState *ls, int del, SemInfo *seminfo) { case '\r': save(ls, '\n'); inclinenumber(ls); continue; case EOZ: continue; /* will raise an error next loop */ default: { - if (!isdigit(ls->current)) + if (!Common::isDigit(ls->current)) save_and_next(ls); /* handles \\, \", \', and \? */ else { /* \xxx */ int i = 0; @@ -321,7 +319,7 @@ static void read_string (LexState *ls, int del, SemInfo *seminfo) { do { c = 10*c + (ls->current-'0'); next(ls); - } while (++i<3 && isdigit(ls->current)); + } while (++i<3 && Common::isDigit(ls->current)); if (c > UCHAR_MAX) luaX_lexerror(ls, "escape sequence too large", TK_STRING); save(ls, c); @@ -412,7 +410,7 @@ static int llex (LexState *ls, SemInfo *seminfo) { return TK_DOTS; /* ... */ else return TK_CONCAT; /* .. */ } - else if (!isdigit(ls->current)) return '.'; + else if (!Common::isDigit(ls->current)) return '.'; else { read_numeral(ls, seminfo); return TK_NUMBER; @@ -422,21 +420,21 @@ static int llex (LexState *ls, SemInfo *seminfo) { return TK_EOS; } default: { - if (isspace(ls->current)) { + if (Common::isSpace(ls->current)) { lua_assert(!currIsNewline(ls)); next(ls); continue; } - else if (isdigit(ls->current)) { + else if (Common::isDigit(ls->current)) { read_numeral(ls, seminfo); return TK_NUMBER; } - else if (isalpha(ls->current) || ls->current == '_') { + else if (Common::isAlpha(ls->current) || ls->current == '_') { /* identifier or reserved word */ TString *ts; do { save_and_next(ls); - } while (isalnum(ls->current) || ls->current == '_'); + } while (Common::isAlnum(ls->current) || ls->current == '_'); ts = luaX_newstring(ls, luaZ_buffer(ls->buff), luaZ_bufflen(ls->buff)); if (ts->tsv.reserved > 0) /* reserved word? */ |