From cb247a15fb3f03737380ec65d9a5afda0249f8e1 Mon Sep 17 00:00:00 2001 From: sjborley Date: Fri, 6 May 2005 23:43:46 +0000 Subject: [PATCH] Added support for the BSD licensed editline library (libedit). --- src/frontend/com_history.c | 14 ++++++++------ src/frontend/control.c | 4 ++-- src/frontend/misccoms.c | 23 ++++++++++++----------- src/frontend/plotting/x11.c | 7 +++---- src/frontend/signal_handler.c | 15 ++++++++++----- 5 files changed, 35 insertions(+), 28 deletions(-) diff --git a/src/frontend/com_history.c b/src/frontend/com_history.c index e337fa4fc..7d82ecbcd 100644 --- a/src/frontend/com_history.c +++ b/src/frontend/com_history.c @@ -11,13 +11,16 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group #include "com_history.h" #ifdef HAVE_GNUREADLINE - /* Added GNU Readline Support -- Andrew Veliath */ #include #include - #endif /* HAVE_GNUREADLINE */ +#ifdef HAVE_BSDEDITLINE +/* SJB added edit line support 2005-05-05 */ +#include +#endif /* HAVE_BSDEDITLINE */ + /* static declarations */ static wordlist * dohsubst(char *string); static wordlist * dohmod(char **string, wordlist *wl); @@ -353,7 +356,7 @@ cp_addhistent(int event, wordlist *wlist) cp_lastone->hi_next = NULL; cp_lastone->hi_event = event; cp_lastone->hi_wlist = wl_copy(wlist); -#ifndef HAVE_GNUREADLINE +#if !defined(HAVE_GNUREADLINE) && !defined(HAVE_BSDEDITLINE) freehist(histlength - cp_maxhistlength); histlength++; #endif @@ -494,7 +497,7 @@ com_history(wordlist *wl) rev = TRUE; } -#ifdef HAVE_GNUREADLINE +#if defined(HAVE_GNUREADLINE) || defined(HAVE_BSDEDITLINE) /* Added GNU Readline Support -- Andrew Veliath */ { HIST_ENTRY *he; @@ -523,8 +526,7 @@ com_history(wordlist *wl) cp_hprint(cp_event - 1, cp_event - histlength, rev); else cp_hprint(cp_event - 1, cp_event - 1 - atoi(wl->wl_word), rev); -#endif /* ifelse HAVE_GNUREADLINE */ +#endif /* defined(HAVE_GNUREADLINE) || defined(HAVE_BSDEDITLINE) */ return; } - diff --git a/src/frontend/control.c b/src/frontend/control.c index 073693045..1bd801459 100644 --- a/src/frontend/control.c +++ b/src/frontend/control.c @@ -589,10 +589,10 @@ getcommand(char *string) if (cp_debug) fprintf(cp_err, "calling getcommand %s\n", string ? string : ""); -#ifndef HAVE_GNUREADLINE +#if !defined(HAVE_GNUREADLINE) && !defined(HAVE_BSDEDITLINE) /* set cp_altprompt for use by the lexer - see parser/lexical.c */ cp_altprompt = get_alt_prompt(); -#endif +#endif /* !defined(HAVE_GNUREADLINE) && !defined(HAVE_BSDEDITLINE) */ cp_cwait = TRUE; wlist = cp_parse(string); diff --git a/src/frontend/misccoms.c b/src/frontend/misccoms.c index 039e737e5..7137a39ed 100644 --- a/src/frontend/misccoms.c +++ b/src/frontend/misccoms.c @@ -10,16 +10,19 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group #include "ftehelp.h" #include "hlpdefs.h" #include "misccoms.h" - #include "circuits.h" #include "hcomp.h" #include "variable.h" - #ifdef HAVE_GNUREADLINE #include #include -#endif +#endif /* HAVE_GNUREADLINE */ + +#ifdef HAVE_BSDEDITLINE +/* SJB added edit line support 2005-05-05 */ +#include +#endif /* HAVE_BSDEDITLINE */ static void byemesg(void); @@ -117,8 +120,7 @@ com_bug(wordlist *wl) return; } -#else - +#else /* SYSTEM_MAIL */ void com_bug(wordlist *wl) @@ -127,7 +129,7 @@ com_bug(wordlist *wl) return; } -#endif +#endif /* SYSTEM_MAIL */ void com_version(wordlist *wl) @@ -230,17 +232,16 @@ static void byemesg(void) { -#ifdef HAVE_GNUREADLINE - extern char gnu_history_file[]; +#if defined(HAVE_GNUREADLINE) || defined(HAVE_BSDEDITLINE) + extern char history_file[]; /* write out command history only when saying goodbye. */ if (cp_interactive && (cp_maxhistlength > 0)) { stifle_history(cp_maxhistlength); - write_history(gnu_history_file); + write_history(history_file); } -#endif /* HAVE_GNUREADLINE */ +#endif /* defined(HAVE_GNUREADLINE) || defined(HAVE_BSDEDITLINE) */ printf("%s-%s done\n", ft_sim->simulator, ft_sim->version); return; } - diff --git a/src/frontend/plotting/x11.c b/src/frontend/plotting/x11.c index 76e5b11e6..0a4c97a3a 100644 --- a/src/frontend/plotting/x11.c +++ b/src/frontend/plotting/x11.c @@ -786,8 +786,8 @@ zoomin(GRAPH *graph) graph->commandline, fx0, fx1, fy0, fy1); } -/* don't use the following if using GNU Readline - AV */ -#ifndef HAVE_GNUREADLINE +/* don't use the following if using GNU Readline or BSD EditLine */ +#if !defined(HAVE_GNUREADLINE) && !defined(HAVE_BSDEDITLINE) { wordlist *wl; int dummy; @@ -799,8 +799,7 @@ zoomin(GRAPH *graph) (void) cp_addhistent(cp_event++, wl); } } - -#endif /* HAVE_GNUREADLINE */ +#endif /* !defined(HAVE_GNUREADLINE) && !defined(HAVE_BSDEDITLINE) */ (void) cp_evloop(buf); diff --git a/src/frontend/signal_handler.c b/src/frontend/signal_handler.c index adaac68ce..7197f131b 100644 --- a/src/frontend/signal_handler.c +++ b/src/frontend/signal_handler.c @@ -7,7 +7,6 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group * The signal routines for spice 3 and nutmeg. */ - #include "ngspice.h" #include "ifsim.h" #include "iferrmsg.h" @@ -23,9 +22,13 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group /* from spice3f4 patch to ng-spice. jmr */ #include #include -#include "fteinput.h" #endif +#ifdef HAVE_BSDEDITLINE +/* SJB added edit line support 2005-05-05 */ +#include +#endif /* HAVE_BSDEDITLINE */ + extern sigjmp_buf jbuf; /* The (void) signal handlers... SIGINT is the only one that gets reset (by @@ -59,13 +62,15 @@ ft_sigintr(void) return; /* just return without aborting simulation if ft_setflag = TRUE */ } -#ifdef HAVE_GNUREADLINE + /* sjb - what to do for editline??? + The following are not supported in editline */ +#if defined(HAVE_GNUREADLINE) /* Clean up readline after catching signals */ - /* One or all of these might be supurfluous */ + /* One or all of these might be superfluous */ (void) rl_free_line_state(); (void) rl_cleanup_after_signal(); (void) rl_reset_after_signal(); -#endif +#endif /* defined(HAVE_GNUREADLINE) || defined(HAVE_BSDEDITLINE) */ /* To restore screen after an interrupt to a plot for instance */ cp_interactive = TRUE;