diff --git a/femtolisp/flisp.c b/femtolisp/flisp.c index 667225f..7390dea 100644 --- a/femtolisp/flisp.c +++ b/femtolisp/flisp.c @@ -2258,7 +2258,7 @@ static value_t argv_list(int argc, char *argv[]) extern value_t fl_file(value_t *args, uint32_t nargs); -int main(int argc, char *argv[]) +int fl_startup() { value_t e; int saveSP; @@ -2303,10 +2303,6 @@ int main(int argc, char *argv[]) } ios_close(value2c(ios_t*,Stack[SP-1])); POPN(1); - - PUSH(symbol_value(symbol("__start"))); - PUSH(argv_list(argc, argv)); - (void)_applyn(1); } FL_CATCH { ios_puts("fatal error during bootstrap:\n", ios_stderr); @@ -2314,6 +2310,24 @@ int main(int argc, char *argv[]) ios_putc('\n', ios_stderr); return 1; } - + return 0; +} + +int main(int argc, char *argv[]) +{ + if (fl_startup()) + return 1; + + FL_TRY { + PUSH(symbol_value(symbol("__start"))); + PUSH(argv_list(argc, argv)); + (void)_applyn(1); + } + FL_CATCH { + ios_puts("fatal error:\n", ios_stderr); + fl_print(ios_stderr, lasterror); + ios_putc('\n', ios_stderr); + return 1; + } return 0; } diff --git a/femtolisp/flisp.h b/femtolisp/flisp.h index 2bf2ef0..0ee03a2 100644 --- a/femtolisp/flisp.h +++ b/femtolisp/flisp.h @@ -322,4 +322,6 @@ value_t fl_hash(value_t *args, u_int32_t nargs); value_t cvalue_byte(value_t *args, uint32_t nargs); value_t cvalue_wchar(value_t *args, uint32_t nargs); +int fl_startup(); + #endif