Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Help: f (repeat) modifier, and histsubstpattern + :s/l/r/ modifier escaping of [{()}]
- X-seq: zsh-users 29160
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Andy Kluger <andykluger@xxxxxxxxx>
- Cc: zsh-users@xxxxxxx
- Subject: Re: Help: f (repeat) modifier, and histsubstpattern + :s/l/r/ modifier escaping of [{()}]
- Date: Thu, 17 Aug 2023 16:09:16 -0700
- Archived-at: <https://zsh.org/users/29160>
- In-reply-to: <CAH+w=7Y+zos=sRfAv2769iJEzazHRfT4u6v+3B3mGoxy8Yv0-w@mail.gmail.com>
- List-id: <zsh-users.zsh.org>
- References: <CAO4D9E=+O-=66w0um7OzENVEiV11QfVUWYSTocacUX4rhYr1=Q@mail.gmail.com> <CAH+w=7Y+zos=sRfAv2769iJEzazHRfT4u6v+3B3mGoxy8Yv0-w@mail.gmail.com>
On Wed, Aug 16, 2023 at 8:19 PM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
>
> > 2. Why doesn't the replacement seem to happen to each subsequent
> > result of a former replacement?
>
> Because there's a bug.
Proof of bug / concept of fix. This might eat a lot of heap so
something more detailed is probably needed, so I'm not going to bother
to protect this from gmail line wrapping etc.
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);
Messages sorted by:
Reverse Date,
Date,
Thread,
Author