aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 @@
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.69 1997/06/27 22:38:49 roberto Exp roberto $"; 8char *rcs_inout="$Id: inout.c,v 2.70 1997/07/07 21:05:51 roberto Exp roberto $";
9 9
10#include <stdio.h> 10#include <stdio.h>
11#include <string.h> 11#include <string.h>
@@ -71,12 +71,8 @@ int lua_dofile (char *filename)
71 f = freopen(filename, "rb", f); /* set binary mode */ 71 f = freopen(filename, "rb", f); /* set binary mode */
72 status = lua_doFILE(f, 1); 72 status = lua_doFILE(f, 1);
73 } 73 }
74 else { 74 else
75 if (c == '#')
76 while ((c=fgetc(f)) != '\n' && c != 0) /* skip first line */;
77 ungetc(c, f);
78 status = lua_doFILE(f, 0); 75 status = lua_doFILE(f, 0);
79 }
80 if (f != stdin) 76 if (f != stdin)
81 fclose(f); 77 fclose(f);
82 return status; 78 return status;
diff --git a/lex.c b/lex.c
index 044ca3ae..a1ffbbee 100644
--- a/lex.c
+++ b/lex.c
@@ -1,4 +1,4 @@
1char *rcs_lex = "$Id: lex.c,v 3.5 1997/06/16 16:50:22 roberto Exp roberto $"; 1char *rcs_lex = "$Id: lex.c,v 3.6 1997/07/01 19:32:41 roberto Exp roberto $";
2 2
3 3
4#include <ctype.h> 4#include <ctype.h>
@@ -37,6 +37,16 @@ static struct {
37static int iflevel; /* level of nested $if's */ 37static int iflevel; /* level of nested $if's */
38 38
39 39
40
41static void firstline (void)
42{
43 int c = zgetc(lex_z);
44 if (c == '#')
45 while((c=zgetc(lex_z)) != '\n' && c != EOZ) /* skip first line */;
46 zungetc(lex_z);
47}
48
49
40void lua_setinput (ZIO *z) 50void lua_setinput (ZIO *z)
41{ 51{
42 current = '\n'; 52 current = '\n';
@@ -45,6 +55,7 @@ void lua_setinput (ZIO *z)
45 ifstate[0].skip = 0; 55 ifstate[0].skip = 0;
46 ifstate[0].elsepart = 1; /* to avoid a free $else */ 56 ifstate[0].elsepart = 1; /* to avoid a free $else */
47 lex_z = z; 57 lex_z = z;
58 firstline();
48} 59}
49 60
50 61