zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: Help: f (repeat) modifier, and histsubstpattern + :s/l/r/ modifier escaping of [{()}]
Date: Sat, 16 Sep 2023 20:47:45 -0700	[thread overview]
Message-ID: <CAH+w=7ZMKT_AK7G021FQz0ddE0Dcxubqk8Ey5F9jKV_UzQgb7w@mail.gmail.com> (raw)
In-Reply-To: <CAH+w=7Yv_tyBKLo1PuoeDB-YkWwpGh5d_hZODyTH7J0mgD3RNg@mail.gmail.com>

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


           reply	other threads:[~2023-09-17  3:48 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <CAH+w=7Yv_tyBKLo1PuoeDB-YkWwpGh5d_hZODyTH7J0mgD3RNg@mail.gmail.com>]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAH+w=7ZMKT_AK7G021FQz0ddE0Dcxubqk8Ey5F9jKV_UzQgb7w@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).