From 8872fed811ecdf867794a8e7d226468771618f97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Santos=20Costa?= Date: Thu, 17 Jun 2010 00:24:19 +0100 Subject: [PATCH] make initialization/2 executable (SWI compatibility). add predicate on file suffix (SWI compatibility). --- pl/consult.yap | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/pl/consult.yap b/pl/consult.yap index 4e91efc57..c4ae22749 100755 --- a/pl/consult.yap +++ b/pl/consult.yap @@ -331,6 +331,9 @@ use_module(M,F,Is) :- fail. '$initialization'(_). +initialization(G,OPT) :- + '$initialization'(G,OPT). + '$initialization'(G,OPT) :- ( var(G) @@ -1024,3 +1027,41 @@ make :- fail. make. +file_name_extension(A1,A2,F) :- + var(F), + nonvar(A1), nonvar(A2), !, + atom_codes(A2, S2), + ( + S2 = [0'.|_] %' + -> + atom_concat(A1, A2, F) + ; + atom_concat([A1, '.', A2], F) + ). +file_name_extension(A1,A2,F) :- + var(F), !, + '$do_error'(instantiation_error,file_name_extension(A1,A2,F)). +file_name_extension(A1,A2,F) :- + nonvar(A2), !, + atom_codes(F, S), + atom_codes(A2, S2), + '$file_name_extension'(S, S1, E2), + ( + S2 = [0'.|E2] %' + -> + true + ; + S2 = E2 + ), + atom_codes(A1, S1). +file_name_extension(A1,A2,F) :- + atom_codes(F, S), + '$file_name_extension'(S, S1, S2), + atom_codes(A2, S2), + atom_codes(A1, S1). + +'$file_name_extension'(S, S1, S2) :- + lists:append(S1, [0'.|S2], S), + \+ lists:append(_, [0'.|_], S2), !. +'$file_name_extension'(S, S, []). +