diff options
-rw-r--r-- | ast.h | 1 | ||||
-rw-r--r-- | main.c | 20 |
2 files changed, 21 insertions, 0 deletions
@@ -83,6 +83,7 @@ struct ut_state { uint8_t trim_blocks:1; uint8_t lstrip_blocks:1; uint8_t strict_declarations:1; + uint8_t skip_shebang:1; size_t off; enum ut_block_type blocktype; struct { @@ -148,6 +148,16 @@ parse(struct ut_state *state, const char *source, bool dumponly, enum ut_error_type err; char *msg; + if (state->skip_shebang) { + if (source[0] == '#' && source[1] == '!') { + while (source[0] != '\0' && source[0] != '\n') + source++; + + if (source[0] == '\n') + source++; + } + } + err = ut_parse(state, source); if (!err) { @@ -336,6 +346,16 @@ main(int argc, char **argv) } } + if (!srcstr && !srcfile && argv[optind] != NULL) { + srcfile = read_file(argv[optind]); + state->skip_shebang = 1; + + if (!srcfile) { + rv = UT_ERROR_EXCEPTION; + goto out; + } + } + if ((srcstr && srcfile) || (!srcstr && !srcfile)) { fprintf(stderr, srcstr ? "Options -i and -s are exclusive\n" : "One of -i or -s is required\n"); |