diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2007-09-14 10:27:04 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2007-09-14 10:27:04 -0300 |
commit | 2622ed25282e2e75e1585b28ce9fa56fc032f7b7 (patch) | |
tree | 24f6e1a88bc812f83b98c5f2c3b0b4ef360faa8e | |
parent | 9cb0607f6f685c78f4191743c387a067117524bb (diff) | |
download | lua-2622ed25282e2e75e1585b28ce9fa56fc032f7b7.tar.gz lua-2622ed25282e2e75e1585b28ce9fa56fc032f7b7.tar.bz2 lua-2622ed25282e2e75e1585b28ce9fa56fc032f7b7.zip |
better way to handle redefinitions of 'localeconv'
-rw-r--r-- | llex.c | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: llex.c,v 2.25 2007/05/11 17:28:56 roberto Exp roberto $ | 2 | ** $Id: llex.c,v 2.26 2007/08/09 20:29:15 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 | */ |
@@ -181,11 +181,14 @@ static void buffreplace (LexState *ls, char from, char to) { | |||
181 | } | 181 | } |
182 | 182 | ||
183 | 183 | ||
184 | #if !defined(getlocaledecpoint) | ||
185 | #define getlocaledecpoint() (localeconv()->decimal_point[0]) | ||
186 | #endif | ||
187 | |||
184 | static void trydecpoint (LexState *ls, SemInfo *seminfo) { | 188 | static void trydecpoint (LexState *ls, SemInfo *seminfo) { |
185 | /* format error: try to update decimal point separator */ | 189 | /* format error: try to update decimal point separator */ |
186 | struct lconv *cv = localeconv(); | ||
187 | char old = ls->decpoint; | 190 | char old = ls->decpoint; |
188 | ls->decpoint = (cv ? cv->decimal_point[0] : '.'); | 191 | ls->decpoint = getlocaledecpoint(); |
189 | buffreplace(ls, old, ls->decpoint); /* try updated decimal separator */ | 192 | buffreplace(ls, old, ls->decpoint); /* try updated decimal separator */ |
190 | if (!luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r)) { | 193 | if (!luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r)) { |
191 | /* format error with correct decimal point: no more options */ | 194 | /* format error with correct decimal point: no more options */ |