Remove function cp_ccon() and related code. The function modifies
the terminal driver's treatment of the control-D (EOF) and escape keys on Unix-like OSs. But escape has no special meaning, and treating control-D as a line terminator was probably to prevent unexpected session exit when connected through a modem without error-correction. Removing the function allows "ngspice netlist &" to work correctly. The function was called during initialisation, which caused an endless loop of job-control stops when ngspice was started as a background process.
This commit is contained in:
parent
4c61e0ba26
commit
543a8bb62d
|
|
@ -29,8 +29,6 @@ com_shell(wordlist *wl)
|
|||
shell = SHELL;
|
||||
}
|
||||
|
||||
cp_ccon(FALSE);
|
||||
|
||||
#ifdef HAVE_VFORK_H
|
||||
/* XXX Needs to switch process groups. Also, worry about suspend */
|
||||
/* Only bother for efficiency */
|
||||
|
|
|
|||
|
|
@ -69,13 +69,7 @@ ft_cpinit(void)
|
|||
"vr(x)", "re(v(x))",
|
||||
"vr(x,y)", "re(v(x) - v(y))"
|
||||
};
|
||||
#ifndef SHARED_MODULE
|
||||
/* if TIOCSTI is defined (not available in MS Windows:
|
||||
Make escape the break character.
|
||||
So the user can type ahead...
|
||||
fcn defined in complete.c. */
|
||||
cp_ccon(TRUE);
|
||||
#endif
|
||||
|
||||
/* Initialize io, cp_chars[], variable "history" in init.c. */
|
||||
cp_init();
|
||||
|
||||
|
|
|
|||
|
|
@ -65,8 +65,6 @@ ft_sperror(int code, char *mess)
|
|||
void
|
||||
fatal(void)
|
||||
{
|
||||
cp_ccon(FALSE);
|
||||
|
||||
#if defined(FTEDEBUG) && defined(SIGQUIT)
|
||||
(void) signal(SIGQUIT, SIG_DFL);
|
||||
(void) kill(getpid(), SIGQUIT);
|
||||
|
|
|
|||
|
|
@ -58,10 +58,8 @@ com_quit(wordlist *wl)
|
|||
(wl && wl->wl_word && cieq(wl->wl_word, "noask")) ||
|
||||
!cp_getvar("askquit", CP_BOOL, NULL, 0);
|
||||
|
||||
/* update screen and reset terminal */
|
||||
/* Update screen. */
|
||||
gr_clean();
|
||||
cp_ccon(FALSE);
|
||||
|
||||
|
||||
/* Make sure the guy really wants to quit. */
|
||||
if (!ft_nutmeg)
|
||||
|
|
|
|||
|
|
@ -40,22 +40,6 @@ Modified: 1999 Paolo Nenzi
|
|||
#include <sys/ioctl.h>
|
||||
#endif
|
||||
|
||||
/* Be sure the ioctls get included in the following */
|
||||
#ifdef HAVE_SGTTY_H
|
||||
#include <sgtty.h>
|
||||
#else
|
||||
#ifdef HAVE_TERMIO_H
|
||||
#include <termio.h>
|
||||
#else
|
||||
#ifdef HAVE_TERMIOS_H
|
||||
#include <termios.h>
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#define CNTRL_D '\004'
|
||||
#define ESCAPE '\033'
|
||||
#define NCLASSES 32
|
||||
|
||||
bool cp_nocc; /* Don't do command completion. */
|
||||
|
|
@ -349,96 +333,6 @@ cp_cctowl(struct ccom *stuff)
|
|||
}
|
||||
|
||||
|
||||
/* Turn on and off the escape break character and cooked mode. */
|
||||
|
||||
void
|
||||
cp_ccon(bool on)
|
||||
{
|
||||
#ifdef TIOCSTI
|
||||
#ifdef HAVE_SGTTY_H
|
||||
static bool ison = FALSE;
|
||||
struct tchars tbuf;
|
||||
struct sgttyb sbuf;
|
||||
|
||||
if (cp_nocc || !cp_interactive || (ison == on))
|
||||
return;
|
||||
ison = on;
|
||||
|
||||
/* Set the terminal up -- make escape the break character, and
|
||||
* make sure we aren't in raw or cbreak mode. Hope the (void)
|
||||
* ioctl's won't fail.
|
||||
*/
|
||||
(void) ioctl(fileno(cp_in), TIOCGETC, &tbuf);
|
||||
if (on)
|
||||
tbuf.t_brkc = ESCAPE;
|
||||
else
|
||||
tbuf.t_brkc = '\0';
|
||||
(void) ioctl(fileno(cp_in), TIOCSETC, &tbuf);
|
||||
|
||||
(void) ioctl(fileno(cp_in), TIOCGETP, &sbuf);
|
||||
sbuf.sg_flags &= ~(RAW|CBREAK);
|
||||
(void) ioctl(fileno(cp_in), TIOCSETP, &sbuf);
|
||||
#else
|
||||
|
||||
# ifdef HAVE_TERMIO_H
|
||||
|
||||
# define TERM_GET TCGETA
|
||||
# define TERM_SET TCSETA
|
||||
static struct termio sbuf;
|
||||
static struct termio OS_Buf;
|
||||
|
||||
# else
|
||||
# ifdef HAVE_TERMIOS_H
|
||||
|
||||
|
||||
# define TERM_GET TCGETS
|
||||
# define TERM_SET TCSETS
|
||||
static struct termios sbuf;
|
||||
static struct termios OS_Buf;
|
||||
|
||||
# endif
|
||||
# endif
|
||||
|
||||
#ifdef TERM_GET
|
||||
static bool ison = FALSE;
|
||||
|
||||
if (cp_nocc || !cp_interactive || (ison == on))
|
||||
return;
|
||||
ison = on;
|
||||
|
||||
if (ison == TRUE) {
|
||||
#if HAVE_TCGETATTR
|
||||
tcgetattr(fileno(cp_in), &OS_Buf);
|
||||
#else
|
||||
(void) ioctl(fileno(cp_in), TERM_GET, &OS_Buf);
|
||||
#endif
|
||||
sbuf = OS_Buf;
|
||||
sbuf.c_cc[VEOF] = '\0';
|
||||
sbuf.c_cc[VEOL] = ESCAPE;
|
||||
sbuf.c_cc[VEOL2] = CNTRL_D;
|
||||
#if HAVE_TCSETATTR
|
||||
tcsetattr(fileno(cp_in), TCSANOW, &sbuf);
|
||||
#else
|
||||
(void) ioctl(fileno(cp_in), TERM_SET, &sbuf);
|
||||
#endif
|
||||
} else {
|
||||
#ifdef HAVE_TCSETATTR
|
||||
tcsetattr(fileno(cp_in), TCSANOW, &OS_Buf);
|
||||
#else
|
||||
(void) ioctl(fileno(cp_in), TERM_SET, &OS_Buf);
|
||||
#endif
|
||||
}
|
||||
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#else
|
||||
NG_IGNORE(on);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* The following routines deal with the command and keyword databases.
|
||||
* Say whether a given word exists in the command database.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -13,18 +13,6 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
|
|||
#include <signal.h>
|
||||
#include "cshpar.h"
|
||||
|
||||
#ifdef HAVE_SGTTY_H
|
||||
#include <sgtty.h>
|
||||
#else
|
||||
#ifdef HAVE_TERMIO_H
|
||||
#include <termio.h>
|
||||
#else
|
||||
#ifdef HAVE_TERMIOS_H
|
||||
#include <termios.h>
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -22,26 +22,6 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
|
|||
#include <pwd.h>
|
||||
#endif
|
||||
|
||||
/* MW. Linux has TIOCSTI, so we include all headers here */
|
||||
#if !defined(__MINGW32__) && !defined(_MSC_VER)
|
||||
#include <sys/ioctl.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SGTTY_H
|
||||
#include <sys/types.h>
|
||||
#include <sgtty.h>
|
||||
#else
|
||||
#ifdef HAVE_TERMIO_H
|
||||
#include <sys/types.h>
|
||||
#include <termio.h>
|
||||
#else
|
||||
#ifdef HAVE_TERMIOS_H
|
||||
#include <sys/types.h>
|
||||
#include <termios.h>
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "ngspice/fteinput.h"
|
||||
#include "lexical.h"
|
||||
|
||||
|
|
@ -73,12 +53,8 @@ bool cp_bqflag = FALSE;
|
|||
char *cp_promptstring = NULL;
|
||||
char *cp_altprompt = NULL;
|
||||
|
||||
static int numeofs = 0;
|
||||
|
||||
|
||||
#define ESCAPE '\033'
|
||||
|
||||
|
||||
/* Return a list of words, with backslash quoting and '' quoting done.
|
||||
* Strings enclosed in "" or `` are made single words and returned,
|
||||
* but with the "" or `` still present. For the \ and '' cases, the
|
||||
|
|
@ -155,7 +131,6 @@ wordlist *
|
|||
cp_lexer(char *string)
|
||||
{
|
||||
int c, d;
|
||||
int i;
|
||||
wordlist *wlist, *wlist_tail;
|
||||
struct cp_lexer_buf buf, linebuf;
|
||||
int paren;
|
||||
|
|
@ -165,7 +140,6 @@ cp_lexer(char *string)
|
|||
|
||||
/* prompt for string if none is passed */
|
||||
if (!string && cp_interactive) {
|
||||
cp_ccon(TRUE);
|
||||
prompt();
|
||||
}
|
||||
|
||||
|
|
@ -194,11 +168,8 @@ nloop:
|
|||
if (string && (c == ESCAPE))
|
||||
continue;
|
||||
|
||||
if ((c != EOF) && (c != ESCAPE))
|
||||
push(&linebuf, c);
|
||||
|
||||
if (c != EOF)
|
||||
numeofs = 0;
|
||||
push(&linebuf, c);
|
||||
|
||||
/* if '\' or '^', add following character to linebuf */
|
||||
if ((c == '\\' && DIR_TERM != '\\') || (c == '\026') /* ^V */ ) {
|
||||
|
|
@ -293,70 +264,6 @@ nloop:
|
|||
push(&linebuf, d);
|
||||
break;
|
||||
|
||||
case '\004':
|
||||
case EOF:
|
||||
/* upon command completion, not used actually */
|
||||
if (cp_interactive && !cp_nocc && !string) {
|
||||
|
||||
if (linebuf.i == 0) {
|
||||
if (cp_ignoreeof && (numeofs++ < 23)) {
|
||||
fputs("Use \"quit\" to quit.\n", stdout);
|
||||
} else {
|
||||
fputs("quit\n", stdout);
|
||||
cp_doquit();
|
||||
}
|
||||
append(NULL);
|
||||
goto done;
|
||||
}
|
||||
|
||||
push(&buf, '\0');
|
||||
push(&linebuf, '\0');
|
||||
|
||||
// cp_ccom doesn't mess wlist, read only access to wlist->wl_word
|
||||
cp_ccom(wlist, buf.s, FALSE);
|
||||
(void) fputc('\r', cp_out);
|
||||
prompt();
|
||||
for (i = 0; linebuf.s[i]; i++)
|
||||
#ifdef TIOCSTI
|
||||
(void) ioctl(fileno(cp_out), TIOCSTI, linebuf.s + i);
|
||||
#else
|
||||
fputc(linebuf.s[i], cp_out); /* But you can't edit */
|
||||
#endif
|
||||
goto nloop;
|
||||
}
|
||||
|
||||
/* EOF during a source */
|
||||
if (cp_interactive) {
|
||||
fputs("quit\n", stdout);
|
||||
cp_doquit();
|
||||
append(NULL);
|
||||
goto done;
|
||||
}
|
||||
|
||||
wl_free(wlist);
|
||||
tfree(buf.s);
|
||||
tfree(linebuf.s);
|
||||
return NULL;
|
||||
|
||||
case ESCAPE:
|
||||
/* upon command completion, not used actually */
|
||||
if (cp_interactive && !cp_nocc) {
|
||||
push(&buf, '\0');
|
||||
push(&linebuf, '\0');
|
||||
fputs("\b\b \b\b\r", cp_out);
|
||||
prompt();
|
||||
for (i = 0; linebuf.s[i]; i++)
|
||||
#ifdef TIOCSTI
|
||||
(void) ioctl(fileno(cp_out), TIOCSTI, linebuf.s + i);
|
||||
#else
|
||||
fputc(linebuf.s[i], cp_out); /* But you can't edit */
|
||||
#endif
|
||||
// cp_ccom doesn't mess wlist, read only access to wlist->wl_word
|
||||
cp_ccom(wlist, buf.s, TRUE);
|
||||
goto nloop;
|
||||
}
|
||||
goto ldefault;
|
||||
|
||||
case ',':
|
||||
if ((paren < 1) && (buf.i > 0)) {
|
||||
newword;
|
||||
|
|
|
|||
|
|
@ -91,7 +91,6 @@ ft_sigintr(void)
|
|||
|
||||
if (interrupt_counter >= 3) {
|
||||
fprintf(cp_err, "\nKilling, since %d interrupts have been requested\n\n", interrupt_counter);
|
||||
cp_ccon(FALSE);
|
||||
controlled_exit(1);
|
||||
}
|
||||
|
||||
|
|
@ -149,7 +148,6 @@ void
|
|||
sigstop(void)
|
||||
{
|
||||
gr_clean();
|
||||
cp_ccon(FALSE);
|
||||
if (!cp_background) {
|
||||
(void) signal(SIGTSTP, SIG_DFL);
|
||||
(void) kill(getpid(), SIGTSTP); /* This should stop us */
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
|
|||
bool cp_noglob = FALSE;
|
||||
bool cp_nonomatch = FALSE;
|
||||
bool cp_noclobber = FALSE;
|
||||
bool cp_ignoreeof = FALSE;
|
||||
bool cp_echo = FALSE; /* CDHW */
|
||||
|
||||
struct variable *variables = NULL;
|
||||
|
|
@ -245,7 +244,7 @@ void cp_vset(const char *varname, enum cp_types type,
|
|||
|
||||
|
||||
/* Process special variables: noglob, nonomatch, history,
|
||||
* noclobber, echo, prompt, ignoreeof, cpdebug, and no_histsubst
|
||||
* noclobber, echo, prompt, cpdebug, and no_histsubst
|
||||
* by setting the values of associated option variables.
|
||||
*
|
||||
* Parmeters
|
||||
|
|
@ -260,8 +259,7 @@ static void update_option_variables(const char *sz_var_name,
|
|||
['h' - 'a'] = 2, /* history */
|
||||
['e' - 'a'] = 3, /* echo */
|
||||
['p' - 'a'] = 4, /* prompt, program */
|
||||
['i' - 'a'] = 5, /* ignoreeof */
|
||||
['c' - 'a'] = 6 /* cpdebug */
|
||||
['c' - 'a'] = 5 /* cpdebug */
|
||||
};
|
||||
|
||||
unsigned int index0 = (unsigned int) sz_var_name[0] - 'a';
|
||||
|
|
@ -365,11 +363,6 @@ static void update_option_variables(const char *sz_var_name,
|
|||
}
|
||||
return; /* not of interest */
|
||||
case 5:
|
||||
if (eq(sz_var_name + 1, "gnoreeof")) { /* ignoreeof */
|
||||
cp_ignoreeof = f_set;
|
||||
}
|
||||
return;
|
||||
case 6:
|
||||
if (eq(sz_var_name + 1, "pdebug")) { /* cpdebug */
|
||||
cp_debug = f_set;
|
||||
#ifndef CPDEBUG
|
||||
|
|
|
|||
|
|
@ -40,7 +40,6 @@ extern struct ccom *cp_kwswitch(int kw_class, struct ccom *tree);
|
|||
extern void cp_addcomm(char *word, long int bits0, long int bits1, long int bits2, long int bits3);
|
||||
extern void cp_addkword(int kw_class, char *word);
|
||||
extern void cp_ccom(wordlist *wlist, char *buf, bool esc);
|
||||
extern void cp_ccon(bool on);
|
||||
extern void cp_ccrestart(bool kwords);
|
||||
extern void cp_remcomm(char *word);
|
||||
extern void cp_remkword(int kw_class, const char *word);
|
||||
|
|
@ -152,7 +151,6 @@ enum cp_types {
|
|||
CP_LIST
|
||||
};
|
||||
|
||||
extern bool cp_ignoreeof;
|
||||
extern bool cp_noclobber;
|
||||
extern bool cp_noglob;
|
||||
extern bool cp_nonomatch;
|
||||
|
|
|
|||
|
|
@ -60,18 +60,6 @@
|
|||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_TERMIOS_H
|
||||
#include <termios.h>
|
||||
#else
|
||||
# ifdef HAVE_SGTTY_H
|
||||
# include <sgtty.h>
|
||||
# else
|
||||
# ifdef HAVE_TERMIO_H
|
||||
# include <termio.h>
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PWD_H
|
||||
#include <pwd.h>
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -495,7 +495,6 @@ void out_init(void) { }
|
|||
void cp_doquit(void) { exit(0); }
|
||||
struct variable *cp_usrvars(void) { return NULL; }
|
||||
int cp_evloop(char *s) { NG_IGNORE(s); return (0); }
|
||||
void cp_ccon(bool o) { NG_IGNORE(o); }
|
||||
char*if_errstring(int c) { NG_IGNORE(c); return strdup("error"); }
|
||||
void out_printf(char *fmt, ...) { NG_IGNORE(fmt); }
|
||||
void out_send(char *string) { NG_IGNORE(string); }
|
||||
|
|
|
|||
Loading…
Reference in New Issue