1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-10-23 16:40:24 +02:00

51079: metafy sep in array subscript flag (s:sep:)

this enable sep to contain \0 etc.
This commit is contained in:
Jun-ichi Takimoto 2022-12-02 19:19:27 +09:00
parent 291940bae6
commit 1be52186b4
3 changed files with 17 additions and 3 deletions

View file

@ -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

View file

@ -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;

View file

@ -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