Skip to content

Commit

Permalink
Compilation dierectives to avoid editline/readline errors on windows.
Browse files Browse the repository at this point in the history
* On linux, swipl uses one of two libraries to manage command line
  input: library(editline) or library(readline). Those libraries are not
  found under windows (library(editline) depends on libedit which is not
  compiled for windows) and SWI-Prolog uses a different mechanism to
  manage command line input. Mettalog expects one of the two libraries
  to be loaded and that causes errors to be raised at startup, on
  windows. The current commit avoids loading the two missing libraries
  and allows mettalog to be loaded without errors on windows.
  • Loading branch information
stassa committed Dec 19, 2024
1 parent 6e669d2 commit 7a7470a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions prolog/metta_lang/metta_repl.pl
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@
% ?- save_history.
% true.
%
:- if(is_win64).
% Dummy to avoid errors on windows.
save_history.
:- else.
save_history :-
% Get the current input stream.
current_input(Input),
Expand All @@ -163,6 +167,7 @@
;
% Otherwise, do nothing.
true).
:- endif.

%! load_and_trim_history is det.
% Loads and trims the REPL history if needed, and installs readline support.
Expand Down Expand Up @@ -2038,12 +2043,16 @@
% This installs readline/editline support, allowing for line editing and history during input.
:- dynamic(is_installed_readline_editline/1).
:- volatile(is_installed_readline_editline/1).

:- if(is_win64).
:-else.
install_readline_editline :-
% Get the current input stream.
current_input(Input),
% Install readline support for the current input.
install_readline(Input),
!.
:- endif.

%! el_wrap_metta(+Input) is det.
%
Expand Down

0 comments on commit 7a7470a

Please sign in to comment.