From 8b2312daf7d075c5d56e8b2b3cba5dabbf4de540 Mon Sep 17 00:00:00 2001 From: Vitor Santos Costa Date: Sun, 13 Feb 2011 01:29:25 +0000 Subject: [PATCH] close must be last to be proted, otherwise YAP gets confused about who owns the stream. --- C/write.c | 4 ++++ pl/boot.yap | 6 ++++-- pl/consult.yap | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/C/write.c b/C/write.c index becfa00c0..95e7e3f06 100755 --- a/C/write.c +++ b/C/write.c @@ -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; diff --git a/pl/boot.yap b/pl/boot.yap index 615ac082d..02f295e1c 100755 --- a/pl/boot.yap +++ b/pl/boot.yap @@ -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) :- diff --git a/pl/consult.yap b/pl/consult.yap index 06b72753f..e6ac969b3 100755 --- a/pl/consult.yap +++ b/pl/consult.yap @@ -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)) ),