From cb288532a97d746a8b06d886040772f7d6513be5 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Sun, 6 Apr 2014 01:40:04 +0900 Subject: [PATCH] support REPL readline history save and load --- tools/main.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tools/main.c b/tools/main.c index 2ef1a954..3b82de4d 100644 --- a/tools/main.c +++ b/tools/main.c @@ -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: