Skip to content

Commit cfe4ffc

Browse files
committed
FIX: find/same not working when used a block as a key
resolves: Oldes/Rebol-issues#2473
1 parent 00a6c8f commit cfe4ffc

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/core/t-block.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,11 @@ static void No_Nones_Or_Logic(REBVAL *arg) {
139139
cnt = 0;
140140
value = BLK_SKIP(series, index);
141141
for (val = VAL_BLK_DATA(target); NOT_END(val); val++, value++) {
142-
if (0 != Cmp_Value(value, val, (REBOOL)(flags & AM_FIND_CASE))) break;
142+
if ((flags & AM_FIND_SAME)) {
143+
if (0 == Compare_Values(value, val, 3))
144+
break;
145+
}
146+
else if (0 != Cmp_Value(value, val, (REBOOL)(flags & AM_FIND_CASE))) break;
143147
if (++cnt >= len) {
144148
return index;
145149
}

src/tests/units/series-test.r3

+17
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,23 @@ Rebol [
275275
--assert 2 = index? find/same [1.0 1] 1
276276
--assert 1 = index? find/same [1.0 1] 1.0
277277

278+
--test-- "FIND block! block!"
279+
;@@ https://github.com/Oldes/Rebol-issues/issues/2473
280+
blk: [1.0 3 1 3 1.0 2.0 1 2]
281+
--assert 5 = index? find blk [1 2]
282+
--assert 1 = index? find blk [1 3]
283+
--assert 5 = index? find blk [1.0 2]
284+
--assert 7 = index? find/same blk [1 2]
285+
--assert 3 = index? find/same blk [1 3]
286+
--assert none? find/same blk [1.0 2]
287+
a: "a" b: "b" blk: reduce ["a" "b" a b]
288+
--assert 1 = index? find blk reduce [a b]
289+
--assert 1 = index? find blk reduce ["a" "b"]
290+
--assert 3 = index? find/same blk reduce [a b]
291+
--assert none? find/same blk reduce [a "b"]
292+
--assert none? find/same blk reduce ["a" "b"]
293+
294+
278295
--test-- "FIND/SAME in string!"
279296
--assert "AbcdAe" = find/same "aAbcdAe" "A"
280297
--assert "Ae" = find/same/last "aAbcdAe" "A"

0 commit comments

Comments
 (0)