add pic_blk_exit

This commit is contained in:
Yuichi Nishiwaki 2014-03-10 01:36:29 +09:00
parent 851187f7bb
commit 68ea22f6eb
2 changed files with 14 additions and 7 deletions

View File

@ -52,6 +52,17 @@ struct pic_cont {
} \
} while (0)
#define PIC_BLK_EXIT(pic) do { \
pic_block *_a; \
while (pic->blk) { \
if (pic->blk->out) \
pic_apply_argv(pic, pic->blk->out, 0); \
_a = pic->blk->prev; \
PIC_BLK_DECREF(pic, pic->blk); \
pic->blk = _a; \
} \
} while (0)
pic_value pic_values(pic_state *, size_t, ...);
pic_value pic_values_by_array(pic_state *, size_t, pic_value *);
pic_value pic_values_by_list(pic_state *, pic_value);

View File

@ -7,6 +7,7 @@
#include "picrin.h"
#include "picrin/string.h"
#include "picrin/pair.h"
#include "picrin/cont.h"
static pic_value
pic_system_cmdline(pic_state *pic)
@ -31,7 +32,6 @@ pic_system_exit(pic_state *pic)
{
pic_value v;
int argc, status = EXIT_SUCCESS;
pic_block *blk;
argc = pic_get_args(pic, "|o", &v);
if (argc == 1) {
@ -47,11 +47,7 @@ pic_system_exit(pic_state *pic)
}
}
blk = pic->blk;
while (blk) {
pic_apply_argv(pic, blk->out, 0);
blk = blk->prev;
}
PIC_BLK_EXIT(pic);
exit(status);
}