aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1996-08-15 15:40:55 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1996-08-15 15:40:55 -0300
commitd763b69740653e68aaddd72edf0bc0a34544415a (patch)
tree57d5f062ee30e18e390c35f2b7ad2bc265e0270f
parent36dd1af92dc0455684b997c15e736b0c56ef3f7c (diff)
downloadlua-d763b69740653e68aaddd72edf0bc0a34544415a.tar.gz
lua-d763b69740653e68aaddd72edf0bc0a34544415a.tar.bz2
lua-d763b69740653e68aaddd72edf0bc0a34544415a.zip
skip first line of a lua file if it starts with a '#' (to allow shell
scripts).
-rw-r--r--opcode.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/opcode.c b/opcode.c
index 4dd61b95..91904199 100644
--- a/opcode.c
+++ b/opcode.c
@@ -3,7 +3,7 @@
3** TecCGraf - PUC-Rio 3** TecCGraf - PUC-Rio
4*/ 4*/
5 5
6char *rcs_opcode="$Id: opcode.c,v 3.70 1996/06/10 19:36:24 roberto Exp roberto $"; 6char *rcs_opcode="$Id: opcode.c,v 3.71 1996/07/24 17:55:57 roberto Exp roberto $";
7 7
8#include <setjmp.h> 8#include <setjmp.h>
9#include <stdio.h> 9#include <stdio.h>
@@ -551,7 +551,13 @@ int lua_dofile (char *filename)
551 return 2; 551 return 2;
552 c = fgetc(f); 552 c = fgetc(f);
553 ungetc(c, f); 553 ungetc(c, f);
554 status = (c == ID_CHUNK) ? luaI_undump(f) : do_protectedmain(); 554 if (c == ID_CHUNK)
555 status = luaI_undump(f);
556 else {
557 if (c == '#')
558 while ((c=fgetc(f)) != '\n') /* skip first line */;
559 status = do_protectedmain();
560 }
555 lua_closefile(); 561 lua_closefile();
556 return status; 562 return status;
557} 563}