mirror of
https://github.com/stedolan/jq.git
synced 2024-05-11 05:55:39 +00:00
Fix indices/1 and rindex/1 in case of overlapping matches in strings
Fixes #2433
This commit is contained in:
committed by
Nico Williams
parent
bf4390562f
commit
1915b689f7
2
src/jv.c
2
src/jv.c
@ -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);
|
||||
|
@ -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]
|
||||
|
Reference in New Issue
Block a user