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
+11
View File
@@ -75,6 +75,14 @@ repl(pic_state *pic)
int char_index;
#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);
while (1) {
@@ -145,6 +153,9 @@ repl(pic_state *pic)
eof:
puts("");
exit_status = 0;
#if PIC_ENABLE_READLINE
write_history(histfile);
#endif
return;
overflow: