Skip to content

Commit 7591f49

Browse files
committed
FEAT: allow FIND binary! char!
related to: Oldes/Rebol-issues#1159 Oldes/Rebol-issues#1161
1 parent 0f67daf commit 7591f49

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

src/core/t-string.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ static struct {
617617

618618
if (IS_BINARY(value)) {
619619
args |= AM_FIND_CASE;
620-
if (!IS_BINARY(arg) && !IS_INTEGER(arg) && !IS_BITSET(arg)) Trap0(RE_NOT_SAME_TYPE);
620+
if (!IS_BINARY(arg) && !IS_INTEGER(arg) && !IS_BITSET(arg) && !IS_CHAR(arg)) Trap0(RE_NOT_SAME_TYPE);
621621
if (IS_INTEGER(arg)) {
622622
if (VAL_INT64(arg) < 0 || VAL_INT64(arg) > 255) Trap_Range(arg);
623623
len = 1;

src/tests/units/series-test.r3

+22
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,33 @@ Rebol [
2727
;@@ https://github.com/Oldes/Rebol-issues/issues/237
2828
--assert "23" = find "123" 2
2929

30+
--test-- "FIND string! binary!"
31+
;@@ https://github.com/Oldes/Rebol-issues/issues/1159
32+
--assert "F00D" = find "id: F00D" #{F00D}
33+
--assert "F00D" = find "id: F00D" #{f00d}
34+
3035
--test-- "FIND binary! binary!"
36+
;@@ https://github.com/Oldes/Rebol-issues/issues/1161
3137
--assert #{0001} = find/match #{0001} #{00}
3238
--assert #{01} = find/match/tail #{0001} #{00}
3339
--assert #{02} = find #{000102} #{02}
3440
--assert #{} = find/tail #{000102} #{02}
41+
--assert none? find/match #{0001} #{01}
42+
--assert none? find/match/tail #{0001} #{01}
43+
--assert none? find #{000102} #{03}
44+
--assert none? find/tail #{000102} #{03}
45+
46+
--test-- "FIND binary! char!"
47+
;@@ https://github.com/Oldes/Rebol-issues/issues/1161
48+
--assert tail? find/tail #{0063} #"c"
49+
--assert tail? find/tail #{0063} #"^(63)"
50+
--assert tail? find/tail #{00FF} #"^(ff)"
51+
--assert none? find/tail #{0063} #"C"
52+
--assert none? find/tail #{0063} #"^(700)"
53+
54+
--test-- "FIND binary! integer!"
55+
--assert tail? find/tail #{0063} 99
56+
--assert error? try [find/tail #{0063} 700]
3557

3658
--test-- "FIND string! tag!"
3759
;@@ https://github.com/Oldes/Rebol-issues/issues/1160

0 commit comments

Comments
 (0)