diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1996-08-15 15:40:55 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1996-08-15 15:40:55 -0300 |
commit | d763b69740653e68aaddd72edf0bc0a34544415a (patch) | |
tree | 57d5f062ee30e18e390c35f2b7ad2bc265e0270f | |
parent | 36dd1af92dc0455684b997c15e736b0c56ef3f7c (diff) | |
download | lua-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.c | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -3,7 +3,7 @@ | |||
3 | ** TecCGraf - PUC-Rio | 3 | ** TecCGraf - PUC-Rio |
4 | */ | 4 | */ |
5 | 5 | ||
6 | char *rcs_opcode="$Id: opcode.c,v 3.70 1996/06/10 19:36:24 roberto Exp roberto $"; | 6 | char *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 | } |