lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Mason Larobina wrote:
> Numbers of the format "1.0" cause luakit to crash when linked against
> LuaJIT in German (and other) locales. Changing all .'s to ,'s solves
> the problem (though that's not really a solution) and forcing a
> non-German locale also works.

This is not a "crash" by any definition. Please watch your
terminology.

Applications embedding Lua or LuaJIT should NOT set a numeric
locale or explicitly set it to "C". Yes, this applies to _both_ VMs.

Actually Lua has an ugly workaround for the issue with the parser.
But it still fails with tonumber() and the explicit (tostring())
or implicit number-to-string conversions. This affects e.g.
print() and so on.

The problem is deep inside libc in strtod() and sprintf(). These
can neither be easily replaced, nor easily convinced to ignore the
locale.

I do not believe in curing a single symptom, so I won't add any
kind of incomplete workaround for this to LuaJIT.

One needs to fix the root cause, i.e. the embedding (luakit) must
use setlocale(LC_NUMERIC, "C") after any setlocale calls in 3rd
party libraries, but before initializing Lua or LuaJIT.

--Mike