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; return;
} }
#endif #endif
if (IsBlob(atom)) {
wrputref(RepAtom(atom),1,writewch);
return;
}
if (IsWideAtom(atom)) { if (IsWideAtom(atom)) {
wchar_t *ws = (wchar_t *)s; wchar_t *ws = (wchar_t *)s;

View File

@ -1382,9 +1382,11 @@ cd(Dir) :- working_directory(_, Dir).
getcwd(Dir) :- working_directory(Dir, Dir). getcwd(Dir) :- working_directory(Dir, Dir).
close(Stream) :- close(Stream) :-
swi_close(Stream). '$close'(Stream).
% swi_close(Stream). must be last
close(Stream, Options) :- close(Stream, Options) :-
swi_close(Stream, Options). '$close'(Stream).
% swi_close(Stream, Options). must be last
open(File, Type, Stream) :- open(File, Type, Stream) :-
swi_open(File, Type, Stream). swi_open(File, Type, Stream).
open(File, Type, Stream, Opts) :- 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). '$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) :- '$lf'(X, Mod, Call, InfLevel,_,Changed,CompilationMode,Imports,_,Enc,SkipUnixComments,CompMode,Reconsult,UseModule) :-
'$find_in_path'(X, Y, Call), '$find_in_path'(X, Y, Call),
(X = 'arith.yap' -> start_low_level_trace ; true),
'$valid_encoding'(Encoding, Enc), '$valid_encoding'(Encoding, Enc),
open(Y, read, Stream, [encoding(Encoding)]), !, % '$open'(Y, '$csult', Stream, 0, Enc, X)
'$set_changed_lfmode'(Changed), '$set_changed_lfmode'(Changed),
'$start_lf'(X, Mod, Stream, InfLevel, CompilationMode, Imports, Changed,SkipUnixComments,CompMode,Reconsult,UseModule), '$start_lf'(X, Mod, Stream, InfLevel, CompilationMode, Imports, Changed,SkipUnixComments,CompMode,Reconsult,UseModule),
'$close'(Stream). '$close'(Stream).
@ -434,7 +434,7 @@ initialization(G,OPT) :-
'$valid_encoding'(Encoding, Enc), '$valid_encoding'(Encoding, Enc),
( open(Y, read, Stream, [encoding(Encoding)]), !, % '$open'(Y, '$csult', Stream, 0, Encoding, X), !, ( open(Y, read, Stream, [encoding(Encoding)]), !, % '$open'(Y, '$csult', Stream, 0, Encoding, X), !,
print_message(Verbosity, loading(including, Y)), 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)) '$do_error'(permission_error(input,stream,Y),include(X))
), ),