From 20b6816562c3513c7f55f6940864925d696af9c5 Mon Sep 17 00:00:00 2001 From: Markus Triska Date: Mon, 17 Jan 2022 20:09:50 +0100 Subject: [PATCH 1/2] MODIFIED: library(charsio): read_term_from_chars/2 is now called read_from_chars/2 This is for compatibility with SICStus Prolog and GNU Prolog. --- src/lib/charsio.pl | 10 +++++----- src/lib/files.pl | 2 +- src/lib/time.pl | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/lib/charsio.pl b/src/lib/charsio.pl index 85856810..3a944301 100644 --- a/src/lib/charsio.pl +++ b/src/lib/charsio.pl @@ -3,7 +3,7 @@ get_single_char/1, read_n_chars/3, read_line_to_chars/3, - read_term_from_chars/2, + read_from_chars/2, write_term_to_chars/3, chars_base64/3]). @@ -113,17 +113,17 @@ get_single_char(C) :- ). -read_term_from_chars(Chars, Term) :- +read_from_chars(Chars, Term) :- ( var(Chars) -> - instantiation_error(read_term_from_chars/2) + instantiation_error(read_from_chars/2) ; nonvar(Term) -> - throw(error(uninstantiation_error(Term), read_term_from_chars/2)) + throw(error(uninstantiation_error(Term), read_from_chars/2)) ; '$skip_max_list'(_, -1, Chars, Chars0), Chars0 == [], partial_string(Chars) -> true ; - type_error(complete_string, Chars, read_term_from_chars/2) + type_error(complete_string, Chars, read_from_chars/2) ), '$read_term_from_chars'(Chars, Term). diff --git a/src/lib/files.pl b/src/lib/files.pl index 6989cb46..9ee1c2b9 100644 --- a/src/lib/files.pl +++ b/src/lib/files.pl @@ -174,7 +174,7 @@ file_creation_time(File, T) :- file_time_(File, Which, T) :- file_must_exist(File, file_time_/3), '$file_time'(File, Which, T0), - read_term_from_chars(T0, T). + read_from_chars(T0, T). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/lib/time.pl b/src/lib/time.pl index 56e31fae..5da5bb59 100644 --- a/src/lib/time.pl +++ b/src/lib/time.pl @@ -49,11 +49,11 @@ :- use_module(library(error)). :- use_module(library(dcgs)). :- use_module(library(lists)). -:- use_module(library(charsio), [read_term_from_chars/2]). +:- use_module(library(charsio), [read_from_chars/2]). current_time(T) :- '$current_time'(T0), - read_term_from_chars(T0, T). + read_from_chars(T0, T). format_time([], _) --> []. format_time(['%','%'|Fs], T) --> !, "%", format_time(Fs, T). From 23adfef281c1158b6ebd84ef95c01a4b0f681190 Mon Sep 17 00:00:00 2001 From: Markus Triska Date: Mon, 17 Jan 2022 20:36:51 +0100 Subject: [PATCH 2/2] MODIFIED: library(charsio): read_n_chars/3 is now called get_n_chars/3 This is because "read" is associated with general Prolog terms. --- src/lib/charsio.pl | 4 ++-- src/lib/pio.pl | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/charsio.pl b/src/lib/charsio.pl index 3a944301..3ef732db 100644 --- a/src/lib/charsio.pl +++ b/src/lib/charsio.pl @@ -1,7 +1,7 @@ :- module(charsio, [char_type/2, chars_utf8bytes/2, get_single_char/1, - read_n_chars/3, + get_n_chars/3, read_line_to_chars/3, read_from_chars/2, write_term_to_chars/3, @@ -205,7 +205,7 @@ read_line_to_chars(Stream, Cs0, Cs) :- characters read. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -read_n_chars(Stream, N, Cs) :- +get_n_chars(Stream, N, Cs) :- can_be(integer, N), ( var(N) -> read_to_eof(Stream, Cs), diff --git a/src/lib/pio.pl b/src/lib/pio.pl index 38849a4b..db609aa6 100644 --- a/src/lib/pio.pl +++ b/src/lib/pio.pl @@ -21,7 +21,7 @@ :- use_module(library(freeze)). :- use_module(library(iso_ext), [setup_call_cleanup/3, partial_string/3]). :- use_module(library(lists), [member/2, maplist/2]). -:- use_module(library(charsio), [read_n_chars/3]). +:- use_module(library(charsio), [get_n_chars/3]). :- meta_predicate(phrase_from_file(2, ?)). :- meta_predicate(phrase_from_file(2, ?, ?)). @@ -62,7 +62,7 @@ reader_step(Stream, Pos, Xs0) :- set_stream_position(Stream, Pos), ( at_end_of_stream(Stream) -> Xs0 = [] - ; read_n_chars(Stream, 4096, Cs), + ; get_n_chars(Stream, 4096, Cs), partial_string(Cs, Xs0, Xs), stream_to_lazy_list(Stream, Xs) ).