zsh-workers
 help / color / mirror / code / Atom feed
* 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(&copy, hsubl, hsubr, gbal, hsubpatopt);
> +                subst(&copy, 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

only message in thread, other threads:[~2023-09-17  3:48 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CAO4D9E=+O-=66w0um7OzENVEiV11QfVUWYSTocacUX4rhYr1=Q@mail.gmail.com>
     [not found] ` <CAH+w=7Y+zos=sRfAv2769iJEzazHRfT4u6v+3B3mGoxy8Yv0-w@mail.gmail.com>
     [not found]   ` <CAH+w=7Yv_tyBKLo1PuoeDB-YkWwpGh5d_hZODyTH7J0mgD3RNg@mail.gmail.com>
2023-09-17  3:47     ` Help: f (repeat) modifier, and histsubstpattern + :s/l/r/ modifier escaping of [{()}] Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).