diff --git a/C/c_interface.c b/C/c_interface.c index a7eb2f3ff..20db6ed61 100644 --- a/C/c_interface.c +++ b/C/c_interface.c @@ -10,8 +10,11 @@ * File: c_interface.c * * comments: c_interface primitives definition * * * -* Last rev: $Date: 2004-05-14 17:56:45 $,$Author: vsc $ * +* Last rev: $Date: 2004-05-17 21:42:08 $,$Author: vsc $ * * $Log: not supported by cvs2svn $ +* Revision 1.46 2004/05/14 17:56:45 vsc +* Yap_WriteBuffer +* * Revision 1.45 2004/05/14 17:11:30 vsc * support BigNums in interface * @@ -125,7 +128,6 @@ X_API Term *STD_PROTO(YAP_AddressFromSlot,(long)); X_API void STD_PROTO(YAP_PutInSlot,(long, Term)); X_API void STD_PROTO(YAP_RecoverSlots,(int)); X_API void STD_PROTO(YAP_Throw,(Term)); -X_API Term STD_PROTO(YAP_ModuleName,(int)); X_API void STD_PROTO(YAP_Halt,(int)); X_API Term *STD_PROTO(YAP_TopOfLocalStack,(void)); X_API void *STD_PROTO(YAP_Predicate,(Atom,unsigned long int,int)); diff --git a/C/cdmgr.c b/C/cdmgr.c index 117a85695..20635792f 100644 --- a/C/cdmgr.c +++ b/C/cdmgr.c @@ -11,8 +11,11 @@ * File: cdmgr.c * * comments: Code manager * * * -* Last rev: $Date: 2004-05-13 21:36:45 $,$Author: vsc $ * +* Last rev: $Date: 2004-05-17 21:42:09 $,$Author: vsc $ * * $Log: not supported by cvs2svn $ +* Revision 1.122 2004/05/13 21:36:45 vsc +* get rid of pesky debugging prints +* * Revision 1.121 2004/05/13 20:54:57 vsc * debugger fixes * make sure we always go back to current module, even during initizlization. @@ -3054,7 +3057,7 @@ p_system_pred(void) } pe = RepPredProp(Yap_GetPredPropByFunc(funt, mod)); } else if (IsPairTerm(t1)) { - return (TRUE); + return TRUE; } else return (FALSE); if (EndOfPAEntr(pe)) diff --git a/C/iopreds.c b/C/iopreds.c index 5b255b0da..8cbfb0529 100644 --- a/C/iopreds.c +++ b/C/iopreds.c @@ -208,17 +208,25 @@ unix_upd_stream_info (StreamDesc * s) return; } #endif /* USE_SOCKET */ -#if _MSC_VER || defined(__MINGW32__) +#if _MSC_VER || defined(__MINGW32__) { - if (_isatty(_fileno(s->u.file.file))) { + if ( +#ifdef __MINGW32__ + TRUE /* we cannot trust _isatty in MINGW */ +#else + _isatty(_fileno(s->u.file.file)) +#endif + ) { s->status |= Tty_Stream_f|Reset_Eof_Stream_f|Promptable_Stream_f; /* make all console descriptors unbuffered */ setvbuf(s->u.file.file, NULL, _IONBF, 0); } +#if _MSC_VER /* standard error stream should never be buffered */ - if (StdErrStream == s-Stream) { + else if (StdErrStream == s-Stream) { setvbuf(s->u.file.file, NULL, _IONBF, 0); } +#endif return; } #else diff --git a/docs/yap.tex b/docs/yap.tex index 2cb6321cd..e811e4102 100644 --- a/docs/yap.tex +++ b/docs/yap.tex @@ -7569,7 +7569,14 @@ allowed. @findex lookup/3 @snindex lookup/3 @cnindex lookup/3 -Lookup an element with key @var{Key} in the AVL tree +Lookup an element with key @var{Key} in the red-black tree +@var{T}, returning the value @var{Value}. + +@item lookupall(+@var{Key},-@var{Value},+@var{T}) +@findex lookupall/3 +@snindex lookupall/3 +@cnindex lookupall/3 +Lookup all elements with key @var{Key} in the red-black tree @var{T}, returning the value @var{Value}. @item new(?@var{T}) diff --git a/include/YapInterface.h b/include/YapInterface.h index 7f9222c6c..9efa130ab 100644 --- a/include/YapInterface.h +++ b/include/YapInterface.h @@ -325,8 +325,7 @@ extern X_API void PROTO(YAP_Throw,(YAP_Term)); /* int YAP_LookupModule() */ #define YAP_LookupModule(T) (T) -/* int YAP_ModuleName() */ -extern X_API YAP_Term PROTO(YAP_ModuleName,(int)); +#define YAP_ModuleName(mod) (mod) /* int YAP_Halt() */ extern X_API int PROTO(YAP_Halt,(int)); diff --git a/library/Makefile.in b/library/Makefile.in index 542d6a413..999994408 100644 --- a/library/Makefile.in +++ b/library/Makefile.in @@ -36,6 +36,7 @@ PROGRAMS= $(srcdir)/apply_macros.yap \ $(srcdir)/prandom.yap \ $(srcdir)/queues.yap \ $(srcdir)/random.yap \ + $(srcdir)/rbtrees.yap \ $(srcdir)/regexp.yap \ $(srcdir)/splay.yap \ $(srcdir)/system.yap \ diff --git a/library/rbtrees.yap b/library/rbtrees.yap index 9047674af..1f36779f0 100644 --- a/library/rbtrees.yap +++ b/library/rbtrees.yap @@ -14,6 +14,7 @@ :- module(rbtrees, [new/1, lookup/3, + lookupall/3, insert/4, delete/3]). @@ -25,8 +26,8 @@ new(K,V,black(Nil,K,V,Nil)) :- lookup(Key, Val, black([],_,_,[])) :- !, fail. lookup(Key, Val, Tree) :- - arg(Tree,2,KA), - compare(Cmp,KA,Key,Tree), + arg(2,Tree,KA), + compare(Cmp,KA,Key), lookup(Cmp,Key,Val,Tree). lookup(<, K, V, Tree) :- @@ -35,9 +36,27 @@ lookup(<, K, V, Tree) :- lookup(>, K, V, Tree) :- arg(4,Tree,NTree), lookup(K, V, NTree). -lookup(>, K, V, Tree) :- +lookup(=, K, V, Tree) :- arg(3,Tree,V). +lookupall(Key, Val, black([],_,_,[])) :- !, fail. +lookupall(Key, Val, Tree) :- + arg(2,Tree,KA), + compare(Cmp,KA,Key), + lookupall(Cmp,Key,Val,Tree). + +lookupall(>, K, V, Tree) :- + arg(4,Tree,NTree), + lookupall(K, V, NTree). +lookupall(=, K, V, Tree) :- + arg(3,Tree,V). +lookupall(=, K, V, Tree) :- + arg(1,Tree,NTree), + lookupall(K, V, NTree). +lookupall(<, K, V, Tree) :- + arg(1,Tree,NTree), + lookupall(K, V, NTree). + % % Tree insertion % diff --git a/pl/debug.yap b/pl/debug.yap index db2c69dc5..86480624d 100644 --- a/pl/debug.yap +++ b/pl/debug.yap @@ -316,9 +316,11 @@ debugging :- throw('$fail_spy'(GoalNumber)). '$loop_spy_event'(abort, _, _, _, _) :- !, throw(abort). -'$loop_spy_event'(Event, GoalNumber, G, Module, _) :- !, - '$trace'(exception(Event),G,Module,GoalNumber), - fail. +'$loop_spy_event'(Event, GoalNumber, G, Module, InControl) :- !, + '$system_catch'( + ('$trace'(exception(Event),G,Module,GoalNumber),fail), + Module,NewEvent, + '$loop_spy_event'(NewEvent, GoalNumber, G, Module, InControl)). '$loop_fail'(GoalNumber, G, Module, InControl) :- diff --git a/pl/setof.yap b/pl/setof.yap index 49ee3e9ae..5a5a0c121 100644 --- a/pl/setof.yap +++ b/pl/setof.yap @@ -122,7 +122,6 @@ bagof(Template, Generator, Bag) :- Key =.. ['$'|LFreeVars], '$init_db_queue'(Ref), '$findall_with_common_vars'(Key-Template, Generator, Ref, Bags0), -write(vsc:(Bags0,Bags)),nl, '$keysort'(Bags0, Bags), '$pick'(Bags, Key, Bag). % or we just have a list of answers