another try at improving ^c with readline

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@160 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc 2001-09-21 14:22:32 +00:00
parent 9236415849
commit f928b9452b
3 changed files with 29 additions and 29 deletions

View File

@ -88,8 +88,6 @@ int in_getc = FALSE;
FILE *rl_instream, *rl_outstream;
#endif
sigjmp_buf readline_jmpbuf;
#endif
typedef struct
@ -821,7 +819,7 @@ extern void add_history (const char *);
static char *ttyptr = NULL;
static char *_line = (char *) NULL;
char *_line = (char *) NULL;
static int cur_out_sno = 2;
@ -881,17 +879,6 @@ ReadlineGetc(int sno)
while (ttyptr == NULL) {
in_getc = TRUE;
/* Do it the gnu way */
if (sigsetjmp(readline_jmpbuf, TRUE)) {
if (PrologMode & InterruptMode) {
PrologMode &= ~InterruptMode;
ProcessSIGINT();
if (PrologMode & AbortMode) {
PrologMode &= ~AbortMode;
Abort("");
}
}
}
/* Only sends a newline if we are at the start of a line */
if (_line != NULL && _line != (char *) EOF)
free (_line);
@ -920,6 +907,16 @@ ReadlineGetc(int sno)
_line = readline (NULL);
}
}
/* Do it the gnu way */
if (PrologMode & InterruptMode) {
PrologMode &= ~InterruptMode;
ProcessSIGINT();
if (PrologMode & AbortMode) {
PrologMode &= ~AbortMode;
Abort("");
}
continue;
}
newline=FALSE;
strncpy (Prompt, RepAtom (*AtPrompt)->StrOfAE, MAX_PROMPT);
in_getc = FALSE;

View File

@ -1055,10 +1055,6 @@ void (*handler)(int);
#endif
#if HAVE_LIBREADLINE
static char *_line = NULL;
#endif
static int
InteractSIGINT(char ch) {
switch (ch) {
@ -1172,16 +1168,21 @@ ProcessSIGINT(void)
do {
#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) {
ch = EOF;
continue;
if (_line != (char *) NULL) {
ch = _line[0];
free(_line);
_line = NULL;
} else {
_line = readline ("Action (h for help): ");
if (_line == (char *)NULL || _line == (char *)EOF) {
ch = EOF;
continue;
} else {
ch = _line[0];
free(_line);
_line = NULL;
}
}
ch = _line[0];
free(_line);
_line = NULL;
#else
/* ask for a new line */
fprintf(stderr, "Action (h for help): ");
@ -1215,7 +1216,8 @@ HandleSIGINT (int sig)
PrologMode |= InterruptMode;
#if HAVE_LIBREADLINE
if (in_getc) {
siglongjmp(readline_jmpbuf, 0);
fprintf(stderr, "Action (h for help): ");
rl_set_prompt("Action (h for help): ");
}
#endif
return;

View File

@ -319,5 +319,6 @@ extern jmp_buf IOBotch;
extern int in_getc;
#ifdef HAVE_LIBREADLINE
extern sigjmp_buf readline_jmpbuf;
extern char *_line;
#endif