Fix indices/1 and rindex/1 in case of overlapping matches in strings

Fixes #2433
This commit is contained in:
Emanuele Torre authored and Nico Williams committed 2023-07-14 23:40:37 -05:00
1 parent bf4390562f
commit 1915b689f7
2 files changed
+5 -1

No files matched your search

+1 -1
View File
@@ -1296,7 +1296,7 @@ jv jv_string_indexes(jv j, jv k) {
p = jstr;
while ((p = _jq_memmem(p, (jstr + jlen) - p, idxstr, idxlen)) != NULL) {
a = jv_array_append(a, jv_number(p - jstr));
p += idxlen;
p++;
}
}
jv_free(j);
+4
View File
@@ -1265,6 +1265,10 @@ split("")
"a,bc,def,ghij,klmno"
[1,13,[1,4,8,13]]
[ index("aba"), rindex("aba"), indices("aba") ]
"xababababax"
[1,7,[1,3,5,7]]
indices(1)
[0,1,1,2,3,4,1,5]
[1,2,6]