support REPL readline history save and load

This commit is contained in:
Yuichi Nishiwaki 2014-04-06 01:40:04 +09:00
parent 288ee21b1b
commit cb288532a9
1 changed files with 11 additions and 0 deletions

View File

@ -75,6 +75,14 @@ repl(pic_state *pic)
int char_index; int char_index;
#endif #endif
#if PIC_ENABLE_READLINE
using_history();
char histfile[snprintf(NULL, 0, "%s/.picrin_history", getenv("HOME")) + 1];
sprintf(histfile, "%s/.picrin_history", getenv("HOME"));
read_history(histfile);
#endif
ai = pic_gc_arena_preserve(pic); ai = pic_gc_arena_preserve(pic);
while (1) { while (1) {
@ -145,6 +153,9 @@ repl(pic_state *pic)
eof: eof:
puts(""); puts("");
exit_status = 0; exit_status = 0;
#if PIC_ENABLE_READLINE
write_history(histfile);
#endif
return; return;
overflow: overflow: