diff --git a/platform/platform_unix.c b/platform/platform_unix.c index 50c3119..15f1df3 100644 --- a/platform/platform_unix.c +++ b/platform/platform_unix.c @@ -107,7 +107,7 @@ char *PlatformReadFile(Picoc *pc, const char *FileName) if ((ReadText[0] == '#') && (ReadText[1] == '!')) { - for (p = ReadText; (*p != '\r') && (*p != '\n'); ++p) + for (p = ReadText; (*p != '\0') && (*p != '\r') && (*p != '\n'); ++p) { *p = ' '; } diff --git a/tests/69_shebang_script.c b/tests/69_shebang_script.c new file mode 100644 index 0000000..7a6e2fd --- /dev/null +++ b/tests/69_shebang_script.c @@ -0,0 +1 @@ +#! \ No newline at end of file diff --git a/tests/69_shebang_script.expect b/tests/69_shebang_script.expect new file mode 100644 index 0000000..e69de29 diff --git a/tests/Makefile b/tests/Makefile index 643a9ae..c18f8cf 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -62,6 +62,7 @@ TESTS= 00_assignment.test \ 66_printf_undefined.test \ 67_macro_crash.test \ 68_return.test \ + 69_shebang_script.test \ include csmith/Makefile @@ -71,6 +72,9 @@ include csmith/Makefile @if [ "x`echo $* | grep args`" != "x" ]; \ then \ ../picoc $*.c - arg1 arg2 arg3 arg4 2>&1 >$*.output; \ + elif [ "x`echo $* | grep script`" != "x" ]; \ + then \ + ../picoc -s $*.c 2>&1 >$*.output; \ else \ ../picoc $*.c 2>&1 >$*.output; \ fi