summaryrefslogtreecommitdiffstats
path: root/usr.bin/bc/bc.y
diff options
context:
space:
mode:
authordelphij <delphij@FreeBSD.org>2010-02-04 18:43:05 +0000
committerdelphij <delphij@FreeBSD.org>2010-02-04 18:43:05 +0000
commit314d37171eeeaf59a5b31a334f60c81fe2e6745c (patch)
tree922142fb6348e5d6c63fc34056e3e1e85129a988 /usr.bin/bc/bc.y
parent4650055e248bb24fa28802c303a9d9af06e02256 (diff)
downloadFreeBSD-src-314d37171eeeaf59a5b31a334f60c81fe2e6745c.zip
FreeBSD-src-314d37171eeeaf59a5b31a334f60c81fe2e6745c.tar.gz
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
Diffstat (limited to 'usr.bin/bc/bc.y')
-rw-r--r--usr.bin/bc/bc.y18
1 files changed, 18 insertions, 0 deletions
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 <err.h>
#include <errno.h>
#include <getopt.h>
+#include <histedit.h>
#include <limits.h>
#include <search.h>
#include <signal.h>
@@ -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]);
OpenPOWER on IntegriCloud