diff options
-rw-r--r-- | liolib.c | 13 | ||||
-rw-r--r-- | llex.c | 9 | ||||
-rw-r--r-- | lstrlib.c | 5 | ||||
-rw-r--r-- | luaconf.h | 14 |
4 files changed, 21 insertions, 20 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: liolib.c,v 2.142 2015/01/02 12:50:28 roberto Exp roberto $ | 2 | ** $Id: liolib.c,v 2.143 2015/03/06 19:09:08 roberto Exp roberto $ |
3 | ** Standard I/O (and system) library | 3 | ** Standard I/O (and system) library |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -410,12 +410,6 @@ static int readdigits (RN *rn, int hex) { | |||
410 | } | 410 | } |
411 | 411 | ||
412 | 412 | ||
413 | /* access to locale "radix character" (decimal point) */ | ||
414 | #if !defined(l_getlocaledecpoint) | ||
415 | #define l_getlocaledecpoint() (localeconv()->decimal_point[0]) | ||
416 | #endif | ||
417 | |||
418 | |||
419 | /* | 413 | /* |
420 | ** Read a number: first reads a valid prefix of a numeral into a buffer. | 414 | ** Read a number: first reads a valid prefix of a numeral into a buffer. |
421 | ** Then it calls 'lua_stringtonumber' to check whether the format is | 415 | ** Then it calls 'lua_stringtonumber' to check whether the format is |
@@ -425,9 +419,10 @@ static int read_number (lua_State *L, FILE *f) { | |||
425 | RN rn; | 419 | RN rn; |
426 | int count = 0; | 420 | int count = 0; |
427 | int hex = 0; | 421 | int hex = 0; |
428 | char decp[2] = "."; | 422 | char decp[2]; |
429 | rn.f = f; rn.n = 0; | 423 | rn.f = f; rn.n = 0; |
430 | decp[0] = l_getlocaledecpoint(); /* get decimal point from locale */ | 424 | decp[0] = lua_getlocaledecpoint(); /* get decimal point from locale */ |
425 | decp[1] = '\0'; | ||
431 | l_lockfile(rn.f); | 426 | l_lockfile(rn.f); |
432 | do { rn.c = l_getc(rn.f); } while (isspace(rn.c)); /* skip spaces */ | 427 | do { rn.c = l_getc(rn.f); } while (isspace(rn.c)); /* skip spaces */ |
433 | test2(&rn, "-+"); /* optional signal */ | 428 | test2(&rn, "-+"); /* optional signal */ |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: llex.c,v 2.90 2015/03/03 18:17:04 roberto Exp roberto $ | 2 | ** $Id: llex.c,v 2.91 2015/03/28 19:14:47 roberto Exp roberto $ |
3 | ** Lexical Analyzer | 3 | ** Lexical Analyzer |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -221,11 +221,6 @@ static void buffreplace (LexState *ls, char from, char to) { | |||
221 | } | 221 | } |
222 | 222 | ||
223 | 223 | ||
224 | #if !defined(l_getlocaledecpoint) | ||
225 | #define l_getlocaledecpoint() (localeconv()->decimal_point[0]) | ||
226 | #endif | ||
227 | |||
228 | |||
229 | #define buff2num(b,o) (luaO_str2num(luaZ_buffer(b), o) != 0) | 224 | #define buff2num(b,o) (luaO_str2num(luaZ_buffer(b), o) != 0) |
230 | 225 | ||
231 | /* | 226 | /* |
@@ -234,7 +229,7 @@ static void buffreplace (LexState *ls, char from, char to) { | |||
234 | */ | 229 | */ |
235 | static void trydecpoint (LexState *ls, TValue *o) { | 230 | static void trydecpoint (LexState *ls, TValue *o) { |
236 | char old = ls->decpoint; | 231 | char old = ls->decpoint; |
237 | ls->decpoint = l_getlocaledecpoint(); | 232 | ls->decpoint = lua_getlocaledecpoint(); |
238 | buffreplace(ls, old, ls->decpoint); /* try new decimal separator */ | 233 | buffreplace(ls, old, ls->decpoint); /* try new decimal separator */ |
239 | if (!buff2num(ls->buff, o)) { | 234 | if (!buff2num(ls->buff, o)) { |
240 | /* format error with correct decimal point: no more options */ | 235 | /* format error with correct decimal point: no more options */ |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lstrlib.c,v 1.226 2015/02/09 18:05:46 roberto Exp roberto $ | 2 | ** $Id: lstrlib.c,v 1.227 2015/03/28 19:14:47 roberto Exp roberto $ |
3 | ** Standard library for string operations and pattern-matching | 3 | ** Standard library for string operations and pattern-matching |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -803,6 +803,7 @@ static int str_gsub (lua_State *L) { | |||
803 | ** Hexadecimal floating-point formatter | 803 | ** Hexadecimal floating-point formatter |
804 | */ | 804 | */ |
805 | 805 | ||
806 | #include <locale.h> | ||
806 | #include <math.h> | 807 | #include <math.h> |
807 | 808 | ||
808 | #define SIZELENMOD (sizeof(LUA_NUMBER_FRMLEN)/sizeof(char)) | 809 | #define SIZELENMOD (sizeof(LUA_NUMBER_FRMLEN)/sizeof(char)) |
@@ -850,7 +851,7 @@ static int num2straux (char *buff, lua_Number x) { | |||
850 | m = adddigit(buff, n++, m * (1 << L_NBFD)); /* add first digit */ | 851 | m = adddigit(buff, n++, m * (1 << L_NBFD)); /* add first digit */ |
851 | e -= L_NBFD; /* this digit goes before the radix point */ | 852 | e -= L_NBFD; /* this digit goes before the radix point */ |
852 | if (m > 0) { /* more digits? */ | 853 | if (m > 0) { /* more digits? */ |
853 | buff[n++] = '.'; /* add radix point */ | 854 | buff[n++] = lua_getlocaledecpoint(); /* add radix point */ |
854 | do { /* add as many digits as needed */ | 855 | do { /* add as many digits as needed */ |
855 | m = adddigit(buff, n++, m * 16); | 856 | m = adddigit(buff, n++, m * 16); |
856 | } while (m > 0); | 857 | } while (m > 0); |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: luaconf.h,v 1.248 2015/03/06 19:49:50 roberto Exp roberto $ | 2 | ** $Id: luaconf.h,v 1.249 2015/03/31 12:00:07 roberto Exp roberto $ |
3 | ** Configuration file for Lua | 3 | ** Configuration file for Lua |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -569,7 +569,7 @@ | |||
569 | 569 | ||
570 | /* | 570 | /* |
571 | ** {================================================================== | 571 | ** {================================================================== |
572 | ** Dependencies with C99 | 572 | ** Dependencies with C99 and other C details |
573 | ** =================================================================== | 573 | ** =================================================================== |
574 | */ | 574 | */ |
575 | 575 | ||
@@ -626,6 +626,16 @@ | |||
626 | #endif | 626 | #endif |
627 | #endif | 627 | #endif |
628 | 628 | ||
629 | |||
630 | /* | ||
631 | @@ lua_getlocaledecpoint gets the locale "radix character" (decimal point). | ||
632 | ** Change that if you do not want to use C locales. (Code using this | ||
633 | ** macro must include header 'locale.h'.) | ||
634 | */ | ||
635 | #if !defined(lua_getlocaledecpoint) | ||
636 | #define lua_getlocaledecpoint() (localeconv()->decimal_point[0]) | ||
637 | #endif | ||
638 | |||
629 | /* }================================================================== */ | 639 | /* }================================================================== */ |
630 | 640 | ||
631 | 641 | ||