commit a4775683c2d3e73b3d3f35383cdf088e8f563d35 Author: victor.stinner Date: Sun Aug 8 23:11:31 2010 +0000 Create Py_UNICODE_strrchr() function git-svn-id: svn+ssh://svn.python.org/python/branches/import_unicode@83867 6015fed2-1504-0410-9fe1-9d1591cc4771 diff --git a/Include/unicodeobject.h b/Include/unicodeobject.h index 1c13696..5d9307b 100644 --- a/Include/unicodeobject.h +++ b/Include/unicodeobject.h @@ -1630,6 +1630,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 diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 2901b7d..13b2608 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -10004,6 +10004,20 @@ 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 *start, *p; + start = s; + p = s + Py_UNICODE_strlen(s); + while (p != start) { + p--; + if (*p == c) + return (Py_UNICODE*)p; + } + return NULL; +} + #ifdef __cplusplus }