memstream
This commit is contained in:
parent
98dd9394b4
commit
6fe162025b
24
os/format.c
24
os/format.c
@ -1079,13 +1079,13 @@ static Int with_output_to(USES_REGS1) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (IsApplTerm(tin) && (f = FunctorOfTerm(tin))) {
|
if (IsApplTerm(tin) && (f = FunctorOfTerm(tin))) {
|
||||||
if(f == FunctorAtom || f == FunctorString || f == FunctorCodes1 ||
|
if (f == FunctorAtom || f == FunctorString || f == FunctorCodes1 ||
|
||||||
f == FunctorCodes || f == FunctorChars1 || f == FunctorChars)) {
|
f == FunctorCodes || f == FunctorChars1 || f == FunctorChars) {
|
||||||
output_stream = Yap_OpenBufWriteStream(PASS_REGS1);
|
output_stream = Yap_OpenBufWriteStream(PASS_REGS1);
|
||||||
my_mem_stream = true;
|
my_mem_stream = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
if (my_mem_stream){
|
||||||
/* needs to change LOCAL_c_output_stream for write */
|
/* needs to change LOCAL_c_output_stream for write */
|
||||||
output_stream = Yap_CheckStream(ARG1, Output_Stream_f, "format/3");
|
output_stream = Yap_CheckStream(ARG1, Output_Stream_f, "format/3");
|
||||||
my_mem_stream = false;
|
my_mem_stream = false;
|
||||||
@ -1121,15 +1121,17 @@ static Int format(Term tf, Term tas, Term tout USES_REGS) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
yhandle_t hl = Yap_StartHandles(), yo = Yap_PushHandle(tout);
|
yhandle_t hl = Yap_StartHandles(), yo = Yap_PushHandle(tout);
|
||||||
if (IsApplTerm(tout) && (f = FunctorOfTerm(tout)) &&
|
if (IsApplTerm(tout) && (f = FunctorOfTerm(tout))) {
|
||||||
(f == FunctorAtom || f == FunctorString1 || f == FunctorCodes1 ||
|
if (f == FunctorAtom || f == FunctorString1 || f == FunctorCodes1 ||
|
||||||
f == FunctorCodes || f == FunctorChars1 || f == FunctorChars)) {
|
f == FunctorCodes || f == FunctorChars1 || f == FunctorChars){
|
||||||
output_stream = Yap_OpenBufWriteStream(PASS_REGS1);
|
output_stream = Yap_OpenBufWriteStream(PASS_REGS1);
|
||||||
mem_stream = true;
|
mem_stream = true;
|
||||||
} else {
|
}
|
||||||
|
if (!mem_stream) {
|
||||||
/* needs to change LOCAL_c_output_stream for write */
|
/* needs to change LOCAL_c_output_stream for write */
|
||||||
output_stream = Yap_CheckStream(tout, Output_Stream_f, "format/3");
|
output_stream = Yap_CheckStream(tout, Output_Stream_f, "format/3");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (output_stream == -1) {
|
if (output_stream == -1) {
|
||||||
UNLOCK(GLOBAL_Stream[output_stream].streamlock);
|
UNLOCK(GLOBAL_Stream[output_stream].streamlock);
|
||||||
return false;
|
return false;
|
||||||
|
Reference in New Issue
Block a user