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:
parent
9236415849
commit
f928b9452b
25
C/iopreds.c
25
C/iopreds.c
@ -88,8 +88,6 @@ int in_getc = FALSE;
|
|||||||
FILE *rl_instream, *rl_outstream;
|
FILE *rl_instream, *rl_outstream;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
sigjmp_buf readline_jmpbuf;
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
@ -821,7 +819,7 @@ extern void add_history (const char *);
|
|||||||
|
|
||||||
static char *ttyptr = NULL;
|
static char *ttyptr = NULL;
|
||||||
|
|
||||||
static char *_line = (char *) NULL;
|
char *_line = (char *) NULL;
|
||||||
|
|
||||||
static int cur_out_sno = 2;
|
static int cur_out_sno = 2;
|
||||||
|
|
||||||
@ -881,17 +879,6 @@ ReadlineGetc(int sno)
|
|||||||
|
|
||||||
while (ttyptr == NULL) {
|
while (ttyptr == NULL) {
|
||||||
in_getc = TRUE;
|
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 */
|
/* Only sends a newline if we are at the start of a line */
|
||||||
if (_line != NULL && _line != (char *) EOF)
|
if (_line != NULL && _line != (char *) EOF)
|
||||||
free (_line);
|
free (_line);
|
||||||
@ -920,6 +907,16 @@ ReadlineGetc(int sno)
|
|||||||
_line = readline (NULL);
|
_line = readline (NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* Do it the gnu way */
|
||||||
|
if (PrologMode & InterruptMode) {
|
||||||
|
PrologMode &= ~InterruptMode;
|
||||||
|
ProcessSIGINT();
|
||||||
|
if (PrologMode & AbortMode) {
|
||||||
|
PrologMode &= ~AbortMode;
|
||||||
|
Abort("");
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
newline=FALSE;
|
newline=FALSE;
|
||||||
strncpy (Prompt, RepAtom (*AtPrompt)->StrOfAE, MAX_PROMPT);
|
strncpy (Prompt, RepAtom (*AtPrompt)->StrOfAE, MAX_PROMPT);
|
||||||
in_getc = FALSE;
|
in_getc = FALSE;
|
||||||
|
30
C/sysbits.c
30
C/sysbits.c
@ -1055,10 +1055,6 @@ void (*handler)(int);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if HAVE_LIBREADLINE
|
|
||||||
static char *_line = NULL;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
InteractSIGINT(char ch) {
|
InteractSIGINT(char ch) {
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
@ -1172,16 +1168,21 @@ ProcessSIGINT(void)
|
|||||||
|
|
||||||
do {
|
do {
|
||||||
#if HAVE_LIBREADLINE
|
#if HAVE_LIBREADLINE
|
||||||
if (_line != (char *) NULL && _line != (char *) EOF)
|
if (_line != (char *) NULL) {
|
||||||
free (_line);
|
ch = _line[0];
|
||||||
_line = readline ("Action (h for help): ");
|
free(_line);
|
||||||
if (_line == (char *)NULL || _line == (char *)EOF) {
|
_line = NULL;
|
||||||
ch = EOF;
|
} else {
|
||||||
continue;
|
_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
|
#else
|
||||||
/* ask for a new line */
|
/* ask for a new line */
|
||||||
fprintf(stderr, "Action (h for help): ");
|
fprintf(stderr, "Action (h for help): ");
|
||||||
@ -1215,7 +1216,8 @@ HandleSIGINT (int sig)
|
|||||||
PrologMode |= InterruptMode;
|
PrologMode |= InterruptMode;
|
||||||
#if HAVE_LIBREADLINE
|
#if HAVE_LIBREADLINE
|
||||||
if (in_getc) {
|
if (in_getc) {
|
||||||
siglongjmp(readline_jmpbuf, 0);
|
fprintf(stderr, "Action (h for help): ");
|
||||||
|
rl_set_prompt("Action (h for help): ");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
|
Reference in New Issue
Block a user