output version info

This commit is contained in:
Joseph Poirier 2015-06-06 22:37:28 -05:00
parent 4165f0d2a8
commit 43300d86b0

25
picoc.c
View file

@ -1,6 +1,6 @@
/* picoc main program - this varies depending on your operating system and /* picoc main program - this varies depending on your operating system and
* how you're using picoc */ * how you're using picoc */
/* include only picoc.h here - should be able to use it with only the external interfaces, no internals from interpreter.h */ /* include only picoc.h here - should be able to use it with only the external interfaces, no internals from interpreter.h */
#include "picoc.h" #include "picoc.h"
@ -19,24 +19,25 @@ int main(int argc, char **argv)
int DontRunMain = FALSE; int DontRunMain = FALSE;
int StackSize = getenv("STACKSIZE") ? atoi(getenv("STACKSIZE")) : PICOC_STACK_SIZE; int StackSize = getenv("STACKSIZE") ? atoi(getenv("STACKSIZE")) : PICOC_STACK_SIZE;
Picoc pc; Picoc pc;
if (argc < 2) if (argc < 2)
{ {
printf("Format: picoc <csource1.c>... [- <arg1>...] : run a program (calls main() to start it)\n" printf(PICOC_VERSION " \n"
"Format: picoc <csource1.c>... [- <arg1>...] : run a program (calls main() to start it)\n"
" picoc -s <csource1.c>... [- <arg1>...] : script mode - runs the program without calling main()\n" " picoc -s <csource1.c>... [- <arg1>...] : script mode - runs the program without calling main()\n"
" picoc -i : interactive mode\n"); " picoc -i : interactive mode\n");
exit(1); exit(1);
} }
PicocInitialise(&pc, StackSize); PicocInitialise(&pc, StackSize);
if (strcmp(argv[ParamCount], "-s") == 0 || strcmp(argv[ParamCount], "-m") == 0) if (strcmp(argv[ParamCount], "-s") == 0 || strcmp(argv[ParamCount], "-m") == 0)
{ {
DontRunMain = TRUE; DontRunMain = TRUE;
PicocIncludeAllSystemHeaders(&pc); PicocIncludeAllSystemHeaders(&pc);
ParamCount++; ParamCount++;
} }
if (argc > ParamCount && strcmp(argv[ParamCount], "-i") == 0) if (argc > ParamCount && strcmp(argv[ParamCount], "-i") == 0)
{ {
PicocIncludeAllSystemHeaders(&pc); PicocIncludeAllSystemHeaders(&pc);
@ -49,14 +50,14 @@ int main(int argc, char **argv)
PicocCleanup(&pc); PicocCleanup(&pc);
return pc.PicocExitValue; return pc.PicocExitValue;
} }
for (; ParamCount < argc && strcmp(argv[ParamCount], "-") != 0; ParamCount++) for (; ParamCount < argc && strcmp(argv[ParamCount], "-") != 0; ParamCount++)
PicocPlatformScanFile(&pc, argv[ParamCount]); PicocPlatformScanFile(&pc, argv[ParamCount]);
if (!DontRunMain) if (!DontRunMain)
PicocCallMain(&pc, argc - ParamCount, &argv[ParamCount]); PicocCallMain(&pc, argc - ParamCount, &argv[ParamCount]);
} }
PicocCleanup(&pc); PicocCleanup(&pc);
return pc.PicocExitValue; return pc.PicocExitValue;
} }
@ -69,7 +70,7 @@ int main(int argc, char **argv)
# include "../string.h" # include "../string.h"
int picoc(char *SourceStr) int picoc(char *SourceStr)
{ {
char *pos; char *pos;
PicocInitialise(HEAP_SIZE); PicocInitialise(HEAP_SIZE);
@ -93,12 +94,12 @@ int picoc(char *SourceStr)
return PicocExitValue; return PicocExitValue;
} }
if (SourceStr) if (SourceStr)
PicocParse("nofile", SourceStr, strlen(SourceStr), TRUE, TRUE, FALSE); PicocParse("nofile", SourceStr, strlen(SourceStr), TRUE, TRUE, FALSE);
PicocParseInteractive(); PicocParseInteractive();
PicocCleanup(); PicocCleanup();
return PicocExitValue; return PicocExitValue;
} }
# endif # endif