summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1997-07-29 10:33:15 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1997-07-29 10:33:15 -0300
commit11d97c34d5e3d5e45e3e6ffd12effe95d6f483cc (patch)
tree71ad9881572f476fb8650fbae2201c26e442943d
parent66be42549e5eb5f25de6b8cbfee8a064b914cbb0 (diff)
downloadlua-github-11d97c34d5e3d5e45e3e6ffd12effe95d6f483cc.tar.gz
skipping of '#' in first line is done by lex.c.
-rw-r--r--inout.c8
-rw-r--r--lex.c13
2 files changed, 14 insertions, 7 deletions
diff --git a/inout.c b/inout.c
index f4694fe1..ad46f5bd 100644
--- a/inout.c
+++ b/inout.c
@@ -5,7 +5,7 @@
** Also provides some predefined lua functions.
*/
-char *rcs_inout="$Id: inout.c,v 2.69 1997/06/27 22:38:49 roberto Exp roberto $";
+char *rcs_inout="$Id: inout.c,v 2.70 1997/07/07 21:05:51 roberto Exp roberto $";
#include <stdio.h>
#include <string.h>
@@ -71,12 +71,8 @@ int lua_dofile (char *filename)
f = freopen(filename, "rb", f); /* set binary mode */
status = lua_doFILE(f, 1);
}
- else {
- if (c == '#')
- while ((c=fgetc(f)) != '\n' && c != 0) /* skip first line */;
- ungetc(c, f);
+ else
status = lua_doFILE(f, 0);
- }
if (f != stdin)
fclose(f);
return status;
diff --git a/lex.c b/lex.c
index 044ca3ae..a1ffbbee 100644
--- a/lex.c
+++ b/lex.c
@@ -1,4 +1,4 @@
-char *rcs_lex = "$Id: lex.c,v 3.5 1997/06/16 16:50:22 roberto Exp roberto $";
+char *rcs_lex = "$Id: lex.c,v 3.6 1997/07/01 19:32:41 roberto Exp roberto $";
#include <ctype.h>
@@ -37,6 +37,16 @@ static struct {
static int iflevel; /* level of nested $if's */
+
+static void firstline (void)
+{
+ int c = zgetc(lex_z);
+ if (c == '#')
+ while((c=zgetc(lex_z)) != '\n' && c != EOZ) /* skip first line */;
+ zungetc(lex_z);
+}
+
+
void lua_setinput (ZIO *z)
{
current = '\n';
@@ -45,6 +55,7 @@ void lua_setinput (ZIO *z)
ifstate[0].skip = 0;
ifstate[0].elsepart = 1; /* to avoid a free $else */
lex_z = z;
+ firstline();
}