Skip to content

Commit

Permalink
When you're using a scripting mode - "-s", "-m" or "-i" - it now auto…
Browse files Browse the repository at this point in the history
…matically includes all the system headers for you.

This fixes issue 101
  • Loading branch information
zik.saleeba committed Jul 27, 2010
1 parent 444a623 commit 2e7172b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
10 changes: 9 additions & 1 deletion include.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/* a list of libraries we can include */
struct IncludeLibrary
{
const char *IncludeName;
char *IncludeName;
void (*SetupFunction)(void);
struct LibraryFunction *FuncList;
const char *SetupCSource;
Expand Down Expand Up @@ -57,6 +57,14 @@ void IncludeRegister(const char *IncludeName, void (*SetupFunction)(void), struc
IncludeLibList = NewLib;
}

/* include all of the system headers */
void IncludeAllSystemHeaders()
{
struct IncludeLibrary *ThisInclude = IncludeLibList;

for (; ThisInclude != NULL; ThisInclude = ThisInclude->NextLib)
IncludeFile(ThisInclude->IncludeName);
}

/* include one of a number of predefined libraries, or perhaps an actual file */
void IncludeFile(char *FileName)
Expand Down
8 changes: 6 additions & 2 deletions picoc.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,25 @@ int main(int argc, char **argv)
if (argc < 2)
{
printf("Format: picoc <csource1.c>... [- <arg1>...] : run a program (calls main() to start it)\n"
" picoc -m <csource1.c>... [- <arg1>...] : run a program without calling main()\n"
" picoc -s <csource1.c>... [- <arg1>...] : script mode - runs the program without calling main()\n"
" picoc -i : interactive mode\n");
exit(1);
}

Initialise();

if (strcmp(argv[ParamCount], "-m") == 0)
if (strcmp(argv[ParamCount], "-s") == 0 || strcmp(argv[ParamCount], "-m") == 0)
{
DontRunMain = TRUE;
IncludeAllSystemHeaders();
ParamCount++;
}

if (strcmp(argv[ParamCount], "-i") == 0)
{
IncludeAllSystemHeaders();
ParseInteractive();
}
else
{
if (PlatformSetExitPoint())
Expand Down
1 change: 1 addition & 0 deletions picoc.h
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ void IncludeInit();
void IncludeCleanup();
void IncludeRegister(const char *IncludeName, void (*SetupFunction)(void), struct LibraryFunction *FuncList, const char *SetupCSource);
void IncludeFile(char *Filename);
void IncludeAllSystemHeaders();

/* stdio.c */
extern const char StdioDefs[];
Expand Down

0 comments on commit 2e7172b

Please sign in to comment.