diff --git a/library/changes b/library/changes index 9c63414..6d14d97 100644 --- a/library/changes +++ b/library/changes @@ -1,3 +1,10 @@ +- When the main() function returns directly or indirectly by way of + calling exit(), the IoErr() value set at this time will now be + preserved until the program really returns control to the shell. + This turned out to be easier to implement than I had originally + thought, thanks to the fact that the atexit() functions are all + invoked straight after the exit() call. + - strtoimax(), strtoumax(), strtod(), strtof(), strtol(), strtoll(), strtoul() and strtoull() now count how many digits were converted. If that number is zero, then the conversion is considered to have diff --git a/library/stdlib_main.c b/library/stdlib_main.c index 747396e..5a76f9e 100644 --- a/library/stdlib_main.c +++ b/library/stdlib_main.c @@ -1,5 +1,5 @@ /* - * $Id: stdlib_main.c,v 1.26 2005-09-04 07:38:51 obarthel Exp $ + * $Id: stdlib_main.c,v 1.27 2005-09-28 10:28:38 obarthel Exp $ * * :ts=4 * @@ -73,6 +73,8 @@ BOOL NOCOMMON __stack_overflow; STATIC int call_main(void) { + volatile LONG saved_io_err; + ENTER(); /* This plants the return buffer for _exit(). */ @@ -128,6 +130,9 @@ call_main(void) out: + /* Save the current IoErr() value in case it is needed later. */ + saved_io_err = IoErr(); + /* Switch off function name printing, if it was enabled. */ __hide_profile_names(); @@ -171,6 +176,9 @@ call_main(void) SHOWMSG("done."); + /* Restore the IoErr() value before we return. */ + SetIoErr(saved_io_err); + RETURN(__exit_value); return(__exit_value); }