avoid unnecessary flushing in readline
fixes to manual make flush work for readline git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@140 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
a09e21bf68
commit
5d5ddd864e
23
C/iopreds.c
23
C/iopreds.c
@ -313,17 +313,26 @@ YP_putc(int ch, int sno)
|
||||
int
|
||||
YP_fflush(int sno)
|
||||
{
|
||||
#if HAVE_LIBREADLINE
|
||||
if (Stream[sno].status & Tty_Stream_f &&
|
||||
Stream[sno].status & Output_Stream_f) {
|
||||
if (ReadlinePos != ReadlineBuf) {
|
||||
ReadlinePos[0] = '\0';
|
||||
fputs( ReadlineBuf, Stream[sno].u.file.file);
|
||||
}
|
||||
ReadlinePos = ReadlineBuf;
|
||||
}
|
||||
#endif
|
||||
if ( (Stream[sno].status & Output_Stream_f) &&
|
||||
! (Stream[sno].status &
|
||||
(Null_Stream_f|
|
||||
InMemory_Stream_f|
|
||||
Socket_Stream_f|
|
||||
Pipe_Stream_f|
|
||||
Free_Stream_f)) )
|
||||
Free_Stream_f)) ) {
|
||||
return(fflush(Stream[sno].u.file.file));
|
||||
else
|
||||
} else
|
||||
return(0);
|
||||
return(fflush(Stream[sno].u.file.file));
|
||||
}
|
||||
|
||||
static void
|
||||
@ -883,7 +892,6 @@ ReadlineGetc(int sno)
|
||||
}
|
||||
}
|
||||
}
|
||||
YP_fflush (YP_stdout);
|
||||
/* Only sends a newline if we are at the start of a line */
|
||||
if (_line != NULL && _line != (char *) EOF)
|
||||
free (_line);
|
||||
@ -901,7 +909,7 @@ ReadlineGetc(int sno)
|
||||
}
|
||||
_line = readline (Prompt);
|
||||
} else {
|
||||
_line = readline ("");
|
||||
_line = readline (NULL);
|
||||
}
|
||||
} else {
|
||||
if (ReadlinePos != ReadlineBuf) {
|
||||
@ -909,7 +917,7 @@ ReadlineGetc(int sno)
|
||||
ReadlinePos = ReadlineBuf;
|
||||
_line = readline (ReadlineBuf);
|
||||
} else {
|
||||
_line = readline ("");
|
||||
_line = readline (NULL);
|
||||
}
|
||||
}
|
||||
newline=FALSE;
|
||||
@ -4352,8 +4360,7 @@ p_flush (void)
|
||||
int sno = CheckStream (ARG1, Output_Stream_f, "flush_output/1");
|
||||
if (sno < 0)
|
||||
return (FALSE);
|
||||
if (!(Stream[sno].status & (Null_Stream_f|Socket_Stream_f|Pipe_Stream_f|InMemory_Stream_f)))
|
||||
YP_fflush (sno);
|
||||
YP_fflush (sno);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
|
@ -1240,11 +1240,11 @@ HandleALRM (int s, siginfo_t *x, ucontext_t *y)
|
||||
HandleALRM(int s)
|
||||
#endif
|
||||
{
|
||||
my_signal (SIGALRM, HandleALRM);
|
||||
/* force the system to creep */
|
||||
p_creep ();
|
||||
/* now, say what is going on */
|
||||
PutValue(AtomAlarm, MkAtomTerm(AtomTrue));
|
||||
my_signal (SIGALRM, HandleALRM);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1934,7 +1934,7 @@ p_alarm(void)
|
||||
Int left;
|
||||
Term tout;
|
||||
|
||||
left = alarm(IntOfTerm(t));
|
||||
left = alarm(IntegerOfTerm(t));
|
||||
tout = MkIntegerTerm(left);
|
||||
return(unify(ARG2,tout));
|
||||
}
|
||||
|
@ -16,6 +16,9 @@
|
||||
|
||||
<h2>Yap-4.3.20:</h2>
|
||||
<ul>
|
||||
<li>FIXED: flush should work with readline.</li>
|
||||
<li>FIXED: reset alarm at top-level.</li>
|
||||
<li>FIXED: do signal(ALARM) immediately.</li>
|
||||
<li>FIXED: don't use full optimization for parser.c in cygwin
|
||||
(report from Steve Moyle).</li>
|
||||
<li>NEW: Erik Alphonse's apply_macros library.</li>
|
||||
|
25
docs/yap.tex
25
docs/yap.tex
@ -5388,8 +5388,9 @@ a certain procedure does not take longer than a certain amount of time:
|
||||
@example
|
||||
loop :- loop.
|
||||
|
||||
:- alarm(10, throw(ball), _),
|
||||
catch(loop, ball, format('Quota exhausted.~n',[])).
|
||||
:- catch((alarm(10, throw(ball), _),loop),
|
||||
ball,
|
||||
format('Quota exhausted.~n',[])).
|
||||
@end example
|
||||
In this case after @code{10} seconds our @code{loop} is interrupted,
|
||||
@code{ball} is thrown, and the handler writes @code{Quota exhausted}.
|
||||
@ -6294,7 +6295,7 @@ Library, Extensions, Builtins, Top
|
||||
|
||||
@end menu
|
||||
|
||||
@node Apply Macros, Association Trees, , Library
|
||||
@node Apply Macros, Association Lists, , Library
|
||||
@section Apply Macros
|
||||
@cindex macros
|
||||
|
||||
@ -6352,11 +6353,11 @@ applying the predicate @var{Pred} to all list elements on which
|
||||
arguments of @var{TermIn}
|
||||
|
||||
@item sumargs(+@var{Pred}, +@var{Term}, ?@var{AccIn}, ?@var{AccOut})
|
||||
@findex sumargs/3
|
||||
@snindex sumargs/3
|
||||
@cnindex sumargs/3
|
||||
Calls the predicate @var{Pred} on all arguments of @var{Term} and collects a
|
||||
result in @var{Accumulator}
|
||||
@findex sumargs/4
|
||||
@snindex sumargs/4
|
||||
@cnindex sumargs/4
|
||||
Calls the predicate @var{Pred} on all arguments of @var{Term} and
|
||||
collects a result in @var{Accumulator}
|
||||
|
||||
@item mapnodes(+@var{Pred}, +@var{TermIn}, ?@var{TermOut})
|
||||
@findex mapnodes/3
|
||||
@ -6372,10 +6373,10 @@ applying the predicate @var{Pred} to all list elements on which
|
||||
Succeeds if the predicate @var{Pred} succeeds on all sub-terms of
|
||||
@var{Term} (depth-first and left-to-right order)
|
||||
|
||||
@item sumnodes(+@var{Pred}, +var{Term}, ?@var{AccIn}, ?@var{AccOut})
|
||||
@findex sumnodes/3
|
||||
@snindex sumnodes/3
|
||||
@cnindex sumnodes/3
|
||||
@item sumnodes(+@var{Pred}, +@var{Term}, ?@var{AccIn}, ?@var{AccOut})
|
||||
@findex sumnodes/4
|
||||
@snindex sumnodes/4
|
||||
@cnindex sumnodes/4
|
||||
Calls the predicate @var{Pred} on all sub-terms of @var{Term} and
|
||||
collect a result in @var{Accumulator} (depth-first and left-to-right order)
|
||||
@end table
|
||||
|
@ -15,7 +15,6 @@
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
'$qery'((?-)).
|
||||
%
|
||||
% This one should come first so that disjunctions and long distance
|
||||
% cuts are compiled right with co-routining.
|
||||
@ -150,6 +149,10 @@ nl.
|
||||
'$read'(true,T,V),
|
||||
set_input(Old).
|
||||
|
||||
% reset alarms when entering top-level.
|
||||
'$enter_top_level' :-
|
||||
'$alarm'(0, _),
|
||||
fail.
|
||||
'$enter_top_level' :-
|
||||
'$clean_up_dead_clauses',
|
||||
fail.
|
||||
|
Reference in New Issue
Block a user