new $stream(T) checks if a term is a stream,

so that I don't have an excuse to call current_stream(_,_,S) with S
something not a stream.


git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@39 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc
2001-05-22 16:14:30 +00:00
parent 5c0d82b07d
commit 59fdfadfa9
2 changed files with 21 additions and 4 deletions

View File

@@ -2077,9 +2077,12 @@ init_cur_s (void)
{ /* Init current_stream */
Term t3 = Deref(ARG3);
if (!IsVarTerm(t3)) {
Int i = CheckStream (t3, Input_Stream_f|Output_Stream_f, "current_stream/3");
Term t1 = StreamName(i), t2;
Int i;
Term t1, t2;
i = CheckStream (t3, Input_Stream_f|Output_Stream_f, "current_stream/3");
t1 = StreamName(i);
t2 = (Stream[i].status & Input_Stream_f ?
MkAtomTerm (AtomRead) :
MkAtomTerm (AtomWrite));
@@ -4519,6 +4522,19 @@ StreamToFileNo(Term t)
}
}
int
p_stream(Term t)
{
Term in = Deref(ARG1);
if (IsVarTerm(in))
return(FALSE);
if (IsAtomTerm(in))
return(CheckAlias(AtomOfTerm(in)) >= 0);
if (IsApplTerm(in))
return(FunctorOfTerm(in) == FunctorStream);
return(FALSE);
}
void
InitBackIO (void)
{
@@ -4589,6 +4605,7 @@ InitIOPreds(void)
InitCPred ("$change_alias_to_stream", 2, p_change_alias_to_stream, SafePredFlag|SyncPredFlag);
InitCPred ("$check_if_valid_new_alias", 1, p_check_if_valid_new_alias, TestPredFlag|SafePredFlag|SyncPredFlag);
InitCPred ("$fetch_stream_alias", 2, p_fetch_stream_alias, SafePredFlag|SyncPredFlag);
InitCPred ("$stream", 2, p_stream, SafePredFlag|TestPredFlag),
#if HAVE_SELECT
InitCPred ("stream_select", 3, p_stream_select, SafePredFlag|SyncPredFlag);
#endif