fix compare, reported by Cameron Patrick

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7023 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Marcelo Matus 2005-03-04 18:17:10 +00:00
commit e69c547289

View file

@ -129,11 +129,11 @@ PySwigObject_compare(PySwigObject *v, PySwigObject *w)
{
int c = strcmp(v->desc, w->desc);
if (c) {
return c;
return (c > 0) ? 1 : -1;
} else {
void *i = v->ptr;
void *j = w->ptr;
return (i < j) ? -1 : (i > j) ? 1 : 0;
return (i < j) ? -1 : ((i > j) ? 1 : 0);
}
}
@ -310,11 +310,11 @@ PySwigPacked_compare(PySwigPacked *v, PySwigPacked *w)
{
int c = strcmp(v->desc, w->desc);
if (c) {
return c;
return (c > 0) ? 1 : -1;
} else {
size_t i = v->size;
size_t j = w->size;
int s = (i < j) ? -1 : (i > j) ? 1 : 0;
int s = (i < j) ? -1 : ((i > j) ? 1 : 0);
return s ? s : strncmp((char *)v->pack, (char *)w->pack, 2*v->size);
}
}