aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--llex.c20
-rw-r--r--makefile1
2 files changed, 13 insertions, 8 deletions
diff --git a/llex.c b/llex.c
index d99d9015..f88057fe 100644
--- a/llex.c
+++ b/llex.c
@@ -211,8 +211,16 @@ static int check_next2 (LexState *ls, const char *set) {
211 211
212/* LUA_NUMBER */ 212/* LUA_NUMBER */
213/* 213/*
214** this function is quite liberal in what it accepts, as 'luaO_str2num' 214** This function is quite liberal in what it accepts, as 'luaO_str2num'
215** will reject ill-formed numerals. 215** will reject ill-formed numerals. Roughly, it accepts the following
216** pattern:
217**
218** %d(%x|%.|([Ee][+-]?))* | 0[Xx](%x|%.|([Pp][+-]?))*
219**
220** The only tricky part is to accept [+-] only after a valid exponent
221** mark, to avoid reading '3-4' or '0xe+1' as a single number.
222**
223** The caller might have already read an initial dot.
216*/ 224*/
217static int read_numeral (LexState *ls, SemInfo *seminfo) { 225static int read_numeral (LexState *ls, SemInfo *seminfo) {
218 TValue obj; 226 TValue obj;
@@ -223,15 +231,13 @@ static int read_numeral (LexState *ls, SemInfo *seminfo) {
223 if (first == '0' && check_next2(ls, "xX")) /* hexadecimal? */ 231 if (first == '0' && check_next2(ls, "xX")) /* hexadecimal? */
224 expo = "Pp"; 232 expo = "Pp";
225 for (;;) { 233 for (;;) {
226 if (check_next2(ls, expo)) /* exponent part? */ 234 if (check_next2(ls, expo)) /* exponent mark? */
227 check_next2(ls, "-+"); /* optional exponent sign */ 235 check_next2(ls, "-+"); /* optional exponent sign */
228 if (lisxdigit(ls->current)) 236 else if (lisxdigit(ls->current) || ls->current == '.') /* '%x|%.' */
229 save_and_next(ls);
230 else if (ls->current == '.')
231 save_and_next(ls); 237 save_and_next(ls);
232 else break; 238 else break;
233 } 239 }
234 if (lislalnum(ls->current)) /* is numeral touching an alpha num? */ 240 if (lislalpha(ls->current)) /* is numeral touching a letter? */
235 save_and_next(ls); /* force an error */ 241 save_and_next(ls); /* force an error */
236 save(ls, '\0'); 242 save(ls, '\0');
237 if (luaO_str2num(luaZ_buffer(ls->buff), &obj) == 0) /* format error? */ 243 if (luaO_str2num(luaZ_buffer(ls->buff), &obj) == 0) /* format error? */
diff --git a/makefile b/makefile
index cb6cece8..cf238aeb 100644
--- a/makefile
+++ b/makefile
@@ -107,7 +107,6 @@ $(LUAC_T): $(LUAC_O) $(CORE_T)
107 $(CC) -o $@ $(MYLDFLAGS) $(LUAC_O) $(CORE_T) $(LIBS) $(MYLIBS) 107 $(CC) -o $@ $(MYLDFLAGS) $(LUAC_O) $(CORE_T) $(LIBS) $(MYLIBS)
108 108
109clean: 109clean:
110 rcsclean -u
111 $(RM) $(ALL_T) $(ALL_O) 110 $(RM) $(ALL_T) $(ALL_O)
112 111
113depend: 112depend: