Skip to content

Commit 0232fbf

Browse files
committed
now that 'luaO_str2num' always accepts a dot as a radix character,
the lexer does not need to bother with this issue.
1 parent ed110f6 commit 0232fbf

File tree

2 files changed

+3
-35
lines changed

2 files changed

+3
-35
lines changed

llex.c

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
** $Id: llex.c,v 2.94 2015/10/28 18:51:47 roberto Exp roberto $
2+
** $Id: llex.c,v 2.95 2015/11/19 19:16:22 roberto Exp roberto $
33
** Lexical Analyzer
44
** See Copyright Notice in lua.h
55
*/
@@ -162,7 +162,6 @@ static void inclinenumber (LexState *ls) {
162162
void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, TString *source,
163163
int firstchar) {
164164
ls->t.token = 0;
165-
ls->decpoint = '.';
166165
ls->L = L;
167166
ls->current = firstchar;
168167
ls->lookahead.token = TK_EOS; /* no look-ahead token */
@@ -207,35 +206,6 @@ static int check_next2 (LexState *ls, const char *set) {
207206
}
208207

209208

210-
/*
211-
** change all characters 'from' in buffer to 'to'
212-
*/
213-
static void buffreplace (LexState *ls, char from, char to) {
214-
if (from != to) {
215-
size_t n = luaZ_bufflen(ls->buff);
216-
char *p = luaZ_buffer(ls->buff);
217-
while (n--)
218-
if (p[n] == from) p[n] = to;
219-
}
220-
}
221-
222-
223-
/*
224-
** in case of format error, try to change decimal point separator to
225-
** the one defined in the current locale and check again
226-
*/
227-
static void trydecpoint (LexState *ls, TValue *o) {
228-
char old = ls->decpoint;
229-
ls->decpoint = lua_getlocaledecpoint();
230-
buffreplace(ls, old, ls->decpoint); /* try new decimal separator */
231-
if (luaO_str2num(luaZ_buffer(ls->buff), o) == 0) {
232-
/* format error with correct decimal point: no more options */
233-
buffreplace(ls, ls->decpoint, '.'); /* undo change (for error message) */
234-
lexerror(ls, "malformed number", TK_FLT);
235-
}
236-
}
237-
238-
239209
/* LUA_NUMBER */
240210
/*
241211
** this function is quite liberal in what it accepts, as 'luaO_str2num'
@@ -259,9 +229,8 @@ static int read_numeral (LexState *ls, SemInfo *seminfo) {
259229
else break;
260230
}
261231
save(ls, '\0');
262-
buffreplace(ls, '.', ls->decpoint); /* follow locale for decimal point */
263232
if (luaO_str2num(luaZ_buffer(ls->buff), &obj) == 0) /* format error? */
264-
trydecpoint(ls, &obj); /* try to update decimal point separator */
233+
lexerror(ls, "malformed number", TK_FLT);
265234
if (ttisinteger(&obj)) {
266235
seminfo->i = ivalue(&obj);
267236
return TK_INT;

llex.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
** $Id: llex.h,v 1.77 2014/10/25 11:50:46 roberto Exp roberto $
2+
** $Id: llex.h,v 1.78 2014/10/29 15:38:24 roberto Exp roberto $
33
** Lexical Analyzer
44
** See Copyright Notice in lua.h
55
*/
@@ -69,7 +69,6 @@ typedef struct LexState {
6969
struct Dyndata *dyd; /* dynamic structures used by the parser */
7070
TString *source; /* current source name */
7171
TString *envn; /* environment variable name */
72-
char decpoint; /* locale decimal point */
7372
} LexState;
7473

7574

0 commit comments

Comments
 (0)