Issue #9425: create Py_UNICODE_strrchr() function

This commit is contained in:
Victor Stinner 2010-08-10 16:37:20 +00:00
parent e1dd1747e8
commit 331ea92ade
2 changed files with 17 additions and 0 deletions

View File

@ -1622,6 +1622,10 @@ PyAPI_FUNC(Py_UNICODE*) Py_UNICODE_strchr(
const Py_UNICODE *s, Py_UNICODE c
);
PyAPI_FUNC(Py_UNICODE*) Py_UNICODE_strrchr(
const Py_UNICODE *s, Py_UNICODE c
);
#ifdef __cplusplus
}
#endif

View File

@ -9965,6 +9965,19 @@ Py_UNICODE_strchr(const Py_UNICODE *s, Py_UNICODE c)
return NULL;
}
Py_UNICODE*
Py_UNICODE_strrchr(const Py_UNICODE *s, Py_UNICODE c)
{
const Py_UNICODE *p;
p = s + Py_UNICODE_strlen(s);
while (p != s) {
p--;
if (*p == c)
return (Py_UNICODE*)p;
}
return NULL;
}
#ifdef __cplusplus
}