lookup with max lentgth
This commit is contained in:
parent
849c96cb38
commit
ecaf6aa713
40
C/adtdefs.c
40
C/adtdefs.c
@ -296,6 +296,46 @@ Yap_LookupMaybeWideAtom(wchar_t *atom)
|
||||
return at;
|
||||
}
|
||||
|
||||
Atom
|
||||
Yap_LookupMaybeWideAtomWithLength(wchar_t *atom, size_t len)
|
||||
{ /* lookup atom in atom table */
|
||||
wchar_t *p = atom, c;
|
||||
size_t len0 = 0;
|
||||
Atom at;
|
||||
int wide = FALSE;
|
||||
|
||||
while ((c = *p++)) {
|
||||
if (c > 255) wide = TRUE;
|
||||
len0++;
|
||||
if (len0 == len) break;
|
||||
}
|
||||
if (p[0] == '\0' && wide) return LookupWideAtom(atom);
|
||||
else if (wide) {
|
||||
wchar_t *ptr, *ptr0;
|
||||
p = atom;
|
||||
ptr0 = ptr = (wchar_t *)Yap_AllocCodeSpace(sizeof(wchar_t)*(len+1));
|
||||
if (!ptr)
|
||||
return NIL;
|
||||
while (len--) {*ptr++ = *p++;}
|
||||
ptr[0] = '\0';
|
||||
at = LookupWideAtom(ptr0);
|
||||
Yap_FreeCodeSpace(ptr0);
|
||||
return at;
|
||||
} else {
|
||||
char *ptr, *ptr0;
|
||||
/* not really a wide atom */
|
||||
p = atom;
|
||||
ptr0 = ptr = Yap_AllocCodeSpace(len+1);
|
||||
if (!ptr)
|
||||
return NIL;
|
||||
while (len--) {*ptr++ = *p++;}
|
||||
ptr[0] = '\0';
|
||||
at = LookupAtom(ptr0);
|
||||
Yap_FreeCodeSpace(ptr0);
|
||||
return at;
|
||||
}
|
||||
}
|
||||
|
||||
Atom
|
||||
Yap_LookupAtom(char *atom)
|
||||
{ /* lookup atom in atom table */
|
||||
|
@ -31,6 +31,7 @@ int STD_PROTO(Yap_HasOp,(Atom));
|
||||
struct operator_entry *STD_PROTO(Yap_GetOpPropForAModuleHavingALock,(AtomEntry *, Term));
|
||||
Atom STD_PROTO(Yap_LookupAtom,(char *));
|
||||
Atom STD_PROTO(Yap_LookupMaybeWideAtom,(wchar_t *));
|
||||
Atom STD_PROTO(Yap_LookupMaybeWideAtomWithLength,(wchar_t *, size_t));
|
||||
Atom STD_PROTO(Yap_FullLookupAtom,(char *));
|
||||
void STD_PROTO(Yap_LookupAtomWithAddress,(char *,AtomEntry *));
|
||||
Prop STD_PROTO(Yap_NewPredPropByFunctor,(struct FunctorEntryStruct *, Term));
|
||||
|
Reference in New Issue
Block a user