]> granicus.if.org Git - python/commitdiff
Issue #9425: create Py_UNICODE_strrchr() function
authorVictor Stinner <victor.stinner@haypocalc.com>
Tue, 10 Aug 2010 16:37:20 +0000 (16:37 +0000)
committerVictor Stinner <victor.stinner@haypocalc.com>
Tue, 10 Aug 2010 16:37:20 +0000 (16:37 +0000)
Include/unicodeobject.h
Objects/unicodeobject.c

index 6448cdab80d9fd6325b4dfa73deec7f87b64ceb9..7f5e8fdacfdb7e395f931b61d19afe536bc198e4 100644 (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
index f2d666de126995be90578cb622bff9ddb6e94b52..478f9a976e15e2249d2514e8d55860d44e45801c 100644 (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
 }