Skip to content

Commit f37ea8c

Browse files
author
zik.saleeba
committed
Now treating a line starting with #! at the start of a picoc file as a
comment line so we can execute it as a shell script. git-svn-id: http://picoc.googlecode.com/svn/trunk@573 21eae674-98b7-11dd-bd71-f92a316d2d60
1 parent cb4c34b commit f37ea8c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

platform/platform_unix.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ char *PlatformReadFile(const char *FileName)
8383
char *ReadText;
8484
FILE *InFile;
8585
int BytesRead;
86+
char *p;
8687

8788
if (stat(FileName, &FileInfo))
8889
ProgramFail(NULL, "can't read file %s\n", FileName);
@@ -102,6 +103,14 @@ char *PlatformReadFile(const char *FileName)
102103
ReadText[BytesRead] = '\0';
103104
fclose(InFile);
104105

106+
if ((ReadText[0] == '#') && (ReadText[1] == '!'))
107+
{
108+
for (*p = ReadText; (*p != '\r') && (*p != '\n'); ++p)
109+
{
110+
*p = ' ';
111+
}
112+
}
113+
105114
return ReadText;
106115
}
107116

0 commit comments

Comments
 (0)