factoring out startup routine for embedded use

This commit is contained in:
JeffBezanson 2010-04-29 18:39:17 +00:00
parent eec95c17b8
commit 1dcc71ec82
2 changed files with 22 additions and 6 deletions

View File

@ -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;
}

View File

@ -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