Skip to content
Myr

Fix string multiplication with a value between 0.0 and 1.0

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

This commit fixes a regression of 6306ac89667c.

authored by itchyny · committed by Nico Williams · parent af57893 · Browse files · 2 files+6 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+6 added−1 removed

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

2 files+6 added−1 removed

modified:src/builtin.c+2 added-1 removed
358 unmodified lines
359 str = b;360 num = a;361 }362 jv res = jv_null();363 int n = jv_number_value(num);363 double d = jv_number_value(num);364 int n = 0.0 < d && d < 1.0 ? 1 : d;365 if (n > 0) {366 size_t alen = jv_string_length_bytes(jv_copy(str));367 res = jv_string_empty(alen * n);368 for (; n > 0; n--) {
1493 unmodified lines
modified:tests/jq.test+4 added
1282 unmodified lines
1283[.[] * 3]1284["a", "ab", "abc"]1285["aaa", "ababab", "abcabcabc"]12861287[.[] * "abc"]1288[-1.0, -0.5, 0.0, 0.5, 1.0, 1.5, 3.7, 10.0]1289[null,null,null,"abc","abc","abc","abcabcabc","abcabcabcabcabcabcabcabcabcabc"]12901291[.[] / ","]1292["a, bc, def, ghij, jklmn, a,b, c,d, e,f", "a,b,c,d, e,f,g,h"]1293[["a"," bc"," def"," ghij"," jklmn"," a","b"," c","d"," e","f"],["a","b","c","d"," e","f","g","h"]]1294
465 unmodified lines