Skip to content

Commit 365be4a

Browse files
committed
FIX: FIND/TAIL not working properly with CHAR as an argument to search
(regression from previous FIND/MATCH changes)
1 parent 30f9d8f commit 365be4a

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/core/s-find.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -523,8 +523,10 @@
523523
c1 = GET_ANY_CHAR(ser, index);
524524
if (uncase && c1 < UNICODE_CASES) c1 = LO_CASE(c1);
525525

526-
if (c1 == c2) return index;
527-
526+
if (c1 == c2) {
527+
if GET_FLAG(flags, ARG_FIND_TAIL - 1) index++;
528+
return index;
529+
}
528530
if GET_FLAG(flags, ARG_FIND_MATCH-1) break;
529531
}
530532

src/tests/units/series-test.r3

+11
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,17 @@ Rebol [
6767
; --assert none? find/part "abcd" "bc" 2
6868
; --assert none? find/part/any "abcd" "*c" 2
6969

70+
--test-- "FIND char in string"
71+
str: "a,b"
72+
--assert ",b" = find str #","
73+
--assert ",b" = find/reverse tail str #","
74+
--assert "b" = find/tail str #","
75+
--assert "b" = find/tail/reverse tail str #","
76+
--assert "b" = find str #"b"
77+
--assert "b" = find str #"B"
78+
--assert "b" = find/case str #"b"
79+
--assert none? find/case str #"B"
80+
7081
--test-- https://github.com/rebol/rebol-issues/issues/66
7182
--assert none? find/skip [1 2 3 4 5 6] 2 3
7283

0 commit comments

Comments
 (0)