Mercurial > cpython-lru_cache-weakref
diff Objects/unicodeobject.c @ 64081:b089ed576b13
Issue #9425: Create Py_UNICODE_strncmp() function
The code is based on strncmp() of the libiberty library,
function in the public domain.
| author | Victor Stinner <victor.stinner@haypocalc.com> |
|---|---|
| date | Mon, 16 Aug 2010 22:03:11 +0000 |
| parents | 50c0dbaeaa04 |
| children | 80f98af17def |
line wrap: on
line diff
--- a/Objects/unicodeobject.c Mon Aug 16 20:50:03 2010 +0000 +++ b/Objects/unicodeobject.c Mon Aug 16 22:03:11 2010 +0000 @@ -9986,6 +9986,23 @@ return 0; } +int +Py_UNICODE_strncmp(const Py_UNICODE *s1, const Py_UNICODE *s2, size_t n) +{ + register Py_UNICODE u1, u2; + for (; n != 0; n--) { + u1 = *s1; + u2 = *s2; + if (u1 != u2) + return (u1 < u2) ? -1 : +1; + if (u1 == '\0') + return 0; + s1++; + s2++; + } + return 0; +} + Py_UNICODE* Py_UNICODE_strchr(const Py_UNICODE *s, Py_UNICODE c) {
