/fix stream_prop; indenting
This commit is contained in:
parent
96bc776375
commit
87c58493d4
60
os/streams.c
60
os/streams.c
@ -145,9 +145,7 @@ int GetFreeStreamD(void) {
|
||||
|
||||
int Yap_GetFreeStreamD(void) { return GetFreeStreamD(); }
|
||||
|
||||
|
||||
static Term lineCount(int sno)
|
||||
{
|
||||
static Term lineCount(int sno) {
|
||||
Term tout;
|
||||
/* one has to be somewhat more careful because of terminals */
|
||||
if (GLOBAL_Stream[sno].status & Tty_Stream_f) {
|
||||
@ -166,8 +164,8 @@ static Term lineCount(int sno)
|
||||
else
|
||||
my_stream = GLOBAL_Stream[sno].name;
|
||||
for (i = 0; i < MaxStreams; i++) {
|
||||
if ((GLOBAL_Stream[i].status & ( Socket_Stream_f |
|
||||
Pipe_Stream_f | InMemory_Stream_f)) &&
|
||||
if ((GLOBAL_Stream[i].status &
|
||||
(Socket_Stream_f | Pipe_Stream_f | InMemory_Stream_f)) &&
|
||||
!(GLOBAL_Stream[i].status & (Free_Stream_f)) &&
|
||||
GLOBAL_Stream[i].name == my_stream)
|
||||
no += GLOBAL_Stream[i].linecount - 1;
|
||||
@ -207,14 +205,14 @@ static Int p_check_if_stream(USES_REGS1) { /* '$check_stream'(Stream) */
|
||||
return sno != -1;
|
||||
}
|
||||
|
||||
static Int is_input(int sno
|
||||
USES_REGS) { /* '$set_output'(+Stream,-ErrorMessage) */
|
||||
static Int
|
||||
is_input(int sno USES_REGS) { /* '$set_output'(+Stream,-ErrorMessage) */
|
||||
bool rc = GLOBAL_Stream[sno].status & Input_Stream_f;
|
||||
return rc;
|
||||
}
|
||||
|
||||
static Int is_output(int sno
|
||||
USES_REGS) { /* '$set_output'(+Stream,-ErrorMessage) */
|
||||
static Int
|
||||
is_output(int sno USES_REGS) { /* '$set_output'(+Stream,-ErrorMessage) */
|
||||
bool rc = GLOBAL_Stream[sno].status & (Output_Stream_f | Append_Stream_f);
|
||||
return rc;
|
||||
}
|
||||
@ -332,7 +330,6 @@ has_encoding(int sno,
|
||||
return Yap_unify(t2, MkAtomTerm(Yap_LookupAtom(s)));
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
found_eof(int sno,
|
||||
Term t2 USES_REGS) { /* '$set_output'(+Stream,-ErrorMessage) */
|
||||
@ -502,13 +499,10 @@ static bool do_stream_property(int sno,
|
||||
for (i = 0; i < STREAM_PROPERTY_END; i++) {
|
||||
if (args[i].used) {
|
||||
switch (i) {
|
||||
case STREAM_PROPERTY_ALIAS:
|
||||
{
|
||||
case STREAM_PROPERTY_ALIAS: {
|
||||
Term ta = args[STREAM_PROPERTY_ALIAS].tvalue;
|
||||
rc = rc & Yap_FetchStreamAlias(
|
||||
sno, ta PASS_REGS);
|
||||
}
|
||||
break;
|
||||
rc = rc & Yap_FetchStreamAlias(sno, ta PASS_REGS);
|
||||
} break;
|
||||
case STREAM_PROPERTY_BOM:
|
||||
rc = rc && has_bom(sno, args[STREAM_PROPERTY_BOM].tvalue PASS_REGS);
|
||||
break;
|
||||
@ -560,8 +554,8 @@ static bool do_stream_property(int sno,
|
||||
sno, args[STREAM_PROPERTY_POSITION].tvalue PASS_REGS);
|
||||
break;
|
||||
case STREAM_PROPERTY_REPOSITION:
|
||||
rc = rc &&
|
||||
has_reposition(sno, args[STREAM_PROPERTY_REPOSITION].tvalue PASS_REGS);
|
||||
rc = rc && has_reposition(
|
||||
sno, args[STREAM_PROPERTY_REPOSITION].tvalue PASS_REGS);
|
||||
break;
|
||||
case STREAM_PROPERTY_REPRESENTATION_ERRORS:
|
||||
rc = rc &&
|
||||
@ -586,19 +580,18 @@ static bool do_stream_property(int sno,
|
||||
}
|
||||
|
||||
static xarg *generate_property(int sno, Term t2,
|
||||
stream_property_choices_t p USES_REGS)
|
||||
{
|
||||
if (p == STREAM_PROPERTY_INPUT) Yap_unify(t2, MkAtomTerm(AtomInput));
|
||||
else if (p == STREAM_PROPERTY_OUTPUT) Yap_unify(t2, MkAtomTerm(AtomOutput));
|
||||
stream_property_choices_t p USES_REGS) {
|
||||
if (p == STREAM_PROPERTY_INPUT)
|
||||
Yap_unify(t2, MkAtomTerm(AtomInput));
|
||||
else if (p == STREAM_PROPERTY_OUTPUT)
|
||||
Yap_unify(t2, MkAtomTerm(AtomOutput));
|
||||
else {
|
||||
Functor f = Yap_MkFunctor(Yap_LookupAtom(stream_property_defs[p].name), 1);
|
||||
Yap_unify(t2, Yap_MkNewApplTerm(f, 1));
|
||||
}
|
||||
return Yap_ArgListToVector(t2, stream_property_defs,
|
||||
STREAM_PROPERTY_END);
|
||||
return Yap_ArgListToVector(t2, stream_property_defs, STREAM_PROPERTY_END);
|
||||
}
|
||||
|
||||
|
||||
static Int cont_stream_property(USES_REGS1) { /* current_stream */
|
||||
bool det;
|
||||
xarg *args;
|
||||
@ -615,8 +608,7 @@ static Int cont_stream_property(USES_REGS1) { /* current_stream */
|
||||
EXTRA_CBACK_ARG(2, 2) = MkIntTerm(p % STREAM_PROPERTY_END);
|
||||
// otherwise, just drop through
|
||||
} else {
|
||||
args = Yap_ArgListToVector(t2, stream_property_defs,
|
||||
STREAM_PROPERTY_END);
|
||||
args = Yap_ArgListToVector(t2, stream_property_defs, STREAM_PROPERTY_END);
|
||||
}
|
||||
if (args == NULL) {
|
||||
if (LOCAL_Error_TYPE != YAP_NO_ERROR) {
|
||||
@ -646,8 +638,8 @@ static Int cont_stream_property(USES_REGS1) { /* current_stream */
|
||||
if (p == STREAM_PROPERTY_END) {
|
||||
// move to next existing stream
|
||||
LOCK(GLOBAL_StreamDescLock);
|
||||
while (++i < MaxStreams && GLOBAL_Stream[i].status & Free_Stream_f)
|
||||
{}
|
||||
while (++i < MaxStreams && GLOBAL_Stream[i].status & Free_Stream_f) {
|
||||
}
|
||||
UNLOCK(GLOBAL_StreamDescLock);
|
||||
if (i < MaxStreams) {
|
||||
EXTRA_CBACK_ARG(2, 1) = MkIntTerm(i);
|
||||
@ -785,15 +777,15 @@ static bool do_set_stream(int sno,
|
||||
SetCloseOnAbort(
|
||||
sno, (args[SET_STREAM_CLOSE_ON_ABORT].tvalue == TermTrue));
|
||||
break;
|
||||
case SET_STREAM_ENCODING:
|
||||
{
|
||||
case SET_STREAM_ENCODING: {
|
||||
Term t2 = args[SET_STREAM_ENCODING].tvalue;
|
||||
Atom atEnc = AtomOfTerm(t2);
|
||||
GLOBAL_Stream[sno].encoding =
|
||||
enc_id(atEnc->StrOfAE, (GLOBAL_Stream[sno].status & HAS_BOM_f ? GLOBAL_Stream[sno].encoding :ENC_OCTET ) );
|
||||
enc_id(atEnc->StrOfAE, (GLOBAL_Stream[sno].status & HAS_BOM_f
|
||||
? GLOBAL_Stream[sno].encoding
|
||||
: ENC_OCTET));
|
||||
Yap_DefaultStreamOps(GLOBAL_Stream + sno);
|
||||
}
|
||||
break;
|
||||
} break;
|
||||
case SET_STREAM_EOF_ACTION: {
|
||||
Term t2 = args[SET_STREAM_EOF_ACTION].tvalue;
|
||||
if (t2 == TermError) {
|
||||
|
Reference in New Issue
Block a user