make format/n swi aware.

This commit is contained in:
Vitor Santos Costa 2010-12-17 00:11:05 +00:00
parent cfe0dda995
commit 0c7f207627
2 changed files with 22 additions and 4 deletions

View File

@ -5953,10 +5953,9 @@ p_format(void)
return res;
}
static Int
p_format2(void)
{ /* 'format'(Stream,Control,Args) */
format2(UInt stream_flag)
{
int old_c_stream = Yap_c_output_stream;
int mem_stream = FALSE, codes_stream = FALSE;
Int out;
@ -5975,7 +5974,7 @@ p_format2(void)
mem_stream = TRUE;
} else {
/* needs to change Yap_c_output_stream for write */
Yap_c_output_stream = CheckStream (ARG1, Output_Stream_f, "format/3");
Yap_c_output_stream = CheckStream (ARG1, Output_Stream_f|stream_flag, "format/3");
}
UNLOCK(Stream[Yap_c_output_stream].streamlock);
if (Yap_c_output_stream == -1) {
@ -6007,6 +6006,18 @@ p_format2(void)
return out;
}
static Int
p_format2(void)
{ /* 'format'(Stream,Control,Args) */
return format2(0);
}
static Int
p_swi_format(void)
{ /* 'format'(Stream,Control,Args) */
return format2(SWI_Stream_f);
}
static Int
p_skip (void)
@ -6804,6 +6815,10 @@ Yap_InitIOPreds(void)
Yap_InitCPred ("$tolower", 2, p_tolower, SafePredFlag|HiddenPredFlag);
Yap_InitCPred ("file_base_name", 2, p_file_base_name, SafePredFlag|HiddenPredFlag);
CurrentModule = SYSTEM_MODULE;
Yap_InitCPred ("swi_format", 3, p_swi_format, SyncPredFlag);
CurrentModule = cm;
Yap_InitReadUtil ();
#if USE_SOCKET
Yap_InitSockets ();

View File

@ -242,6 +242,9 @@ goal_expansion(print(A),write_term(user_output,A,[swi(true),portray(true),number
goal_expansion(print(S,A),write_term(S,A,[swi(true),portray(true),numbervars(true)])) :- swi_io.
goal_expansion(write_term(A,Opts),write_term(user_output,A,Opts,[swi(true)|Opts])) :- swi_io.
goal_expansion(write_term(S,A,Opts),write_term(S,A,[swi(true)|Opts])) :- swi_io, \+ member(swi(_), Opts).
goal_expansion(format(A),system:swi_format(user_output,A,[])) :- swi_io.
goal_expansion(format(A,Args),system:swi_format(user_output,A,Args)) :- swi_io.
goal_expansion(format(S,A,Args),system:swi_format(S,A,Args)) :- swi_io.
% make sure we also use