skip
more write updates.
This commit is contained in:
parent
f13215700b
commit
52f8cb1041
100
C/iopreds.c
100
C/iopreds.c
@ -104,8 +104,6 @@ STATIC_PROTO (int PlUnGetc, (int));
|
|||||||
STATIC_PROTO (Term MkStream, (int));
|
STATIC_PROTO (Term MkStream, (int));
|
||||||
STATIC_PROTO (int CheckStream, (Term, int, char *));
|
STATIC_PROTO (int CheckStream, (Term, int, char *));
|
||||||
STATIC_PROTO (Int p_close, (void));
|
STATIC_PROTO (Int p_close, (void));
|
||||||
STATIC_PROTO (Int p_write, (void));
|
|
||||||
STATIC_PROTO (Int p_write2, (void));
|
|
||||||
STATIC_PROTO (Int p_set_read_error_handler, (void));
|
STATIC_PROTO (Int p_set_read_error_handler, (void));
|
||||||
STATIC_PROTO (Int p_get_read_error_handler, (void));
|
STATIC_PROTO (Int p_get_read_error_handler, (void));
|
||||||
STATIC_PROTO (Int p_read, (void));
|
STATIC_PROTO (Int p_read, (void));
|
||||||
@ -1770,102 +1768,6 @@ int beam_write (void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static Int
|
|
||||||
p_write (void)
|
|
||||||
{
|
|
||||||
/* '$write'(+Flags,?Term) */
|
|
||||||
int flags = (int) IntOfTerm (Deref (ARG1));
|
|
||||||
/* notice: we must have ASP well set when using portray, otherwise
|
|
||||||
we cannot make recursive Prolog calls */
|
|
||||||
Yap_StartSlots();
|
|
||||||
Yap_plwrite (ARG2, Stream[Yap_c_output_stream].stream_wputc, flags, 1200);
|
|
||||||
Yap_CloseSlots();
|
|
||||||
if (EX != 0L) {
|
|
||||||
Term ball = Yap_PopTermFromDB(EX);
|
|
||||||
EX = NULL;
|
|
||||||
Yap_JumpToEnv(ball);
|
|
||||||
return(FALSE);
|
|
||||||
}
|
|
||||||
return (TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
static Int
|
|
||||||
p_write_prio (void)
|
|
||||||
{
|
|
||||||
/* '$write'(+Flags,?Term) */
|
|
||||||
int flags = (int) IntOfTerm (Deref (ARG1));
|
|
||||||
/* notice: we must have ASP well set when using portray, otherwise
|
|
||||||
we cannot make recursive Prolog calls */
|
|
||||||
Yap_StartSlots();
|
|
||||||
Yap_plwrite (ARG3, Stream[Yap_c_output_stream].stream_wputc, flags, (int)IntOfTerm(Deref(ARG2)));
|
|
||||||
Yap_CloseSlots();
|
|
||||||
if (EX != 0L) {
|
|
||||||
Term ball = Yap_PopTermFromDB(EX);
|
|
||||||
EX = NULL;
|
|
||||||
Yap_JumpToEnv(ball);
|
|
||||||
return(FALSE);
|
|
||||||
}
|
|
||||||
return (TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
static Int
|
|
||||||
p_write2_prio (void)
|
|
||||||
{ /* '$write'(+Stream,+Flags,?Term) */
|
|
||||||
int old_output_stream = Yap_c_output_stream;
|
|
||||||
Int flags = IntegerOfTerm(Deref(ARG2));
|
|
||||||
int stream_f;
|
|
||||||
|
|
||||||
if (flags & Use_SWI_Stream_f) {
|
|
||||||
stream_f = Output_Stream_f|SWI_Stream_f;
|
|
||||||
} else {
|
|
||||||
stream_f = Output_Stream_f;
|
|
||||||
}
|
|
||||||
Yap_c_output_stream = CheckStream (ARG1, stream_f, "write/2");
|
|
||||||
if (Yap_c_output_stream == -1) {
|
|
||||||
Yap_c_output_stream = old_output_stream;
|
|
||||||
return(FALSE);
|
|
||||||
}
|
|
||||||
UNLOCK(Stream[Yap_c_output_stream].streamlock);
|
|
||||||
/* notice: we must have ASP well set when using portray, otherwise
|
|
||||||
we cannot make recursive Prolog calls */
|
|
||||||
Yap_StartSlots();
|
|
||||||
Yap_plwrite (ARG4, Stream[Yap_c_output_stream].stream_wputc, (int) flags, (int) IntOfTerm (Deref (ARG3)));
|
|
||||||
Yap_CloseSlots();
|
|
||||||
Yap_c_output_stream = old_output_stream;
|
|
||||||
if (EX != 0L) {
|
|
||||||
Term ball = Yap_PopTermFromDB(EX);
|
|
||||||
EX = NULL;
|
|
||||||
Yap_JumpToEnv(ball);
|
|
||||||
return(FALSE);
|
|
||||||
}
|
|
||||||
return (TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
static Int
|
|
||||||
p_write2 (void)
|
|
||||||
{ /* '$write'(+Stream,+Flags,?Term) */
|
|
||||||
int old_output_stream = Yap_c_output_stream;
|
|
||||||
Yap_c_output_stream = CheckStream (ARG1, Output_Stream_f, "write/2");
|
|
||||||
if (Yap_c_output_stream == -1) {
|
|
||||||
Yap_c_output_stream = old_output_stream;
|
|
||||||
return(FALSE);
|
|
||||||
}
|
|
||||||
UNLOCK(Stream[Yap_c_output_stream].streamlock);
|
|
||||||
/* notice: we must have ASP well set when using portray, otherwise
|
|
||||||
we cannot make recursive Prolog calls */
|
|
||||||
Yap_StartSlots();
|
|
||||||
Yap_plwrite (ARG3, Stream[Yap_c_output_stream].stream_wputc, (int) IntOfTerm (Deref (ARG2)), 1200);
|
|
||||||
Yap_CloseSlots();
|
|
||||||
Yap_c_output_stream = old_output_stream;
|
|
||||||
if (EX != 0L) {
|
|
||||||
Term ball = Yap_PopTermFromDB(EX);
|
|
||||||
EX = NULL;
|
|
||||||
Yap_JumpToEnv(ball);
|
|
||||||
return(FALSE);
|
|
||||||
}
|
|
||||||
return (TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
clean_vars(VarEntry *p)
|
clean_vars(VarEntry *p)
|
||||||
{
|
{
|
||||||
@ -3921,8 +3823,6 @@ Yap_InitIOPreds(void)
|
|||||||
Yap_InitCPred ("$read", 6, p_read, SyncPredFlag|HiddenPredFlag|UserCPredFlag);
|
Yap_InitCPred ("$read", 6, p_read, SyncPredFlag|HiddenPredFlag|UserCPredFlag);
|
||||||
Yap_InitCPred ("$read", 7, p_read2, SyncPredFlag|HiddenPredFlag|UserCPredFlag);
|
Yap_InitCPred ("$read", 7, p_read2, SyncPredFlag|HiddenPredFlag|UserCPredFlag);
|
||||||
Yap_InitCPred ("$skip", 2, p_skip, SafePredFlag|SyncPredFlag|HiddenPredFlag);
|
Yap_InitCPred ("$skip", 2, p_skip, SafePredFlag|SyncPredFlag|HiddenPredFlag);
|
||||||
Yap_InitCPred ("$write_with_prio", 3, p_write_prio, SyncPredFlag|HiddenPredFlag);
|
|
||||||
Yap_InitCPred ("$write_with_prio", 4, p_write2_prio, SyncPredFlag|HiddenPredFlag);
|
|
||||||
Yap_InitCPred ("format", 2, p_format, SyncPredFlag);
|
Yap_InitCPred ("format", 2, p_format, SyncPredFlag);
|
||||||
Yap_InitCPred ("format", 3, p_format2, SyncPredFlag);
|
Yap_InitCPred ("format", 3, p_format2, SyncPredFlag);
|
||||||
Yap_InitCPred ("$start_line", 1, p_startline, SafePredFlag|SyncPredFlag|HiddenPredFlag);
|
Yap_InitCPred ("$start_line", 1, p_startline, SafePredFlag|SyncPredFlag|HiddenPredFlag);
|
||||||
|
@ -628,7 +628,7 @@ true :- true.
|
|||||||
'$do_another'(C).
|
'$do_another'(C).
|
||||||
|
|
||||||
'$do_another'(C) :-
|
'$do_another'(C) :-
|
||||||
( C== 0'; -> '$skip'(user_input,10), %'
|
( C== 0'; -> skip(user_input,10), %'
|
||||||
'$add_nl_outside_console',
|
'$add_nl_outside_console',
|
||||||
fail
|
fail
|
||||||
;
|
;
|
||||||
@ -645,7 +645,7 @@ true :- true.
|
|||||||
;
|
;
|
||||||
C== -1 -> halt
|
C== -1 -> halt
|
||||||
;
|
;
|
||||||
'$skip'(user_input,10), '$ask_again_for_another'
|
skip(user_input,10), '$ask_again_for_another'
|
||||||
).
|
).
|
||||||
|
|
||||||
%'$add_nl_outside_console' :-
|
%'$add_nl_outside_console' :-
|
||||||
@ -1506,6 +1506,11 @@ put_code(C) :-
|
|||||||
put_code(Stream, C) :-
|
put_code(Stream, C) :-
|
||||||
swi_put_code(Stream, C).
|
swi_put_code(Stream, C).
|
||||||
|
|
||||||
|
skip(C) :-
|
||||||
|
swi_skip(C).
|
||||||
|
skip(Stream, C) :-
|
||||||
|
swi_skip(Stream, C).
|
||||||
|
|
||||||
nl :-
|
nl :-
|
||||||
swi_nl.
|
swi_nl.
|
||||||
nl(Stream) :-
|
nl(Stream) :-
|
||||||
|
@ -252,6 +252,9 @@ display(Stream, T) :-
|
|||||||
format(T) :-
|
format(T) :-
|
||||||
format(T, []).
|
format(T, []).
|
||||||
|
|
||||||
|
writeln(T) :-
|
||||||
|
write(T),
|
||||||
|
nl.
|
||||||
|
|
||||||
/* interface to user portray */
|
/* interface to user portray */
|
||||||
'$portray'(T) :-
|
'$portray'(T) :-
|
||||||
@ -262,10 +265,6 @@ format(T) :-
|
|||||||
|
|
||||||
/* character I/O */
|
/* character I/O */
|
||||||
|
|
||||||
skip(N) :- current_input(S), N1 is N, '$skip'(S,N1).
|
|
||||||
|
|
||||||
skip(Stream,N) :- N1 is N, '$skip'(Stream,N1).
|
|
||||||
|
|
||||||
ttyget(N) :- get(user_input,N).
|
ttyget(N) :- get(user_input,N).
|
||||||
|
|
||||||
ttyget0(N) :- get0(user_input,N).
|
ttyget0(N) :- get0(user_input,N).
|
||||||
|
Reference in New Issue
Block a user