Merge branch 'master' into debugger
Conflicts: pl/boot.yap
This commit is contained in:
commit
f431142ef4
14
C/arith2.c
14
C/arith2.c
@ -51,12 +51,7 @@ p_mod(Term t1, Term t2) {
|
||||
if (i2 == 0)
|
||||
return Yap_ArithError(EVALUATION_ERROR_ZERO_DIVISOR, t2, "X is " Int_FORMAT " mod 0", i1);
|
||||
if (i1 == Int_MIN && i2 == -1) {
|
||||
#ifdef USE_GMP
|
||||
return Yap_gmp_add_ints(Int_MAX, 1);
|
||||
#else
|
||||
return Yap_ArithError(EVALUATION_ERROR_INT_OVERFLOW, t1,
|
||||
"// /2 with %d and %d", i1, i2);
|
||||
#endif
|
||||
return MkIntTerm(0);
|
||||
}
|
||||
mod = i1%i2;
|
||||
if (mod && (mod ^ i2) < 0)
|
||||
@ -181,12 +176,7 @@ p_rem(Term t1, Term t2) {
|
||||
if (i2 == 0)
|
||||
return Yap_ArithError(EVALUATION_ERROR_ZERO_DIVISOR, t2, "X is " Int_FORMAT " rem 0", i1);
|
||||
if (i1 == Int_MIN && i2 == -1) {
|
||||
#ifdef USE_GMP
|
||||
return Yap_gmp_add_ints(Int_MAX, 1);
|
||||
#else
|
||||
return Yap_ArithError(EVALUATION_ERROR_INT_OVERFLOW, t1,
|
||||
"rem/2 with %d and %d", i1, i2);
|
||||
#endif
|
||||
return MkIntTerm(0);
|
||||
}
|
||||
RINT(i1%i2);
|
||||
}
|
||||
|
@ -46,6 +46,8 @@
|
||||
#define PLVERSION YAP_VERSION
|
||||
#define PLNAME "yap"
|
||||
|
||||
#define SWIP "swi_"
|
||||
|
||||
/* try not to pollute the SWI space */
|
||||
#ifdef P
|
||||
#undef P
|
||||
|
@ -1227,14 +1227,13 @@ case "$target_os" in
|
||||
then
|
||||
YAPLIB_LD="\$(CC) -shared"
|
||||
EXTRA_LIBS_FOR_DLLS="$EXTRA_LIBS_FOR_DLLS -L\$(abs_top_builddir) -lYap -Wl,-R,\$(YAPLIBDIR) -Wl,-R,\$(LIBDIR)"
|
||||
INSTALL_ENV="LD_LIBRARY_PATH=\$(DESTDIR)\$(LIBDIR):\$(DESTDIR)\$(YAPLIBDIR): YAPSHAREDIR=\$(DESTDIR)\$(SHAREDIR) YAPLIBDIR=\$(DESTDIR)\$(YAPLIBDIR)"
|
||||
PRE_INSTALL_ENV="LD_LIBRARY_PATH=\$(abs_top_builddir)"
|
||||
INSTALL_ENV="LD_LIBRARY_PATH=:\$(DESTDIR)\$(LIBDIR):\$(DESTDIR)\$(YAPLIBDIR): YAPSHAREDIR=\$(DESTDIR)\$(SHAREDIR) YAPLIBDIR=\$(DESTDIR)\$(YAPLIBDIR)"
|
||||
else
|
||||
YAPLIB_LD="\$(CC)"
|
||||
EXTRA_LIBS_FOR_DLLS="$EXTRA_LIBS_FOR_DLLS -Wl,-R,\$(YAPLIBDIR) -Wl,-R,\$(LIBDIR)"
|
||||
INSTALL_ENV="YAPSHAREDIR=\$(DESTDIR)\$(SHAREDIR) YAPLIBDIR=\$(DESTDIR)\$(YAPLIBDIR)"
|
||||
PRE_INSTALL_ENV=""
|
||||
fi
|
||||
PRE_INSTALL_ENV="LD_LIBRARY_PATH=$LD_LIBRARY_PATH:\$(abs_top_builddir):\$(abs_top_builddir)/lib/sys"
|
||||
;;
|
||||
*sunos4*)
|
||||
M4="/usr/5bin/m4"
|
||||
|
@ -88,7 +88,77 @@ check_int(I, Inp) :-
|
||||
throw(error(type_error(integer,I),Inp)).
|
||||
|
||||
% file operations
|
||||
% file operations
|
||||
|
||||
delete_file(IFile) :-
|
||||
true_file_name(IFile, File),
|
||||
delete_file(File, off, on, off).
|
||||
|
||||
delete_file(IFile, Opts) :-
|
||||
true_file_name(IFile, File),
|
||||
process_delete_file_opts(Opts, Dir, Recurse, Ignore, delete_file(File,Opts)),
|
||||
delete_file(File, Dir, Recurse, Ignore).
|
||||
|
||||
process_delete_file_opts(V, _, _, _, T) :- var(V), !,
|
||||
throw(error(instantiation_error,T)).
|
||||
process_delete_file_opts([], off, off, off, _) :- !.
|
||||
process_delete_file_opts([V|_], _, _, _, T) :- var(V), !,
|
||||
throw(error(instantiation_error,T)).
|
||||
process_delete_file_opts([directory|Opts], on, Recurse, Ignore, T) :- !,
|
||||
process_delete_file_opts(Opts, _, Recurse, Ignore, T).
|
||||
process_delete_file_opts([recursive|Opts], Dir, on, Ignore, T) :- !,
|
||||
process_delete_file_opts(Opts, Dir, _, Ignore, T).
|
||||
process_delete_file_opts([ignore|Opts], Dir, Recurse, on, T) :- !,
|
||||
process_delete_file_opts(Opts, Dir, Recurse, _, T).
|
||||
process_delete_file_opts(Opts, _, _, _, T) :-
|
||||
throw(error(domain_error(delete_file_option,Opts),T)).
|
||||
|
||||
delete_file(IFile, Dir, Recurse, Ignore) :-
|
||||
true_file_name(IFile, File),
|
||||
file_property(File, Type, _, _, _Permissions, _, Ignore),
|
||||
delete_file(Type, File, Dir, Recurse, Ignore).
|
||||
|
||||
delete_file(N, File, _Dir, _Recurse, Ignore) :- number(N), !, % error.
|
||||
handle_system_error(N, Ignore, delete_file(File)).
|
||||
delete_file(directory, File, Dir, Recurse, Ignore) :-
|
||||
delete_directory(Dir, File, Recurse, Ignore).
|
||||
delete_file(_, File, _Dir, _Recurse, Ignore) :-
|
||||
unlink_file(File, Ignore).
|
||||
|
||||
unlink_file(IFile, Ignore) :-
|
||||
true_file_name(IFile, File),
|
||||
unlink(File, N),
|
||||
handle_system_error(N, Ignore, delete_file(File)).
|
||||
|
||||
delete_directory(on, File, _Recurse, Ignore) :-
|
||||
rm_directory(File, Ignore).
|
||||
delete_directory(off, File, Recurse, Ignore) :-
|
||||
delete_directory(Recurse, File, Ignore).
|
||||
|
||||
rm_directory(File, Ignore) :-
|
||||
rmdir(File, Error),
|
||||
handle_system_error(Error, Ignore, delete_file(File)).
|
||||
|
||||
delete_directory(on, File, Ignore) :-
|
||||
directory_files(File, FileList, Ignore),
|
||||
path_separator(D),
|
||||
atom_concat(File, D, FileP),
|
||||
delete_dirfiles(FileList, FileP, Ignore),
|
||||
rmdir(File, Ignore).
|
||||
|
||||
delete_dirfiles([], _, _).
|
||||
delete_dirfiles(['.'|Fs], File, Ignore) :- !,
|
||||
delete_dirfiles(Fs, File, Ignore).
|
||||
delete_dirfiles(['..'|Fs], File, Ignore) :- !,
|
||||
delete_dirfiles(Fs, File, Ignore).
|
||||
delete_dirfiles([F|Fs], File, Ignore) :-
|
||||
atom_concat(File,F,TrueF),
|
||||
delete_file(TrueF, off, on, Ignore),
|
||||
delete_dirfiles(Fs, File, Ignore).
|
||||
|
||||
directory_files(File, FileList, Ignore) :-
|
||||
list_directory(File, FileList, Error),
|
||||
handle_system_error(Error, Ignore, directory_files(File, FileList)).
|
||||
|
||||
handle_system_error(Error, _Ignore, _G) :- var(Error), !.
|
||||
handle_system_error(Error, off, G) :- atom(Error), !,
|
||||
|
@ -828,7 +828,7 @@ PRED_IMPL("tmp_file_stream", 3, tmp_file_stream, 0)
|
||||
|
||||
|
||||
static
|
||||
PRED_IMPL("delete_file", 1, delete_file, 0)
|
||||
PRED_IMPL("swi_delete_file", 1, delete_file, 0)
|
||||
{ PRED_LD
|
||||
char *n;
|
||||
atom_t aname;
|
||||
@ -1125,7 +1125,7 @@ BeginPredDefs(files)
|
||||
PRED_DEF("exists_directory", 1, exists_directory, 0)
|
||||
PRED_DEF("tmp_file", 2, tmp_file, 0)
|
||||
PRED_DEF("tmp_file_stream", 3, tmp_file_stream, 0)
|
||||
PRED_DEF("delete_file", 1, delete_file, 0)
|
||||
PRED_DEF("swi_delete_file", 1, delete_file, 0)
|
||||
PRED_DEF("delete_directory", 1, delete_directory, 0)
|
||||
PRED_DEF("make_directory", 1, make_directory, 0)
|
||||
PRED_DEF("same_file", 2, same_file, 0)
|
||||
|
25
pl/boot.yap
25
pl/boot.yap
@ -493,11 +493,11 @@ true :- true.
|
||||
'$write_answer'(NV, LGs, Written),
|
||||
'$write_query_answer_true'(Written),
|
||||
(
|
||||
'$prompt_alternatives_on'(determinism), CP = NCP, DCP = 0 ->
|
||||
nl(user_error),
|
||||
'$prompt_alternatives_on'(determinism), CP = NCP, DCP = 0
|
||||
->
|
||||
format(user_error, '.~n', []),
|
||||
!
|
||||
;
|
||||
|
||||
'$another',
|
||||
!
|
||||
),
|
||||
@ -511,13 +511,10 @@ true :- true.
|
||||
'$do_yes_no'(G,M),
|
||||
'$delayed_goals'(G, [], NV, LGs, _),
|
||||
'$write_answer'(NV, LGs, Written),
|
||||
(
|
||||
Written = []
|
||||
->
|
||||
!,
|
||||
'$present_answer'(C, yes)
|
||||
( Written = [] ->
|
||||
!,'$present_answer'(C, true)
|
||||
;
|
||||
'$another', !
|
||||
'$another', !
|
||||
),
|
||||
fail.
|
||||
'$yes_no'(_,_) :-
|
||||
@ -544,9 +541,9 @@ true :- true.
|
||||
|
||||
'$out_neg_answer' :-
|
||||
( '$undefined'(print_message(_,_),prolog) ->
|
||||
'$present_answer'(user_error,"no~n", [])
|
||||
'$present_answer'(user_error,'false.~n', [])
|
||||
;
|
||||
print_message(help,no)
|
||||
print_message(help,false)
|
||||
),
|
||||
fail.
|
||||
|
||||
@ -557,7 +554,7 @@ true :- true.
|
||||
'$execute_outside_system_mode'(G, M).
|
||||
|
||||
'$write_query_answer_true'([]) :- !,
|
||||
format(user_error,'~ntrue',[]).
|
||||
format(user_error,'true',[]).
|
||||
'$write_query_answer_true'(_).
|
||||
|
||||
|
||||
@ -577,7 +574,7 @@ true :- true.
|
||||
write_term(user_error,Answ,Opts) ;
|
||||
format(user_error,'~w',[Answ])
|
||||
),
|
||||
format(user_error,'~n', []).
|
||||
format(user_error,'.~n', []).
|
||||
|
||||
'$another' :-
|
||||
format(user_error,' ? ',[]),
|
||||
@ -586,7 +583,7 @@ true :- true.
|
||||
|
||||
'$do_another'(C) :-
|
||||
( C== 0'; -> skip(user_input,10), %'
|
||||
'$add_nl_outside_console',
|
||||
% '$add_nl_outside_console',
|
||||
fail
|
||||
;
|
||||
C== 10 -> '$add_nl_outside_console',
|
||||
|
@ -37,6 +37,8 @@ file_position(FileName,LN,MsgCodes) -->
|
||||
|
||||
generate_message(halt) --> !,
|
||||
['YAP execution halted'].
|
||||
generate_message(false) --> !,
|
||||
['false.'].
|
||||
generate_message('$abort') --> !,
|
||||
['YAP execution aborted'].
|
||||
generate_message(abort(user)) --> !,
|
||||
|
Reference in New Issue
Block a user