support recent readlines.

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@77 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc 2001-06-11 17:40:16 +00:00
parent a0debea045
commit 0164f32c36
4 changed files with 72 additions and 6 deletions

View File

@ -140,6 +140,7 @@ STATIC_PROTO (int ConsoleSocketGetc, (int));
#endif
#if HAVE_LIBREADLINE
STATIC_PROTO (int ReadlineGetc, (int));
STATIC_PROTO (int ReadlinePutc, (int,int));
#endif
STATIC_PROTO (int PlUnGetc, (int));
STATIC_PROTO (Term MkStream, (int));
@ -363,6 +364,9 @@ p_always_prompt_user(void)
#if HAVE_LIBREADLINE
if (s->status & Tty_Stream_f) {
s->stream_getc = ReadlineGetc;
if (Stream[0].status && Tty_Stream_f &&
s->u.file.name == Stream[0].u.file.name)
s->stream_putc = ReadlinePutc;
} else
#endif
{
@ -408,6 +412,9 @@ InitStdStream (int sno, SMALLUNSGN flags, YP_File file, Atom name)
/* if a tty have a special routine to call readline */
#if HAVE_LIBREADLINE
if (s->status & Tty_Stream_f) {
if (Stream[0].status && Tty_Stream_f &&
s->u.file.name == Stream[0].u.file.name)
s->stream_putc = ReadlinePutc;
s->stream_getc = ReadlineGetc;
} else
#endif
@ -755,9 +762,47 @@ static char *_line = (char *) NULL;
int in_readline = FALSE;
static int cur_out_sno = 2;
#define READLINE_OUT_BUF_MAX 256
static void
InitReadline(void) {
ReadlineBuf = (char *)AllocAtomSpace(READLINE_OUT_BUF_MAX+1);
ReadlinePos = ReadlineBuf;
}
static int
ReadlinePutc (int sno, int ch)
{
if (ReadlinePos != ReadlineBuf &&
(sno != cur_out_sno ||
ReadlinePos - ReadlineBuf == READLINE_OUT_BUF_MAX-1 ||
#if MAC || _MSC_VER
ch == 10 ||
#endif
ch == '\n')) {
#if MAC || _MSC_VER
if (ch == 10)
{
ch = '\n';
}
#endif
if (ch == '\n') {
ReadlinePos[0] = '\n';
ReadlinePos++;
}
ReadlinePos[0] = '\0';
fputs( ReadlineBuf, Stream[sno].u.file.file);
ReadlinePos = ReadlineBuf;
if (ch == '\n') {
console_count_output_char(ch,Stream+sno,sno);
return((int) '\n');
}
}
*ReadlinePos++ = ch;
console_count_output_char(ch,Stream+sno,sno);
return ((int) ch);
}
/*
@ -776,8 +821,8 @@ ReadlineGetc(int sno)
/* Only sends a newline if we are at the start of a line */
if (_line != (char *) NULL && _line != (char *) EOF)
free (_line);
rl_instream = stdin;
rl_outstream = stderr;
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) {
@ -794,7 +839,13 @@ ReadlineGetc(int sno)
_line = readline ("");
}
} else {
_line = readline ("");
if (ReadlinePos != ReadlineBuf) {
ReadlinePos[0] = '\0';
ReadlinePos = ReadlineBuf;
_line = readline (ReadlineBuf);
} else {
_line = readline ("");
}
}
newline=FALSE;
in_readline = FALSE;
@ -861,6 +912,9 @@ EOFGetc(int sno)
#if HAVE_LIBREADLINE
if (s->status & Tty_Stream_f) {
s->stream_getc = ReadlineGetc;
if (Stream[0].status && Tty_Stream_f &&
s->u.file.name == Stream[0].u.file.name)
s->stream_putc = ReadlinePutc;
} else
#endif
{
@ -1162,6 +1216,9 @@ PlUnGetc (int sno)
#if HAVE_LIBREADLINE
if (s->status & Tty_Stream_f) {
s->stream_getc = ReadlineGetc;
if (Stream[0].status && Tty_Stream_f &&
s->u.file.name == Stream[0].u.file.name)
s->stream_putc = ReadlinePutc;
} else
#endif
{

View File

@ -10,7 +10,7 @@
* File: Heap.h *
* mods: *
* comments: Heap Init Structure *
* version: $Id: Heap.h,v 1.5 2001-06-08 19:10:43 vsc Exp $ *
* version: $Id: Heap.h,v 1.6 2001-06-11 17:40:16 vsc Exp $ *
*************************************************************************/
/* information that can be stored in Code Space */
@ -78,6 +78,9 @@ typedef struct various_codes {
consult_obj *consultbase;
consult_obj *consultlow;
Int consultcapacity;
#if HAVE_LIBREADLINE
char *readline_buf, *readline_pos;
#endif
#if USE_THREADED_CODE
opentry *op_rtable;
#endif
@ -478,5 +481,9 @@ typedef struct various_codes {
#define ConsultLow (heap_regs->consultlow )
/* current maximum number of cells in consult stack */
#define ConsultCapacity (heap_regs->consultcapacity )
#if HAVE_LIBREADLINE
#define ReadlineBuf heap_regs->readline_buf
#define ReadlinePos heap_regs->readline_pos
#endif

2
TO_DO
View File

@ -1,5 +1,4 @@
BEFORE 4.4:
- weird going ons with prompt and readline
- mixed constraints and delays.
- write infinite terms
- constraints in DB.
@ -74,3 +73,4 @@ DONE:
- fix bugs from Nicos.
- remove pl/nfr.yap and misc/yap.spec from CVS.
- deterministic trail entries for multi-assignment variables.
- weird going ons with prompt and readline

View File

@ -16,6 +16,8 @@
<h2>Yap-4.3.19:</h2>
<ul>
<li>FIXED: support newer versions of readline by moving text
to prompt.</li>
<li>FIXED: upgrade to autoconf 2.5.</li>
<li>FIXED: catch and throw should not leave unnecessary
choice-points behind.</li>