* Re: Help: f (repeat) modifier, and histsubstpattern + :s/l/r/ modifier escaping of [{()}]
[not found] ` <CAH+w=7Yv_tyBKLo1PuoeDB-YkWwpGh5d_hZODyTH7J0mgD3RNg@mail.gmail.com>
@ 2023-09-17 3:47 ` Bart Schaefer
0 siblings, 0 replies; only message in thread
From: Bart Schaefer @ 2023-09-17 3:47 UTC (permalink / raw)
To: Zsh hackers list
On Thu, Aug 17, 2023 at 4:09 PM Bart Schaefer <schaefer@brasslantern.com> wrote:
>
> Proof of bug / concept of fix. This might eat a lot of heap so
> something more detailed is probably needed
There doesn't seem to be any better approach without actually invoking
pushheap/popheap which is likely overkill for most cases of this, so
I'm just going to commit users/29160.
Here's a test suite patch to go with it.
> diff --git a/Src/subst.c b/Src/subst.c
> index 14947ae36..7b866e638 100644
> --- a/Src/subst.c
> +++ b/Src/subst.c
> @@ -4539,7 +4539,8 @@ modify(char **str, char **ptr, int inbrace)
> case 'S':
> hsubpatopt = (c == 'S');
> if (hsubl && hsubr)
> - subst(©, hsubl, hsubr, gbal, hsubpatopt);
> + subst(©, dupstring(hsubl), dupstring(hsubr),
> + gbal, hsubpatopt);
> break;
> case 'q':
> copy = quotestring(copy, QT_BACKSLASH_SHOWNULL);
> @@ -4627,7 +4628,8 @@ modify(char **str, char **ptr, int inbrace)
> case 'S':
> hsubpatopt = (c == 'S');
> if (hsubl && hsubr)
> - subst(str, hsubl, hsubr, gbal, hsubpatopt);
> + subst(str, dupstring(hsubl), dupstring(hsubr),
> + gbal, hsubpatopt);
> break;
> case 'q':
> *str = quotestring(*str, QT_BACKSLASH);
diff --git a/Test/E01options.ztst b/Test/E01options.ztst
index 83f0371a1..363846f5c 100644
--- a/Test/E01options.ztst
+++ b/Test/E01options.ztst
@@ -561,12 +561,14 @@
foo=(one.c two.c three.c)
print ${foo:s/#%(#b)t(*).c/T${match[1]}.X/}
print *(#q:s/#(#b)tmp(*e)/'scrunchy${match[1]}'/)
+ print ${${:-"left[({})]over"}:fs/(\\{\\}|\\(\\)|\\[\\])//}
unsetopt histsubstpattern
0:HIST_SUBST_PATTERN option
>TINGcd TINGfile1 TINGfile2 homedir
>THUMPcd THUMPfile1 THUMPfile2
>one.c Two.X Three.X
>homedir scrunchyfile1 scrunchyfile2 tmpcd
+>leftover
setopt ignorebraces
echo X{a,b}Y
^ permalink raw reply [flat|nested] only message in thread