aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1996-09-09 11:11:11 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1996-09-09 11:11:11 -0300
commitf0cc2d55067d32c1232d9483721254360d4c3bae (patch)
tree3aff379cd171fdf2b4406cdd9bce1b466661f395
parentd289ac81d3629f8dc494a11929d16f03accd1007 (diff)
downloadlua-f0cc2d55067d32c1232d9483721254360d4c3bae.tar.gz
lua-f0cc2d55067d32c1232d9483721254360d4c3bae.tar.bz2
lua-f0cc2d55067d32c1232d9483721254360d4c3bae.zip
BUG: a program ending in a comment without EOL made lex loops forever.
-rw-r--r--inout.c5
-rw-r--r--lex.c10
2 files changed, 5 insertions, 10 deletions
diff --git a/inout.c b/inout.c
index 1d618596..237dd574 100644
--- a/inout.c
+++ b/inout.c
@@ -5,7 +5,7 @@
5** Also provides some predefined lua functions. 5** Also provides some predefined lua functions.
6*/ 6*/
7 7
8char *rcs_inout="$Id: inout.c,v 2.37 1996/05/28 21:07:32 roberto Exp $"; 8char *rcs_inout="$Id: inout.c,v 2.38 1996/07/12 20:00:26 roberto Exp roberto $";
9 9
10#include <stdio.h> 10#include <stdio.h>
11 11
@@ -31,7 +31,8 @@ static char *st;
31*/ 31*/
32static int fileinput (void) 32static int fileinput (void)
33{ 33{
34 return fgetc (fp); 34 int c = fgetc(fp);
35 return (c == EOF) ? 0 : c;
35} 36}
36 37
37/* 38/*
diff --git a/lex.c b/lex.c
index cbb7b082..1a6439fa 100644
--- a/lex.c
+++ b/lex.c
@@ -1,4 +1,4 @@
1char *rcs_lex = "$Id: lex.c,v 2.33 1996/05/28 21:07:32 roberto Exp roberto $"; 1char *rcs_lex = "$Id: lex.c,v 2.34 1996/05/30 14:04:07 roberto Exp roberto $";
2 2
3 3
4#include <ctype.h> 4#include <ctype.h>
@@ -82,7 +82,6 @@ static int read_long_string (char *yytext, int buffsize)
82 yytext = luaI_buffer(buffsize *= 2); 82 yytext = luaI_buffer(buffsize *= 2);
83 switch (current) 83 switch (current)
84 { 84 {
85 case EOF:
86 case 0: 85 case 0:
87 save(0); 86 save(0);
88 return WRONGTOKEN; 87 return WRONGTOKEN;
@@ -132,10 +131,6 @@ int luaY_lex (void)
132 int tokensize = 0; 131 int tokensize = 0;
133 switch (current) 132 switch (current)
134 { 133 {
135 case EOF:
136 case 0:
137 save(0);
138 return 0;
139 case '\n': linelasttoken = ++lua_linenumber; 134 case '\n': linelasttoken = ++lua_linenumber;
140 case ' ': 135 case ' ':
141 case '\r': /* CR: to avoid problems with DOS/Windows */ 136 case '\r': /* CR: to avoid problems with DOS/Windows */
@@ -206,7 +201,6 @@ int luaY_lex (void)
206 yytext = luaI_buffer(buffsize *= 2); 201 yytext = luaI_buffer(buffsize *= 2);
207 switch (current) 202 switch (current)
208 { 203 {
209 case EOF:
210 case 0: 204 case 0:
211 case '\n': 205 case '\n':
212 save(0); 206 save(0);
@@ -316,7 +310,7 @@ int luaY_lex (void)
316 return NUMBER; 310 return NUMBER;
317 } 311 }
318 312
319 default: /* also end of file */ 313 default: /* also end of program (0) */
320 { 314 {
321 save_and_next(); 315 save_and_next();
322 return yytext[0]; 316 return yytext[0];