Skip to content

Commit

Permalink
FIX: FIND/TAIL not working properly with CHAR as an argument to search
Browse files Browse the repository at this point in the history
(regression from previous FIND/MATCH changes)
  • Loading branch information
Oldes committed Jan 14, 2019
1 parent 30f9d8f commit 365be4a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/core/s-find.c
Original file line number Diff line number Diff line change
Expand Up @@ -523,8 +523,10 @@
c1 = GET_ANY_CHAR(ser, index);
if (uncase && c1 < UNICODE_CASES) c1 = LO_CASE(c1);

if (c1 == c2) return index;

if (c1 == c2) {
if GET_FLAG(flags, ARG_FIND_TAIL - 1) index++;
return index;
}
if GET_FLAG(flags, ARG_FIND_MATCH-1) break;
}

Expand Down
11 changes: 11 additions & 0 deletions src/tests/units/series-test.r3
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,17 @@ Rebol [
; --assert none? find/part "abcd" "bc" 2
; --assert none? find/part/any "abcd" "*c" 2

--test-- "FIND char in string"
str: "a,b"
--assert ",b" = find str #","
--assert ",b" = find/reverse tail str #","
--assert "b" = find/tail str #","
--assert "b" = find/tail/reverse tail str #","
--assert "b" = find str #"b"
--assert "b" = find str #"B"
--assert "b" = find/case str #"b"
--assert none? find/case str #"B"

--test-- https://github.com/rebol/rebol-issues/issues/66
--assert none? find/skip [1 2 3 4 5 6] 2 3

Expand Down

0 comments on commit 365be4a

Please sign in to comment.