diff --git a/H/Yatom.h b/H/Yatom.h index 084e86257..7891e082f 100755 --- a/H/Yatom.h +++ b/H/Yatom.h @@ -1869,32 +1869,52 @@ PredPropByAtomAndMod (Atom at, Term cur_mod) // report arity, name, and module for a predicate. // INLINE_ONLY inline EXTERN - UInt IndicatorOfPred(PredEntry * ap, const char *name, const char *module); + UInt IndicatorOfPred(PredEntry * ap, const char **name, const char **module); INLINE_ONLY inline EXTERN - UInt IndicatorOfPred(PredEntry * ap, const char *name, const char *module) + UInt IndicatorOfPred(PredEntry * ap, const char **name, const char **module) { - Term tmod = ap->ModuleOfPred; - if (!tmod) module = "prolog"; - else module = RepAtom(AtomOfTerm( tmod ))->StrOfAE; - if (ap->ModuleOfPred == IDB_MODULE && - ap->PredFlags & NumberDBPredFlag) { + if (module) { + Term tmod = ap->ModuleOfPred; + if (!tmod) *module = "prolog"; + else *module = RepAtom(AtomOfTerm( tmod ))->StrOfAE; + } + if (ap->ModuleOfPred == IDB_MODULE) { + if (ap->PredFlags & NumberDBPredFlag ) { + if (name) { Int id = ap->src.IndxId; char *s = (char *)malloc(16); - snprintf(s, 15, Int_FORMAT, id); - name = s; - return 0; - } - if (ap->ArityOfPE == 0) { + snprintf(s, 15, Int_FORMAT, id); + *name = s; + } + return 0; + } else if (ap->PredFlags & AtomDBPredFlag) { + if (name) { Atom At = (Atom)ap->FunctorOfPred; - name = RepAtom(At)->StrOfAE; - return 0; + *name = RepAtom(At)->StrOfAE; + } + return 0; + } else { + Functor f = ap->FunctorOfPred; + if (name) { + Atom At = NameOfFunctor(f); + *name = RepAtom(At)->StrOfAE; + } + return ArityOfFunctor(f); + } + } else { + if (name) { + if (ap->ArityOfPE == 0) { + Atom At = (Atom)ap->FunctorOfPred; + *name = RepAtom(At)->StrOfAE; } else { Functor f = ap->FunctorOfPred; Atom At = NameOfFunctor(f); - name = RepAtom(At)->StrOfAE; - return ArityOfFunctor(f); - } + *name = RepAtom(At)->StrOfAE; + } + } + return ap->ArityOfPE; + } } #if DEBUG_PELOCKING