aboutsummaryrefslogtreecommitdiff
path: root/llex.c
diff options
context:
space:
mode:
Diffstat (limited to 'llex.c')
-rw-r--r--llex.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/llex.c b/llex.c
index 22a83ff1..5a742cf6 100644
--- a/llex.c
+++ b/llex.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: llex.c,v 2.40 2010/10/25 12:24:36 roberto Exp roberto $ 2** $Id: llex.c,v 2.41 2010/11/18 18:38:44 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*/
@@ -200,6 +200,9 @@ static void buffreplace (LexState *ls, char from, char to) {
200#define getlocaledecpoint() (localeconv()->decimal_point[0]) 200#define getlocaledecpoint() (localeconv()->decimal_point[0])
201#endif 201#endif
202 202
203
204#define buff2d(b,e) luaO_str2d(luaZ_buffer(b), luaZ_bufflen(b) - 1, e)
205
203/* 206/*
204** in case of format error, try to change decimal point separator to 207** in case of format error, try to change decimal point separator to
205** the one defined in the current locale and check again 208** the one defined in the current locale and check again
@@ -208,7 +211,7 @@ static void trydecpoint (LexState *ls, SemInfo *seminfo) {
208 char old = ls->decpoint; 211 char old = ls->decpoint;
209 ls->decpoint = getlocaledecpoint(); 212 ls->decpoint = getlocaledecpoint();
210 buffreplace(ls, old, ls->decpoint); /* try new decimal separator */ 213 buffreplace(ls, old, ls->decpoint); /* try new decimal separator */
211 if (!luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r)) { 214 if (!buff2d(ls->buff, &seminfo->r)) {
212 /* format error with correct decimal point: no more options */ 215 /* format error with correct decimal point: no more options */
213 buffreplace(ls, ls->decpoint, '.'); /* undo change (for error message) */ 216 buffreplace(ls, ls->decpoint, '.'); /* undo change (for error message) */
214 lexerror(ls, "malformed number", TK_NUMBER); 217 lexerror(ls, "malformed number", TK_NUMBER);
@@ -226,7 +229,7 @@ static void read_numeral (LexState *ls, SemInfo *seminfo) {
226 } while (lislalnum(ls->current) || ls->current == '.'); 229 } while (lislalnum(ls->current) || ls->current == '.');
227 save(ls, '\0'); 230 save(ls, '\0');
228 buffreplace(ls, '.', ls->decpoint); /* follow locale for decimal point */ 231 buffreplace(ls, '.', ls->decpoint); /* follow locale for decimal point */
229 if (!luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r)) /* format error? */ 232 if (!buff2d(ls->buff, &seminfo->r)) /* format error? */
230 trydecpoint(ls, seminfo); /* try to update decimal point separator */ 233 trydecpoint(ls, seminfo); /* try to update decimal point separator */
231} 234}
232 235