From 8eeae7942c47181230a27e2cb0ba691fd54fa2be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Santos=20Costa?= Date: Fri, 11 Mar 2011 19:48:43 +0000 Subject: [PATCH] avoid loading memfile --- library/charsio.yap | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/library/charsio.yap b/library/charsio.yap index 6b4ed1a91..bc4490a3e 100644 --- a/library/charsio.yap +++ b/library/charsio.yap @@ -32,8 +32,6 @@ term_to_atom/2 ]). -:- use_module(library(memfile)). - :- meta_predicate(with_output_to_chars(0,?)). :- meta_predicate(with_output_to_chars(0,-,?)). :- meta_predicate(with_output_to_chars(0,-,?,?)). @@ -73,13 +71,17 @@ open_chars_stream(Codes, Stream) :- open_chars_stream(Codes, Stream, ''). open_chars_stream(Codes, Stream, Postfix) :- - new_memory_file(MF), - open_memory_file(MF, write, Out), + predicate_property(memory_file:open_memory_file(_,_,_),_), !, + memory_file:new_memory_file(MF), + memory_file:open_memory_file(MF, write, Out), format(Out, '~s~w', [Codes, Postfix]), close(Out), - open_memory_file(MF, read, Stream, + memory_file:open_memory_file(MF, read, Stream, [ free_on_close(true) ]). +open_chars_stream(Codes, Stream, Postfix) :- + ensure_loaded(library(memfile)), + open_chars_stream(Codes, Stream, Postfix). with_output_to_chars(Goal, Codes) :- with_output_to(codes(Codes), Goal).