Merge branch 'master' of ../yap-6.2
This commit is contained in:
commit
2dad416011
@ -3492,7 +3492,7 @@ CheckStream (Term arg, int kind, char *msg)
|
||||
if (kind & SWI_Stream_f) {
|
||||
struct io_stream *swi_stream;
|
||||
|
||||
if (Yap_get_stream_handle(arg, &swi_stream)) {
|
||||
if (Yap_get_stream_handle(arg, kind & Input_Stream_f, kind & Output_Stream_f, &swi_stream)) {
|
||||
sno = LookupSWIStream(swi_stream);
|
||||
return sno;
|
||||
}
|
||||
@ -3692,9 +3692,11 @@ Yap_CloseStreams (int loud)
|
||||
} else {
|
||||
free(Stream[sno].u.mem_string.buf);
|
||||
}
|
||||
} else if (!(Stream[sno].status & Null_Stream_f))
|
||||
} else if (Stream[sno].status & (SWI_Stream_f)) {
|
||||
SWIClose(Stream[sno].u.swi_stream.swi_ptr);
|
||||
} else if (!(Stream[sno].status & Null_Stream_f)) {
|
||||
YP_fclose (Stream[sno].u.file.file);
|
||||
else {
|
||||
} else {
|
||||
if (loud)
|
||||
fprintf (Yap_stderr, "%% YAP Error: while closing stream: %s\n", RepAtom (Stream[sno].u.file.name)->StrOfAE);
|
||||
}
|
||||
|
@ -461,7 +461,7 @@ void STD_PROTO(Yap_InitMYDDAS_TopLevelPreds,(void));
|
||||
/* yap2swi.c */
|
||||
void STD_PROTO(Yap_swi_install,(void));
|
||||
void STD_PROTO(Yap_InitSWIHash,(void));
|
||||
int STD_PROTO(Yap_get_stream_handle,(Term, void *));
|
||||
int STD_PROTO(Yap_get_stream_handle,(Term, int, int, void *));
|
||||
|
||||
/* ypsocks.c */
|
||||
void STD_PROTO(Yap_InitSockets,(void));
|
||||
|
@ -162,7 +162,7 @@
|
||||
AtomMfClause = Yap_FullLookupAtom("$mf_clause");
|
||||
AtomMinus = Yap_LookupAtom("-");
|
||||
AtomModify = Yap_LookupAtom("modify");
|
||||
AtomMultiFile = Yap_FullLookupAtom("$multi_file");
|
||||
AtomMultiFile = Yap_FullLookupAtom("$mf");
|
||||
AtomMutable = Yap_LookupAtom("mutable");
|
||||
AtomMutableVariable = Yap_FullLookupAtom("$mutable_variable");
|
||||
AtomMyddasDB = Yap_FullLookupAtom("$myddas_db");
|
||||
|
1
configure
vendored
1
configure
vendored
@ -8574,6 +8574,7 @@ main ()
|
||||
{
|
||||
jmp_buf RestartEnv;
|
||||
|
||||
_setjmp (RestartEnv);
|
||||
_longjmp (RestartEnv, 1);
|
||||
|
||||
;
|
||||
|
@ -1575,6 +1575,7 @@ AC_TRY_COMPILE(
|
||||
,
|
||||
jmp_buf RestartEnv;
|
||||
|
||||
_setjmp (RestartEnv);
|
||||
_longjmp (RestartEnv, 1);
|
||||
,
|
||||
yap_cv__setjmp=yes,yap_cv__setjmp=no)])
|
||||
|
@ -191,7 +191,8 @@ goal_expansion(is_stream(A), system:swi_is_stream(A)) :- swi_io.
|
||||
goal_expansion(set_stream(A,B),system:swi_set_stream(A,B)) :- swi_io.
|
||||
% careful: with_output_to/2 requires setting user_output, and this
|
||||
% confuses emulation.
|
||||
%goal_expansion(with_output_to(A,B),system:swi_with_output_to(A,B)) :- swi_io.
|
||||
goal_expansion(with_output_to(A,B),system:swi_with_output_to(A,NB)) :- swi_io,
|
||||
expand_goal(B, NB).
|
||||
goal_expansion(set_prolog_IO(A,B,C), system:swi_set_prolog_IO(A,B,C)) :- swi_io.
|
||||
goal_expansion(protocol(A), system:swi_protocol(A)) :- swi_io.
|
||||
goal_expansion(protocola(A), system:swi_protocola(A)) :- swi_io.
|
||||
|
@ -3098,13 +3098,20 @@ PL_YAP_InitSWIIO(struct SWI_IO *swio)
|
||||
SWIGetStream = swio->get_stream_handle;
|
||||
}
|
||||
|
||||
typedef int (*GetStreamF)(term_t, IOSTREAM **s);
|
||||
typedef int (*GetStreamF)(term_t, int, int, IOSTREAM **s);
|
||||
|
||||
int
|
||||
Yap_get_stream_handle(Term t0, void *s){
|
||||
term_t t = (term_t)YAP_InitSlot(t0);
|
||||
Yap_get_stream_handle(Term t0, int read_mode, int write_mode, void *s){
|
||||
term_t t;
|
||||
GetStreamF f = (GetStreamF)SWIGetStream;
|
||||
return (*f)(t,s);
|
||||
if (t0 == MkAtomTerm(AtomUserOut) && write_mode && !read_mode) {
|
||||
t = 0;
|
||||
} else if (t0 == MkAtomTerm(AtomUserIn) && !write_mode && read_mode) {
|
||||
t = 0;
|
||||
} else {
|
||||
t = (term_t)YAP_InitSlot(t0);
|
||||
}
|
||||
return (*f)(t, read_mode, write_mode, s);
|
||||
}
|
||||
|
||||
|
||||
|
@ -167,7 +167,7 @@ A MetaCall F "$call"
|
||||
A MfClause F "$mf_clause"
|
||||
A Minus N "-"
|
||||
A Modify N "modify"
|
||||
A MultiFile F "$multi_file"
|
||||
A MultiFile F "$mf"
|
||||
A Mutable N "mutable"
|
||||
A MutableVariable F "$mutable_variable"
|
||||
A MyddasDB F "$myddas_db"
|
||||
|
@ -4340,12 +4340,16 @@ static const PL_extension foreigns[] = {
|
||||
};
|
||||
|
||||
static int
|
||||
get_stream_handle_no_errors(term_t t, IOSTREAM **s)
|
||||
get_stream_handle_no_errors(term_t t, int read, int write, IOSTREAM **s)
|
||||
{ GET_LD
|
||||
if ( t == 0 )
|
||||
{ if (write) *s = getStream(Scurout);
|
||||
else *s = getStream(Scurout);
|
||||
return TRUE;
|
||||
}
|
||||
return get_stream_handle(t, s, SH_ALIAS);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
init_yap_extras(void)
|
||||
{
|
||||
@ -4357,7 +4361,7 @@ init_yap_extras(void)
|
||||
swiio.get_w = Sgetcode;
|
||||
swiio.put_w = Sputcode;
|
||||
swiio.flush_s = Sflush;
|
||||
swiio.close_s = Sclose;
|
||||
swiio.close_s = closeStream;
|
||||
swiio.get_stream_handle = get_stream_handle_no_errors;
|
||||
PL_YAP_InitSWIIO(&swiio);
|
||||
initCharTypes();
|
||||
|
Reference in New Issue
Block a user