Calls to exit(n) now return the exit value n to the command line.
This fixes issue 100. git-svn-id: http://picoc.googlecode.com/svn/trunk@478 21eae674-98b7-11dd-bd71-f92a316d2d60
This commit is contained in:
parent
8e02f32095
commit
df9129b355
5
picoc.c
5
picoc.c
|
@ -3,7 +3,6 @@
|
|||
#define CALL_MAIN_NO_ARGS "main();"
|
||||
#define CALL_MAIN_WITH_ARGS "main(__argc,__argv);"
|
||||
|
||||
|
||||
/* initialise everything */
|
||||
void Initialise(int StackSize)
|
||||
{
|
||||
|
@ -93,7 +92,7 @@ int main(int argc, char **argv)
|
|||
if (PlatformSetExitPoint())
|
||||
{
|
||||
Cleanup();
|
||||
return 1;
|
||||
return ExitValue;
|
||||
}
|
||||
|
||||
for (; ParamCount < argc && strcmp(argv[ParamCount], "-") != 0; ParamCount++)
|
||||
|
@ -125,7 +124,7 @@ int picoc(char *SourceStr)
|
|||
if (ExitBuf[40]) {
|
||||
printf("leaving picoC\n\r");
|
||||
Cleanup();
|
||||
return 1;
|
||||
return ExitValue;
|
||||
}
|
||||
|
||||
if (SourceStr)
|
||||
|
|
3
picoc.h
3
picoc.h
|
@ -428,10 +428,11 @@ void PlatformPutc(unsigned char OutCh, union OutputStreamInfo *);
|
|||
void PlatformErrorPrefix(struct ParseState *Parser);
|
||||
void PlatformPrintf(const char *Format, ...);
|
||||
void PlatformVPrintf(const char *Format, va_list Args);
|
||||
void PlatformExit();
|
||||
void PlatformExit(int ExitVal);
|
||||
void PlatformLibraryInit();
|
||||
void Initialise();
|
||||
void Cleanup();
|
||||
extern int ExitValue;
|
||||
|
||||
/* include.c */
|
||||
void IncludeInit();
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
#include "picoc.h"
|
||||
|
||||
/* the value passed to exit() */
|
||||
int ExitValue = 0;
|
||||
|
||||
void PrintSourceTextErrorLine(const char *FileName, const char *SourceText, int Line, int CharacterPos)
|
||||
{
|
||||
int LineCount;
|
||||
|
|
|
@ -106,8 +106,9 @@ void PlatformScanFile(const char *FileName)
|
|||
jmp_buf ExitBuf;
|
||||
|
||||
/* exit the program */
|
||||
void PlatformExit()
|
||||
void PlatformExit(int RetVal)
|
||||
{
|
||||
ExitValue = RetVal;
|
||||
longjmp(ExitBuf, 1);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue