mirror of
https://github.com/python/cpython.git
synced 2025-08-29 05:05:03 +00:00
Issue #9425: Create Py_UNICODE_strncmp() function
The code is based on strncmp() of the libiberty library, function in the public domain.
This commit is contained in:
parent
405038ac1c
commit
ef8d95c498
2 changed files with 38 additions and 6 deletions
|
@ -9986,6 +9986,23 @@ Py_UNICODE_strcmp(const Py_UNICODE *s1, const Py_UNICODE *s2)
|
|||
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)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue