diff --git a/C/iopreds.c b/C/iopreds.c index bf8430036..ffbd7a132 100644 --- a/C/iopreds.c +++ b/C/iopreds.c @@ -760,8 +760,6 @@ static char *ttyptr = NULL; static char *_line = (char *) NULL; -int in_readline = FALSE; - static int cur_out_sno = 2; #define READLINE_OUT_BUF_MAX 256 @@ -776,8 +774,7 @@ static int ReadlinePutc (int sno, int ch) { if (ReadlinePos != ReadlineBuf && - (sno != cur_out_sno || - ReadlinePos - ReadlineBuf == READLINE_OUT_BUF_MAX-1 || + (ReadlinePos - ReadlineBuf == READLINE_OUT_BUF_MAX-1 /* overflow */ || #if MAC || _MSC_VER ch == 10 || #endif @@ -824,7 +821,6 @@ ReadlineGetc(int sno) rl_instream = Stream[sno].u.file.file; rl_outstream = Stream[cur_out_sno].u.file.file; /* window of vulnerability opened */ - in_readline = TRUE; if (newline) { char *cptr = Prompt, ch; @@ -848,7 +844,6 @@ ReadlineGetc(int sno) } } newline=FALSE; - in_readline = FALSE; strncpy (Prompt, RepAtom (*AtPrompt)->StrOfAE, MAX_PROMPT); /* window of vulnerability closed */ if (PrologMode & AbortMode) { diff --git a/C/sysbits.c b/C/sysbits.c index 8bb4bb49d..10b985070 100644 --- a/C/sysbits.c +++ b/C/sysbits.c @@ -81,6 +81,9 @@ static char SccsId[] = "%W% %G%"; #include #endif #endif +#if HAVE_LIBREADLINE +#include +#endif STATIC_PROTO (void InitPageSize, (void)); STATIC_PROTO (void InitTime, (void)); @@ -1060,6 +1063,11 @@ void (*handler)(int); #endif + +#if HAVE_LIBREADLINE +static char *_line = NULL; +#endif + void ProcessSIGINT(void) { @@ -1070,12 +1078,18 @@ ProcessSIGINT(void) int ch0; #endif +#if HAVE_LIBREADLINE + if (_line != (char *) NULL && _line != (char *) EOF) + free (_line); + _line = readline ("Action (h for help): "); + if (_line == (char *)NULL || _line == (char *)EOF) + continue; + ch = _line[0]; +#else YP_fprintf(YP_stderr, "\nAction (h for help): "); ch = YP_getchar ( ); -#if HAVE_LIBREADLINE - if (!in_readline) -#endif while ((YP_getchar()) != '\n'); +#endif switch (ch) { case 'a': @@ -1094,13 +1108,8 @@ ProcessSIGINT(void) #ifdef VAX VaxFixFrame (CritMode); #endif -#if HAVE_LIBREADLINE /* we cannot abort until we finish readline :-( */ - if (in_readline) { - /* readline must eat a newline, otherwise we will - have to wait before we do the Abort() */ - } else if (!(PrologMode & CritMode)) { -#endif + if (!(PrologMode & CritMode)) { #if defined(__MINGW32__) || _MSC_VER /* we can't do a direct abort, so ask the system to do it for us */ p_creep(); @@ -1201,10 +1210,6 @@ ProcessSIGINT(void) YP_fprintf(YP_stderr, " e for exit\n t for trace\n s for statistics\n"); break; } -#if HAVE_LIBREADLINE - /* we must do the reading now, because libreadline won't have a chance here */ - while ((YP_getchar()) != '\n'); -#endif } } diff --git a/H/yapio.h b/H/yapio.h index d3778e779..0692b7d41 100644 --- a/H/yapio.h +++ b/H/yapio.h @@ -283,10 +283,6 @@ void STD_PROTO(plwrite,(Term,int (*)(int, int),int)); /* grow.c */ int STD_PROTO(growstack_in_parser, (tr_fr_ptr *, TokEntry **, VarEntry **)); -#ifdef HAVE_LIBREADLINE -extern int in_readline; -#endif - #if HAVE_ERRNO_H #include #else