Skip to content
Myr

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

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Fixes #2433

authored by Emanuele Torre · committed by Nico Williams · parent bf43905 · Browse files · 2 files+5 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+5 added−1 removed

  • tests:+4 added−0 removed
  • other:+1 added−1 removed

2 files+5 added−1 removed

modified:src/jv.c+1 added-1 removed
1294 unmodified lines
1295 if (idxlen != 0) {1296 p = jstr;1297 while ((p = _jq_memmem(p, (jstr + jlen) - p, idxstr, idxlen)) != NULL) {1298 a = jv_array_append(a, jv_number(p - jstr));1299 p += idxlen;1299 p++;1300 }1301 }1302 jv_free(j);1303 jv_free(k);
688 unmodified lines
modified:tests/jq.test+4 added
1263 unmodified lines
1264[(index(","), rindex(",")), indices(",")]1265"a,bc,def,ghij,klmno"1266[1,13,[1,4,8,13]]12671268[ index("aba"), rindex("aba"), indices("aba") ]1269"xababababax"1270[1,7,[1,3,5,7]]12711272indices(1)1273[0,1,1,2,3,4,1,5]1274[1,2,6]1275
545 unmodified lines