stream cotrol was broken
This commit is contained in:
parent
1c2880fd1b
commit
5c33960535
41
C/flags.c
41
C/flags.c
@ -47,9 +47,13 @@ static Term sys_pid(Term inp);
|
|||||||
static bool mkprompt(Term inp);
|
static bool mkprompt(Term inp);
|
||||||
static Term synerr(Term inp);
|
static Term synerr(Term inp);
|
||||||
static Term indexer(Term inp);
|
static Term indexer(Term inp);
|
||||||
|
static Term stream(Term inp);
|
||||||
static bool getenc(Term inp);
|
static bool getenc(Term inp);
|
||||||
static bool typein(Term inp);
|
static bool typein(Term inp);
|
||||||
static bool dqf(Term t2);
|
static bool dqf(Term t2);
|
||||||
|
static bool set_error_stream( Term inp );
|
||||||
|
static bool set_input_stream( Term inp );
|
||||||
|
static bool set_output_stream( Term inp );
|
||||||
|
|
||||||
static void newFlag(Term fl, Term val);
|
static void newFlag(Term fl, Term val);
|
||||||
static Int current_prolog_flag(USES_REGS1);
|
static Int current_prolog_flag(USES_REGS1);
|
||||||
@ -168,6 +172,41 @@ static Term isaccess(Term inp) {
|
|||||||
return TermZERO;
|
return TermZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Term stream(Term inp) {
|
||||||
|
if ( IsVarTerm(inp) )
|
||||||
|
return inp;
|
||||||
|
return Yap_CheckStream( inp, Input_Stream_f | Output_Stream_f |
|
||||||
|
Append_Stream_f | Socket_Stream_f, "yap_flag/3" ) >= 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
set_error_stream( Term inp ) {
|
||||||
|
LOCAL_c_error_stream = Yap_CheckStream( inp, Output_Stream_f |
|
||||||
|
Append_Stream_f | Socket_Stream_f, "yap_flag/3" );
|
||||||
|
if( IsVarTerm(inp) )
|
||||||
|
return Yap_unify( inp, Yap_StreamUserName( LOCAL_c_error_stream ) );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
set_input_stream( Term inp ) {
|
||||||
|
LOCAL_c_input_stream = Yap_CheckStream( inp, Input_Stream_f | Socket_Stream_f, "yap_flag/3" );
|
||||||
|
if( IsVarTerm(inp) )
|
||||||
|
return Yap_unify( inp, Yap_StreamUserName( LOCAL_c_input_stream ) );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
set_output_stream( Term inp ) {
|
||||||
|
LOCAL_c_output_stream = Yap_CheckStream( inp, Output_Stream_f |
|
||||||
|
Append_Stream_f | Socket_Stream_f, "yap_flag/3" );
|
||||||
|
if( IsVarTerm(inp) )
|
||||||
|
return Yap_unify( inp, Yap_StreamUserName( LOCAL_c_output_stream ) );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static Term isground(Term inp) {
|
static Term isground(Term inp) {
|
||||||
return Yap_IsGroundTerm(inp) ? inp : TermZERO;
|
return Yap_IsGroundTerm(inp) ? inp : TermZERO;
|
||||||
}
|
}
|
||||||
@ -1473,7 +1512,7 @@ static void newFlag(Term fl, Term val) {
|
|||||||
GLOBAL_flagCount++;
|
GLOBAL_flagCount++;
|
||||||
f.name = (char *)RepAtom(AtomOfTerm(fl))->StrOfAE;
|
f.name = (char *)RepAtom(AtomOfTerm(fl))->StrOfAE;
|
||||||
f.writable = true;
|
f.writable = true;
|
||||||
f.helper = 0;
|
f.helper = NULL;
|
||||||
f.def = ok;
|
f.def = ok;
|
||||||
initFlag(&f, i, true);
|
initFlag(&f, i, true);
|
||||||
if (IsAtomOrIntTerm(val)) {
|
if (IsAtomOrIntTerm(val)) {
|
||||||
|
@ -83,7 +83,7 @@ which must be an atom. If unbound, unify the argument with the current
|
|||||||
working module.
|
working module.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
YAP_FLAG( USER_ERROR_FLAG, "user_error", true, isatom, "user_error" , NULL ), /**< `user_error1`
|
YAP_FLAG( USER_ERROR_FLAG, "user_error", true, stream, "user_error" , set_error_stream ), /**< `user_error1`
|
||||||
|
|
||||||
If the second argument is bound to a stream, set user_error to
|
If the second argument is bound to a stream, set user_error to
|
||||||
this stream. If the second argument is unbound, unify the argument with
|
this stream. If the second argument is unbound, unify the argument with
|
||||||
@ -114,5 +114,5 @@ prompts from the system were redirected to the stream
|
|||||||
automatically redirects the user_error alias to the original
|
automatically redirects the user_error alias to the original
|
||||||
`stderr`.
|
`stderr`.
|
||||||
*/
|
*/
|
||||||
YAP_FLAG( USER_INPUT_FLAG, "user_input", true, isatom, "user_input" , NULL ),
|
YAP_FLAG( USER_INPUT_FLAG, "user_input", true, stream, "user_input" , set_input_stream ),
|
||||||
YAP_FLAG( USER_OUTPUT_FLAG, "user_output", true, isatom, "user_output" , NULL ),
|
YAP_FLAG( USER_OUTPUT_FLAG, "user_output", true, stream, "user_output" , set_output_stream ),
|
||||||
|
Reference in New Issue
Block a user