Merge branch 'master' of ../yap-6.2

This commit is contained in:
Vitor Santos Costa
2010-12-13 12:40:07 +00:00
31 changed files with 231 additions and 144 deletions

View File

@@ -3489,9 +3489,17 @@ CheckStream (Term arg, int kind, char *msg)
sname = AtomUserOut;
}
}
if (kind & SWI_Stream_f) {
struct io_stream *swi_stream;
if (Yap_get_stream_handle(arg, &swi_stream)) {
sno = LookupSWIStream(swi_stream);
return sno;
}
}
if ((sno = CheckAlias(sname)) == -1) {
Yap_Error(EXISTENCE_ERROR_STREAM, arg, msg);
return(-1);
return -1;
}
} else if (IsApplTerm (arg) && FunctorOfTerm (arg) == FunctorStream) {
arg = ArgOfTerm (1, arg);
@@ -4089,7 +4097,15 @@ static Int
p_write2_prio (void)
{ /* '$write'(+Stream,+Flags,?Term) */
int old_output_stream = Yap_c_output_stream;
Yap_c_output_stream = CheckStream (ARG1, Output_Stream_f, "write/2");
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);
@@ -4098,7 +4114,7 @@ p_write2_prio (void)
/* 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) IntOfTerm (Deref (ARG2)), (int) IntOfTerm (Deref (ARG3)));
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) {