memstream

This commit is contained in:
Vítor Santos Costa 2018-05-07 09:13:06 +01:00
parent 98dd9394b4
commit 6fe162025b
1 changed files with 13 additions and 11 deletions

View File

@ -1079,13 +1079,13 @@ static Int with_output_to(USES_REGS1) {
return false;
}
if (IsApplTerm(tin) && (f = FunctorOfTerm(tin))) {
if(f == FunctorAtom || f == FunctorString || f == FunctorCodes1 ||
f == FunctorCodes || f == FunctorChars1 || f == FunctorChars)) {
output_stream = Yap_OpenBufWriteStream(PASS_REGS1);
my_mem_stream = true;
}
} else {
if (f == FunctorAtom || f == FunctorString || f == FunctorCodes1 ||
f == FunctorCodes || f == FunctorChars1 || f == FunctorChars) {
output_stream = Yap_OpenBufWriteStream(PASS_REGS1);
my_mem_stream = true;
}
}
if (my_mem_stream){
/* needs to change LOCAL_c_output_stream for write */
output_stream = Yap_CheckStream(ARG1, Output_Stream_f, "format/3");
my_mem_stream = false;
@ -1121,15 +1121,17 @@ static Int format(Term tf, Term tas, Term tout USES_REGS) {
return false;
}
yhandle_t hl = Yap_StartHandles(), yo = Yap_PushHandle(tout);
if (IsApplTerm(tout) && (f = FunctorOfTerm(tout)) &&
(f == FunctorAtom || f == FunctorString1 || f == FunctorCodes1 ||
f == FunctorCodes || f == FunctorChars1 || f == FunctorChars)) {
if (IsApplTerm(tout) && (f = FunctorOfTerm(tout))) {
if (f == FunctorAtom || f == FunctorString1 || f == FunctorCodes1 ||
f == FunctorCodes || f == FunctorChars1 || f == FunctorChars){
output_stream = Yap_OpenBufWriteStream(PASS_REGS1);
mem_stream = true;
} else {
}
if (!mem_stream) {
/* needs to change LOCAL_c_output_stream for write */
output_stream = Yap_CheckStream(tout, Output_Stream_f, "format/3");
}
}
if (output_stream == -1) {
UNLOCK(GLOBAL_Stream[output_stream].streamlock);
return false;