diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | Src/params.c | 10 | ||||
-rw-r--r-- | Test/D06subscript.ztst | 5 |
3 files changed, 17 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog index 2ae9ccade..27c6fee98 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2022-12-02 Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp> + + * 51079: Src/params.c, Test/D06subscript.ztst: metafy sep in the + array subscript flag (s:sep:) so that sep can contain \0 etc. + 2022-11-23 Daniel Shahaf <d.s@daniel.shahaf.name> * unposted (cf. 51016): Test/C01arith.ztst: Add a test case diff --git a/Src/params.c b/Src/params.c index 27ea82298..f1fe38955 100644 --- a/Src/params.c +++ b/Src/params.c @@ -1262,7 +1262,6 @@ getarg(char **str, int *inv, Value v, int a2, zlong *w, /* first parse any subscription flags */ if (v->pm && (*s == '(' || *s == Inpar)) { int escapes = 0; - int waste; for (s++; *s != ')' && *s != Outpar && s != *str; s++) { switch (*s) { case 'r': @@ -1339,8 +1338,13 @@ getarg(char **str, int *inv, Value v, int a2, zlong *w, sav = *t; *t = '\0'; s += arglen; - sep = escapes ? getkeystring(s, &waste, GETKEYS_SEP, NULL) - : dupstring(s); + if (escapes) { + int len; + sep = getkeystring(s, &len, GETKEYS_SEP, NULL); + sep = metafy(sep, len, META_HREALLOC); + } + else + sep = dupstring(s); *t = sav; s = t + arglen - 1; break; diff --git a/Test/D06subscript.ztst b/Test/D06subscript.ztst index adbd398c4..21127e641 100644 --- a/Test/D06subscript.ztst +++ b/Test/D06subscript.ztst @@ -294,3 +294,8 @@ F:Regression test for workers/42297 [[ ${a[$i]} = ${a[i]} ]] 0f:Math evaluation of commas in array subscripts F:In math, (($i)) should be the same as ((i)), see workers/47748. + + string=$'foo\0bar' + echo ${string[(pws:\0:)1]} +0:Word splitting by NUL +>foo |