diff -urN lua-5.1-alpha/src/llex.c lua-5.1-alpha_new/src/llex.c --- lua-5.1-alpha/src/llex.c 2005年09月07日 22:01:05.389523320 -0400 +++ lua-5.1-alpha_new/src/llex.c 2005年09月07日 22:03:37.203444096 -0400 @@ -7,6 +7,7 @@ #include #include +#include #define llex_c #define LUA_CORE @@ -155,9 +156,33 @@ +static int luaO_hexstr2d (const char *s, lua_Number *result) { + char *endptr; + *result = strtoul(s, &endptr, 0); + if (endptr == s) return 0; /* conversion failed */ + if (*endptr == '0円') return 1; /* most common case */ + while (isspace(cast(unsigned char, *endptr))) endptr++; + if (*endptr != '0円') return 0; /* invalid trailing characters? */ + return 1; +} /* LUA_NUMBER */ static void read_numeral (LexState *ls, SemInfo *seminfo) { + + if (ls->current == '0') { /* check for hex prefix */ + save_and_next(ls); + if (ls->current == 'x' || ls->current == 'X') { + save_and_next(ls); + while (isxdigit(ls->current)) { + save_and_next(ls); + } + save(ls, '0円'); + if (!luaO_hexstr2d(luaZ_buffer(ls->buff), &seminfo->r)) + luaX_lexerror(ls, "malformed hex number", TK_NUMBER); + return; + } + } + while (isdigit(ls->current)) { save_and_next(ls); }

AltStyle によって変換されたページ (->オリジナル) /