From 324833f84a206d42846b2e3836dd8d26656fab13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Manuel=20de=20Morais=20Santos=20Costa?= Date: Mon, 11 Jan 2010 15:44:43 +0000 Subject: [PATCH 1/4] =?UTF-8?q?fix=20excessive=20trimming=20in=20C-interfa?= =?UTF-8?q?ce=20for=20backtrackable=20predicates=20(obs=20from=20Jos=C3=A9?= =?UTF-8?q?=20Vieira).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- C/c_interface.c | 5 +++-- library/tries/tries.c | 1 - packages/chr | 2 +- packages/jpl | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/C/c_interface.c b/C/c_interface.c index dda827e18..5e68e7640 100644 --- a/C/c_interface.c +++ b/C/c_interface.c @@ -1027,13 +1027,14 @@ YAP_cut_up(void) cut_pt = B->cp_b; CUT_prune_to(cut_pt); + Yap_TrimTrail(); B = cut_pt; } -#else /* YAPOR */ +#else + Yap_TrimTrail(); B = B->cp_b; /* cut_fail */ #endif HB = B->cp_h; /* cut_fail */ - Yap_TrimTrail(); RECOVER_B(); } diff --git a/library/tries/tries.c b/library/tries/tries.c index 87d8966b1..111cd89c1 100644 --- a/library/tries/tries.c +++ b/library/tries/tries.c @@ -387,7 +387,6 @@ static int p_trie_traverse_init(void) { /* traverse trie */ if (!(data = trie_traverse_init((TrEntry) YAP_IntOfTerm(arg_trie), (TrData) YAP_IntOfTerm(arg_init_ref)))) { - printf("cut fail no init!!!\n"); YAP_cut_fail(); return FALSE; } diff --git a/packages/chr b/packages/chr index f6a790076..c325e4564 160000 --- a/packages/chr +++ b/packages/chr @@ -1 +1 @@ -Subproject commit f6a79007615bf46dc79712c41d61289834f28ba3 +Subproject commit c325e4564bb8d4e32c27f2061df85f13d315974e diff --git a/packages/jpl b/packages/jpl index eb6d27251..a2d2f0310 160000 --- a/packages/jpl +++ b/packages/jpl @@ -1 +1 @@ -Subproject commit eb6d27251c2548c25e6d37fff2a27a014caaa7aa +Subproject commit a2d2f03107eecd45462cd61a678035132cf06326 From 4670e456a5cb3e7fbfbb47e067626328f8fc2627 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Manuel=20de=20Morais=20Santos=20Costa?= Date: Tue, 12 Jan 2010 14:08:38 +0000 Subject: [PATCH 2/4] do not check for bom over binary files (obs from Nuno Fonseca). --- C/iopreds.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/C/iopreds.c b/C/iopreds.c index 7e93e55bc..7449f0917 100755 --- a/C/iopreds.c +++ b/C/iopreds.c @@ -2361,8 +2361,11 @@ p_open (void) } unix_upd_stream_info (st); if (opts != 0) { - if (opts & 2) + if (opts & 2) { st->status |= Binary_Stream_f; + /* we should not search for a byter order mark on a binary file */ + avoid_bom = TRUE; + } if (opts & 4) { if (st->status & (Tty_Stream_f|Socket_Stream_f|InMemory_Stream_f)) { Term ta[1], t; From bf52be1ece7a21a66ea43547ac9e4d5f1e21915d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Manuel=20de=20Morais=20Santos=20Costa?= Date: Tue, 12 Jan 2010 14:27:32 +0000 Subject: [PATCH 3/4] add extra options for SWI compatibility: notice, attributes/1 is not actually implemented within write yet! --- pl/yio.yap | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/pl/yio.yap b/pl/yio.yap index c0f674744..e6836643d 100644 --- a/pl/yio.yap +++ b/pl/yio.yap @@ -226,6 +226,8 @@ open(F,T,S,Opts) :- '$check_opt_sp'(A, G) :- '$do_error'(domain_error(stream_property,A),G). +'$check_opt_write'(attributes(T), G) :- !, + '$check_write_attributes'(T, G). '$check_opt_write'(cycles(T), G) :- !, '$check_cycles_arg'(T, G). '$check_opt_write'(quoted(T), G) :- !, @@ -236,6 +238,8 @@ open(F,T,S,Opts) :- '$check_write_numbervars_arg'(T, G). '$check_opt_write'(portrayed(T), G) :- !, '$check_write_portrayed'(T, G). +'$check_opt_write'(portray(T), G) :- !, + '$check_write_portrayed'(T, G). '$check_opt_write'(priority(T), G) :- !, '$check_priority_arg'(T, G). '$check_opt_write'(max_depth(T), G) :- !, @@ -316,6 +320,15 @@ open(F,T,S,Opts) :- '$check_read_syntax_errors_arg'(X,G) :- '$do_error'(domain_error(read_option,syntax_errors(X)),G). +'$check_write_attributes'(X, G) :- var(X), !, + '$do_error'(instantiation_error,G). +'$check_write_attributes'(ignore,_) :- !. +'$check_write_attributes'(dots,_) :- !. +'$check_write_attributes'(write,_) :- !. +'$check_write_attributes'(portray,_) :- !. +'$check_write_attributes'(X,G) :- + '$do_error'(domain_error(write_option,attributes(X)),G). + '$check_write_quoted_arg'(X, G) :- var(X), !, '$do_error'(instantiation_error,G). '$check_write_quoted_arg'(true,_) :- !. @@ -597,6 +610,14 @@ write_term(_,_,_). '$process_wt_opts'([portrayed(false)|Opts], Flag0, Flag, Priority, CallBacks) :- FlagI is Flag0 /\ 23, '$process_wt_opts'(Opts, FlagI, Flag, Priority, CallBacks). +'$process_wt_opts'([portray(true)|Opts], Flag0, Flag, Priority, CallBacks) :- + FlagI is Flag0 \/ 8, + '$process_wt_opts'(Opts, FlagI, Flag, Priority, CallBacks). +'$process_wt_opts'([portray(false)|Opts], Flag0, Flag, Priority, CallBacks) :- + FlagI is Flag0 /\ 23, + '$process_wt_opts'(Opts, FlagI, Flag, Priority, CallBacks). +'$process_wt_opts'([attributes(_)|Opts], Flag0, Flag, Priority, CallBacks) :- + '$process_wt_opts'(Opts, FlagI, Flag, Priority, CallBacks). '$process_wt_opts'([priority(Priority)|Opts], Flag0, Flag, Priority, CallBacks) :- '$process_wt_opts'(Opts, Flag0, Flag, _, CallBacks). '$process_wt_opts'([max_depth(D)|Opts], Flag0, Flag, Priority, [max_depth(D1,D0,D2)|CallBacks]) :- From d4b14648b02cfa6dcee254d37923e1c9ace0b760 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Manuel=20de=20Morais=20Santos=20Costa?= Date: Tue, 12 Jan 2010 14:58:48 +0000 Subject: [PATCH 4/4] fix confusion with SWI handling of C-backtrackable predicates. --- C/c_interface.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/C/c_interface.c b/C/c_interface.c index 5e68e7640..edcf5a05a 100644 --- a/C/c_interface.c +++ b/C/c_interface.c @@ -1341,10 +1341,12 @@ YAP_ExecuteFirst(PredEntry *pe, CPredicate exec_code) } else if (val == 1) { /* TRUE */ cut_succeed(); } else { - if ((val & REDO_PTR) == REDO_PTR) + /* + if ((val & REDO_PTR) == REDO_PTR) ctx->context = (int *)(val & ~REDO_PTR); - else + else ctx->context = (int *)((val & ~REDO_PTR)>>FRG_REDO_BITS); + */ return TRUE; } } else { @@ -1356,7 +1358,7 @@ YAP_ExecuteFirst(PredEntry *pe, CPredicate exec_code) Int YAP_ExecuteNext(PredEntry *pe, CPredicate exec_code) { - if (pe->PredFlags & SWIEnvPredFlag) { + if (pe->PredFlags & (SWIEnvPredFlag|CArgsPredFlag)) { Int val; CPredicateV codev = (CPredicateV)exec_code; struct foreign_context *ctx = (struct foreign_context *)(&EXTRA_CBACK_ARG(pe->ArityOfPE,1)); @@ -1372,10 +1374,12 @@ YAP_ExecuteNext(PredEntry *pe, CPredicate exec_code) } else if (val == 1) { /* TRUE */ cut_succeed(); } else { - if ((val & REDO_PTR) == REDO_PTR) + /* + if ((val & REDO_PTR) == REDO_PTR) ctx->context = (int *)(val & ~REDO_PTR); - else + else ctx->context = (int *)((val & ~REDO_PTR)>>FRG_REDO_BITS); + */ } return TRUE; }