diff -urN lua-5.0/src/llex.c lua_new/src/llex.c --- lua-5.0/src/llex.c 2003年03月24日 07:39:34.000000000 -0500 +++ lua_new/src/llex.c 2003年04月04日 10:04:30.000000000 -0500 @@ -7,6 +7,7 @@ #include #include +#include #define llex_c @@ -169,12 +170,38 @@ return l-1; } +static int luaO_hexstr2d (const char *s, lua_Number *result) { + char *endptr; + lua_Number res = strtoul(s, &endptr, 0); + if (endptr == s) return 0; /* no conversion */ + while (isspace((unsigned char)(*endptr))) endptr++; + if (*endptr != '0円') return 0; /* invalid trailing characters? */ + *result = res; + return 1; +} + /* LUA_NUMBER */ static void read_numeral (LexState *LS, int comma, SemInfo *seminfo) { size_t l = 0; checkbuffer(LS, l); if (comma) save(LS, '.', l); + + if (LS->current == '0') { /* check for hex prefix */ + save_and_next(LS, l); + if (LS->current == 'x' || LS->current == 'X') { + save_and_next(LS, l); + while (isxdigit(LS->current)) { + checkbuffer(LS, l); + save_and_next(LS, l); + } + save(LS, '0円', l); + if (!luaO_hexstr2d(luaZ_buffer(LS->buff), &seminfo->r)) + luaX_lexerror(LS, "malformed hex number", TK_NUMBER); + return; + } + } + while (isdigit(LS->current)) { checkbuffer(LS, l); save_and_next(LS, l);

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