exit functions take an optional argument

This commit is contained in:
Yuichi Nishiwaki 2013-10-21 14:13:08 +09:00
parent 86177b7c4e
commit 72a6e90d83
1 changed files with 28 additions and 4 deletions

View File

@ -24,17 +24,41 @@ pic_system_cmdline(pic_state *pic)
static pic_value
pic_system_exit(pic_state *pic)
{
pic_get_args(pic, "");
pic_value v;
int argc, status = EXIT_SUCCESS;
exit(EXIT_SUCCESS);
argc = pic_get_args(pic, "|o", &v);
if (argc == 1) {
switch (pic_type(v)) {
case PIC_TT_FLOAT:
status = (int)pic_float(v);
break;
default:
break;
}
}
exit(status);
}
static pic_value
pic_system_emergency_exit(pic_state *pic)
{
pic_get_args(pic, "");
pic_value v;
int argc, status = EXIT_FAILURE;
_Exit(EXIT_FAILURE);
argc = pic_get_args(pic, "|o", &v);
if (argc == 1) {
switch (pic_type(v)) {
case PIC_TT_FLOAT:
status = (int)pic_float(v);
break;
default:
break;
}
}
_Exit(status);
}
static pic_value