From 51982bee4280740245f9d7de3d18fe51fedb18e6 Mon Sep 17 00:00:00 2001 From: Vitor Santos Costa Date: Mon, 1 Mar 2010 21:48:39 +0000 Subject: [PATCH] fix nb_current/2 --- C/globals.c | 12 +++++++++--- pl/utils.yap | 3 --- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/C/globals.c b/C/globals.c index cefa30833..dcefb9727 100644 --- a/C/globals.c +++ b/C/globals.c @@ -2613,10 +2613,16 @@ init_current_nb(void) { /* current_atom(?Atom) */ Term t1 = Deref(ARG1); if (!IsVarTerm(t1)) { - if (IsAtomTerm(t1)) - cut_succeed(); - else + if (IsAtomTerm(t1)) { + if (!FindGlobalEntry(AtomOfTerm(t1))) { + cut_fail(); + } else { + cut_succeed(); + } + } else { + Yap_Error(TYPE_ERROR_ATOM,t1,"nb_current"); cut_fail(); + } } READ_LOCK(HashChain[0].AERWLock); EXTRA_CBACK_ARG(1,1) = MkIntegerTerm((Int)GlobalVariables); diff --git a/pl/utils.yap b/pl/utils.yap index 98f23fe1e..89f9a414f 100644 --- a/pl/utils.yap +++ b/pl/utils.yap @@ -577,9 +577,6 @@ nth_instance(Key,Index,T,Ref) :- instance(Ref,T). nb_current(GlobalVariable, Val) :- - var(GlobalVariable), !, '$nb_current'(GlobalVariable), nb_getval(GlobalVariable, Val). -nb_current(GlobalVariable, Val) :- - nb_getval(GlobalVariable, Val).