From 8bccb86a43c06967ce5f975751ac7e81a5edea67 Mon Sep 17 00:00:00 2001 From: vsc Date: Tue, 10 Dec 2002 00:32:22 +0000 Subject: [PATCH] do some more checking and document. git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@719 b08c6af1-5177-4d33-ba66-4b1c6b8b522a --- C/dbase.c | 18 ++++++++++-------- docs/yap.tex | 9 ++++++++- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/C/dbase.c b/C/dbase.c index 89cfab894..6bbb13ef6 100644 --- a/C/dbase.c +++ b/C/dbase.c @@ -2054,8 +2054,8 @@ copy_attachments(CELL *ts) } #endif -static Term -GetDBKey(DBRef DBSP) +static int +UnifyDBKey(DBRef DBSP, PropFlags flags, Term t) { DBProp p = DBSP->Parent; Term t1, tf; @@ -2067,16 +2067,18 @@ GetDBKey(DBRef DBSP) } else { t1 = Yap_MkNewApplTerm(p->FunctorOfDB,p->ArityOfDB); } - if (p->KindOfPE & MkCode) { + if (p->KindOfPE & CodeDBBit && (flags & CodeDBBit)) { Term t[2]; t[1] = Yap_LookupModule(p->ModuleOfDB); t[2] = t1; tf = Yap_MkApplTerm(FunctorModule, 2, t); - } else { + } else if (!(flags & CodeDBBit)) { tf = t1; + } else { + return FALSE; } READ_UNLOCK(p->DBRWLock); - return(tf); + return(Yap_unify(tf,t)); } @@ -2946,7 +2948,7 @@ in_rded(void) if (ref == NULL || DEAD_REF(ref) || !Yap_unify(ARG2,GetDBTerm(ref)) - || !Yap_unify(ARG1,GetDBKey(ref))) { + || !UnifyDBKey(ref,0,ARG1)) { UNLOCK(ref->lock); cut_fail(); } else { @@ -2998,7 +3000,7 @@ in_rdedp(void) if (ref == NULL || DEAD_REF(ref) || !Yap_unify(ARG2,GetDBTerm(ref)) - || !Yap_unify(ARG1,GetDBKey(ref))) { + || !UnifyDBKey(ref,CodeDBBit,ARG1)) { UNLOCK(ref->lock); cut_fail(); } else { @@ -3041,7 +3043,7 @@ p_somercdedp(void) if (ref == NULL || DEAD_REF(ref) || !Yap_unify(ARG2,GetDBTerm(ref)) - || !Yap_unify(ARG1,GetDBKey(ref))) { + || !UnifyDBKey(ref,CodeDBBit,ARG1)) { UNLOCK(ref->lock); cut_fail(); } else { diff --git a/docs/yap.tex b/docs/yap.tex index 919b10617..67c187656 100644 --- a/docs/yap.tex +++ b/docs/yap.tex @@ -4968,7 +4968,14 @@ If a term equal to @var{T} up to variable renaming is stored under key @saindex recorded/3 @cyindex recorded/3 Searches in the internal database under the key @var{K}, a term that -unifies with @var{T} and whose reference matches @var{R}. +unifies with @var{T} and whose reference matches @var{R}. This +built-in may be used in one of two ways: +@itemize @bullet +@item @var{K} may be given, in this case the built-in will return all +elements of the internal data-base that match the key. +@item @var{R} may be given, if so returning the key and element that +match the reference. +@end itemize @item erase(+@var{R}) @findex erase/1