SWIG_TypeCompare was not working as commented - return values were 0,1 and not 1,0,-1. Although undocumented and not used anywhere within SWIG, it has been replaced with SWIG_TypeCmp to work as commented.

This commit is contained in:
William S Fulton 2013-03-04 07:32:40 +00:00
commit 670962cfe8

View file

@ -232,18 +232,18 @@ SWIG_TypeNameComp(const char *f1, const char *l1,
/* /*
Check type equivalence in a name list like <name1>|<name2>|... Check type equivalence in a name list like <name1>|<name2>|...
Return 0 if not equal, 1 if equal Return 0 if equal, -1 if nb < tb, 1 if nb > tb
*/ */
SWIGRUNTIME int SWIGRUNTIME int
SWIG_TypeEquiv(const char *nb, const char *tb) { SWIG_TypeCmp(const char *nb, const char *tb) {
int equiv = 0; int equiv = 1;
const char* te = tb + strlen(tb); const char* te = tb + strlen(tb);
const char* ne = nb; const char* ne = nb;
while (!equiv && *ne) { while (equiv != 0 && *ne) {
for (nb = ne; *ne; ++ne) { for (nb = ne; *ne; ++ne) {
if (*ne == '|') break; if (*ne == '|') break;
} }
equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; equiv = SWIG_TypeNameComp(nb, ne, tb, te);
if (*ne) ++ne; if (*ne) ++ne;
} }
return equiv; return equiv;
@ -251,24 +251,13 @@ SWIG_TypeEquiv(const char *nb, const char *tb) {
/* /*
Check type equivalence in a name list like <name1>|<name2>|... Check type equivalence in a name list like <name1>|<name2>|...
Return 0 if equal, -1 if nb < tb, 1 if nb > tb Return 0 if not equal, 1 if equal
*/ */
SWIGRUNTIME int SWIGRUNTIME int
SWIG_TypeCompare(const char *nb, const char *tb) { SWIG_TypeEquiv(const char *nb, const char *tb) {
int equiv = 0; return SWIG_TypeCmp(nb, tb) == 0 ? 1 : 0;
const char* te = tb + strlen(tb);
const char* ne = nb;
while (!equiv && *ne) {
for (nb = ne; *ne; ++ne) {
if (*ne == '|') break;
}
equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0;
if (*ne) ++ne;
}
return equiv;
} }
/* /*
Check the typename Check the typename
*/ */