]> granicus.if.org Git - python/commitdiff
Issue #23573: Fix bytes.rfind() and bytearray.rfind() on Windows
authorVictor Stinner <victor.stinner@gmail.com>
Wed, 25 Mar 2015 02:16:32 +0000 (03:16 +0100)
committerVictor Stinner <victor.stinner@gmail.com>
Wed, 25 Mar 2015 02:16:32 +0000 (03:16 +0100)
Windows has no memrchr() function.

This change is only a workaround, the optimization must be reenabled on other
platforms.

Objects/bytearrayobject.c
Objects/bytesobject.c

index 195c79f4016e1b64e3becfb494f110b3c1f782db..333f9c8bf00a8c1d84786ae804302a6b1cbcf766 100644 (file)
@@ -1166,7 +1166,8 @@ bytearray_find_internal(PyByteArrayObject *self, PyObject *args, int dir)
     ADJUST_INDICES(start, end, len);
     if (end - start < sub_len)
         res = -1;
-    else if (sub_len == 1) {
+    /* Issue #23573: FIXME, windows has no memrchr() */
+    else if (sub_len == 1 && dir > 0) {
         unsigned char needle = *sub;
         int mode = (dir > 0) ? FAST_SEARCH : FAST_RSEARCH;
         res = stringlib_fastsearch_memchr_1char(
index ae3c2895a01f0514a86e98086828ddbe5ceae7ec..4d6b3e4abe150d76acf203efbee82d5c9a209c36 100644 (file)
@@ -1938,7 +1938,8 @@ bytes_find_internal(PyBytesObject *self, PyObject *args, int dir)
     ADJUST_INDICES(start, end, len);
     if (end - start < sub_len)
         res = -1;
-    else if (sub_len == 1) {
+    /* Issue #23573: FIXME, windows has no memrchr() */
+    else if (sub_len == 1 && dir > 0) {
         unsigned char needle = *sub;
         int mode = (dir > 0) ? FAST_SEARCH : FAST_RSEARCH;
         res = stringlib_fastsearch_memchr_1char(