fix stream_property
This commit is contained in:
parent
27b7e32036
commit
5a95c6bbc7
@ -336,7 +336,7 @@ FetchAlias (int sno)
|
|||||||
}
|
}
|
||||||
aliasp++;
|
aliasp++;
|
||||||
}
|
}
|
||||||
return(AtomFoundVar);
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check if arg is an alias */
|
/* check if arg is an alias */
|
||||||
|
19
os/streams.c
19
os/streams.c
@ -345,7 +345,7 @@ found_eof(int sno,
|
|||||||
return Yap_unify(t2, MkAtomTerm(AtomPast));
|
return Yap_unify(t2, MkAtomTerm(AtomPast));
|
||||||
if (flags & Eof_Stream_f)
|
if (flags & Eof_Stream_f)
|
||||||
return Yap_unify(t2, MkAtomTerm(AtomAt));
|
return Yap_unify(t2, MkAtomTerm(AtomAt));
|
||||||
return Yap_unify(t2, MkAtomTerm(AtomNot));
|
return Yap_unify(t2, MkAtomTerm(AtomAltNot));
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
@ -503,8 +503,11 @@ static bool do_stream_property(int sno,
|
|||||||
if (args[i].used) {
|
if (args[i].used) {
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case STREAM_PROPERTY_ALIAS:
|
case STREAM_PROPERTY_ALIAS:
|
||||||
|
{
|
||||||
|
Term ta = args[STREAM_PROPERTY_ALIAS].tvalue;
|
||||||
rc = rc & Yap_FetchStreamAlias(
|
rc = rc & Yap_FetchStreamAlias(
|
||||||
sno, args[STREAM_PROPERTY_ALIAS].tvalue PASS_REGS);
|
sno, ta PASS_REGS);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case STREAM_PROPERTY_BOM:
|
case STREAM_PROPERTY_BOM:
|
||||||
rc = rc && has_bom(sno, args[STREAM_PROPERTY_BOM].tvalue PASS_REGS);
|
rc = rc && has_bom(sno, args[STREAM_PROPERTY_BOM].tvalue PASS_REGS);
|
||||||
@ -588,9 +591,8 @@ static xarg *generate_property(int sno, Term t2,
|
|||||||
if (p == STREAM_PROPERTY_INPUT) Yap_unify(t2, MkAtomTerm(AtomInput));
|
if (p == STREAM_PROPERTY_INPUT) Yap_unify(t2, MkAtomTerm(AtomInput));
|
||||||
else if (p == STREAM_PROPERTY_OUTPUT) Yap_unify(t2, MkAtomTerm(AtomOutput));
|
else if (p == STREAM_PROPERTY_OUTPUT) Yap_unify(t2, MkAtomTerm(AtomOutput));
|
||||||
else {
|
else {
|
||||||
Term t0 = MkVarTerm();
|
|
||||||
Functor f = Yap_MkFunctor(Yap_LookupAtom(stream_property_defs[p].name), 1);
|
Functor f = Yap_MkFunctor(Yap_LookupAtom(stream_property_defs[p].name), 1);
|
||||||
Yap_unify( t2, Yap_MkApplTerm(f, 1, &t0));
|
Yap_unify( t2, Yap_MkNewApplTerm(f, 1));
|
||||||
}
|
}
|
||||||
return Yap_ArgListToVector(t2, stream_property_defs,
|
return Yap_ArgListToVector(t2, stream_property_defs,
|
||||||
STREAM_PROPERTY_END);
|
STREAM_PROPERTY_END);
|
||||||
@ -626,11 +628,8 @@ static Int cont_stream_property(USES_REGS1) { /* current_stream */
|
|||||||
cut_fail();
|
cut_fail();
|
||||||
}
|
}
|
||||||
LOCK(GLOBAL_Stream[i].streamlock);
|
LOCK(GLOBAL_Stream[i].streamlock);
|
||||||
if (args[STREAM_PROPERTY_ALIAS].tvalue &&
|
if (IsAtomTerm(args[STREAM_PROPERTY_ALIAS].tvalue)) {
|
||||||
IsAtomTerm(args[STREAM_PROPERTY_ALIAS].tvalue)) {
|
|
||||||
// one solution only
|
// one solution only
|
||||||
LOCK(GLOBAL_Stream[i].streamlock);
|
|
||||||
UNLOCK(GLOBAL_Stream[i].streamlock);
|
|
||||||
i = Yap_CheckAlias(AtomOfTerm(args[STREAM_PROPERTY_ALIAS].tvalue));
|
i = Yap_CheckAlias(AtomOfTerm(args[STREAM_PROPERTY_ALIAS].tvalue));
|
||||||
UNLOCK(GLOBAL_Stream[i].streamlock);
|
UNLOCK(GLOBAL_Stream[i].streamlock);
|
||||||
if (i < 0 ||!Yap_unify(ARG1, Yap_MkStream(i) ) ) {
|
if (i < 0 ||!Yap_unify(ARG1, Yap_MkStream(i) ) ) {
|
||||||
@ -695,8 +694,10 @@ static Int stream_property(USES_REGS1) { /* Init current_stream */
|
|||||||
UNLOCK(GLOBAL_Stream[i].streamlock);
|
UNLOCK(GLOBAL_Stream[i].streamlock);
|
||||||
return false; // error...
|
return false; // error...
|
||||||
}
|
}
|
||||||
if (IsVarTerm(t2))
|
EXTRA_CBACK_ARG(2, 1) = MkIntTerm(i);
|
||||||
|
if (IsVarTerm(t2)) {
|
||||||
return cont_stream_property(PASS_REGS1);
|
return cont_stream_property(PASS_REGS1);
|
||||||
|
}
|
||||||
args = Yap_ArgListToVector(Deref(ARG2), stream_property_defs,
|
args = Yap_ArgListToVector(Deref(ARG2), stream_property_defs,
|
||||||
STREAM_PROPERTY_END);
|
STREAM_PROPERTY_END);
|
||||||
if (args == NULL) {
|
if (args == NULL) {
|
||||||
|
Reference in New Issue
Block a user