close must be last to be proted, otherwise YAP gets confused about who owns the stream.

This commit is contained in:
Vitor Santos Costa 2011-02-13 01:29:25 +00:00
parent 80f190bc8a
commit 8b2312daf7
3 changed files with 10 additions and 4 deletions

View File

@ -421,6 +421,10 @@ putAtom(Atom atom, int Quote_illegal, wrf writewch) /* writes an atom */
return;
}
#endif
if (IsBlob(atom)) {
wrputref(RepAtom(atom),1,writewch);
return;
}
if (IsWideAtom(atom)) {
wchar_t *ws = (wchar_t *)s;

View File

@ -1382,9 +1382,11 @@ cd(Dir) :- working_directory(_, Dir).
getcwd(Dir) :- working_directory(Dir, Dir).
close(Stream) :-
swi_close(Stream).
'$close'(Stream).
% swi_close(Stream). must be last
close(Stream, Options) :-
swi_close(Stream, Options).
'$close'(Stream).
% swi_close(Stream, Options). must be last
open(File, Type, Stream) :-
swi_open(File, Type, Stream).
open(File, Type, Stream, Opts) :-

View File

@ -159,8 +159,8 @@ load_files(Files,Opts) :-
'$do_lf'(Mod, user_input, InfLevel, CompilationMode,Imports,SkipUnixComments,CompMode,Reconsult,UseModule).
'$lf'(X, Mod, Call, InfLevel,_,Changed,CompilationMode,Imports,_,Enc,SkipUnixComments,CompMode,Reconsult,UseModule) :-
'$find_in_path'(X, Y, Call),
(X = 'arith.yap' -> start_low_level_trace ; true),
'$valid_encoding'(Encoding, Enc),
open(Y, read, Stream, [encoding(Encoding)]), !, % '$open'(Y, '$csult', Stream, 0, Enc, X)
'$set_changed_lfmode'(Changed),
'$start_lf'(X, Mod, Stream, InfLevel, CompilationMode, Imports, Changed,SkipUnixComments,CompMode,Reconsult,UseModule),
'$close'(Stream).
@ -434,7 +434,7 @@ initialization(G,OPT) :-
'$valid_encoding'(Encoding, Enc),
( open(Y, read, Stream, [encoding(Encoding)]), !, % '$open'(Y, '$csult', Stream, 0, Encoding, X), !,
print_message(Verbosity, loading(including, Y)),
'$loop'(Stream,Status), '$close'(Stream)
'$loop'(Stream,Status), close(Stream)
;
'$do_error'(permission_error(input,stream,Y),include(X))
),