|
This is off topic, but if I'm not running linux, how do I apply one of
these "patches" on say Windows ? Is there a freeware Win32 command line tool that does this? Brian Mike Pall wrote: Hi, our prayers have been answered with the latest 5.1-rc: $ lua -e 'print(0xff)' 255 Well ... almost. This only works if your strtod() is C99 compliant -- which is probably true for most systems nowadays. AFAIK a prominent exception is the MSVC library. :-/ A patch for non-C99 compliant systems is attached. This fixes (plain) hex number parsing for both the lexer and tonumber(). On C99 compliant systems you also get hex numbers with exponents (0x1p10 == 1024). But negative exponents don't work (this is tricky to fix). So I didn't bother to add this to my patch. [ Important note if you redefine lua_Number to use integers: The correct way to change the number parsing is: #define lua_str2number(s,p) strtoul((s), (p), 10) Do not use strtol or base 0. This either breaks large positive hex numbers or misparses numbers with a leading zero as octal. But base 10 disables parsing of hex numbers. So you need to use the attached patch, too. ] BTW: The lexer is now mostly ignorant about the exact syntax of numbers. It accepts anything matching /[\d.]+([eE][+-])?[\w_]*/. This could be (ab)used for global constants, like 0_FOO_BAR. :-) Bye, Mike |