--- C:\Users\John\Desktop\lua-5.2.0\lobject.c 2011年11月30日 19:30:16.000000000 -0000 +++ C:\Users\John\Desktop\lua-5.2.0p\lobject.c 2012年01月08日 15:31:51.882000000 -0000 @@ -154,6 +152,29 @@ #endif +#if defined(JH_LUA_BINCONST) +static lua_Number lua_strb2number (const char *s, char **endptr) { + lua_Number r = 0.0; + int i = 0; int f = 0; + *endptr = cast(char *, s); /* nothing is valid yet */ + while (lisspace(cast_uchar(*s))) s++; /* skip initial spaces */ + if (!(*s == '0' && (*(s + 1) == 'b' || *(s + 1) == 'B'))) /* check '0b' */ + return 0.0; /* invalid format (no '0b') */ + s += 2; /* skip '0b' */ + while ((*s == '0') || (*s == '1')) + { + f = 0; + r *= 2.0; + if (*s == '1') r += 1.0; + i++; s++; + while (*s == '_') {s++; f = 1;} + } + if ((i == 0) || (f> 0)) + return 0.0; /* invalid format */ + *endptr = cast(char *, s); /* valid up to here */ + return r; +} +#endif int luaO_str2d (const char *s, size_t len, lua_Number *result) { char *endptr; @@ -161,6 +182,10 @@ return 0; else if (strpbrk(s, "xX")) /* hexa? */ *result = lua_strx2number(s, &endptr); +#if defined(JH_LUA_BINCONST) + else if (strpbrk(s, "bB")) /* bina? */ + *result = lua_strb2number(s, &endptr); +#endif else *result = lua_str2number(s, &endptr); if (endptr == s) return 0; /* nothing recognized */

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