Issue #19424: PyUnicode_CompareWithASCIIString() normalizes memcmp() result

to -1, 0, 1
This commit is contained in:
Victor Stinner 2013-11-04 11:28:26 +01:00
parent f0c7b2af05
commit 21ea21ef6d
1 changed files with 6 additions and 2 deletions

View File

@ -10584,8 +10584,12 @@ PyUnicode_CompareWithASCIIString(PyObject* uni, const char* str)
len = Py_MIN(len1, len2);
cmp = memcmp(data, str, len);
if (cmp != 0)
return cmp;
if (cmp != 0) {
if (cmp < 0)
return -1;
else
return 1;
}
if (len1 > len2)
return 1; /* uni is longer */
if (len2 > len1)