[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: lujit - Malformed number
- From: Mike Pall <mikelu-1009@...>
- Date: Sat, 4 Sep 2010 12:28:39 +0200
Sylvain Fabre wrote:
> We are also evaluating luajit and we get a strange error each time
> we deal with a float (ie like 3.14116) : we get a 'Malformed number
> ...' error.
> In the main core of the program embedding lua, we call the
> setlocale(LC_ALL, "C"); but it does not seem to change anything.
> Even calling the os.setlocale from the lua script does not change
> this.
Maybe some other component is changing the locale (readline or
GTK+ are often the culprits). Or something is setting LC_NUMERIC,
which overrides LC_ALL.
> But i we set the value 3,14116 (ie "french-like"), then the number
> is accepted.
Well, this would still break loadfile() et al.
> Any idea to fix this ? After a look in the luajit code, i was no
> table to find where the decimal point is detected (or not).
This is really deep inside libc in strtod(), which can neither be
easily replaced, nor easily convinced to ignore the locale. Lua
has some NLS-specific workaround, but I had to remove these from
the codebase to reduce dependencies (not every embedded OS/libc
supports the NLS APIs and structs).
Try os.setlocale("C", "numeric") or the equivalent C call after
all other libraries have been initialized.
--Mike