From 314d37171eeeaf59a5b31a334f60c81fe2e6745c Mon Sep 17 00:00:00 2001 From: delphij Date: Thu, 4 Feb 2010 18:43:05 +0000 Subject: Use libedit when interacting with tty, which provided history functionality, etc. as did by GNU bc. This also fixes an issue where BSDL bc can not handle very long line. Reported by: imp Reviewed by: imp --- usr.bin/bc/bc.y | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'usr.bin/bc/bc.y') diff --git a/usr.bin/bc/bc.y b/usr.bin/bc/bc.y index b00d140..b00d5ac 100644 --- a/usr.bin/bc/bc.y +++ b/usr.bin/bc/bc.y @@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -1106,6 +1107,13 @@ sigchld(int signo) } } +static const char * +dummy_prompt(void) +{ + + return (""); +} + int main(int argc, char *argv[]) { @@ -1173,6 +1181,16 @@ main(int argc, char *argv[]) dup(p[1]); close(p[0]); close(p[1]); + if (interactive) { + el = el_init("bc", stdin, stderr, stderr); + hist = history_init(); + history(hist, &he, H_SETSIZE, 100); + el_set(el, EL_HIST, history, hist); + el_set(el, EL_EDITOR, "emacs"); + el_set(el, EL_SIGNAL, 1); + el_set(el, EL_PROMPT, dummy_prompt); + el_source(el, NULL); + } } else { close(STDIN_FILENO); dup(p[0]); -- cgit v1.1