catch read error in repl
This commit is contained in:
parent
3302721c65
commit
d168e7e1c8
12
tools/main.c
12
tools/main.c
|
@ -56,6 +56,7 @@ repl(pic_state *pic)
|
||||||
char *prompt;
|
char *prompt;
|
||||||
struct pic_proc *proc;
|
struct pic_proc *proc;
|
||||||
pic_value v, exprs;
|
pic_value v, exprs;
|
||||||
|
jmp_buf jmp;
|
||||||
int ai;
|
int ai;
|
||||||
|
|
||||||
#if PIC_ENABLE_READLINE
|
#if PIC_ENABLE_READLINE
|
||||||
|
@ -102,6 +103,17 @@ repl(pic_state *pic)
|
||||||
goto overflow;
|
goto overflow;
|
||||||
strcat(code, line);
|
strcat(code, line);
|
||||||
|
|
||||||
|
if (setjmp(jmp) == 0) {
|
||||||
|
pic->jmp = &jmp;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* error occured */
|
||||||
|
printf("%s\n", pic_errmsg(pic));
|
||||||
|
code[0] = '\0';
|
||||||
|
pic->err = NULL;
|
||||||
|
goto next;
|
||||||
|
}
|
||||||
|
|
||||||
/* read */
|
/* read */
|
||||||
exprs = pic_read_cstr(pic, code);
|
exprs = pic_read_cstr(pic, code);
|
||||||
if (pic_undef_p(exprs)) { /* wait for more input */
|
if (pic_undef_p(exprs)) { /* wait for more input */
|
||||||
|
|
Loading…
Reference in New Issue