From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 20730 invoked from network); 17 Aug 2023 23:10:01 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 17 Aug 2023 23:10:01 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1692313801; b=VpBY3wp6sYxnFu/Kh4M1jCQGrxAm8aR3k7AkX8wTE/M/zz+JC1FjvTfq2UsibfXeAVzGFa7s1Y FmJNOQJKY+wv5sJrAQoKWkfMmar4UgFzwv4TtvqV8SuSmbFxFZnPaNMTvgfbCuxD0lqwPCoSX0 iw1tLmIilbjIXn0Zfu5BQb9eSrZMeUY2kOFRhRa6bczE33vEJq3WMT85354LB+0ZXudV2l4+H6 KkAfYc6ZrZE+moNctq5PvOcH69GOCD2GHy0OfjaoRscxtz1FJb4TrqRE0f2whmgUabur3PJ3fL 8MTLV6Vfi+eS5PYsZojs1GgqkQUjIxv+0v6UdklxfoAKag==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-lj1-f181.google.com) smtp.remote-ip=209.85.208.181; dkim=pass header.d=brasslantern-com.20221208.gappssmtp.com header.s=20221208 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1692313801; bh=Dm98V28DnJTuluu2ilQ02Xyiiepzd5n4k9zKFnHVZTE=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:Cc:To:Subject: Message-ID:Date:From:In-Reply-To:References:MIME-Version:DKIM-Signature: DKIM-Signature; b=As2eEdzS5Nw2xrWNR1nPn5BuDJZUJR8azFLIbiL4rqrz6LKnSdM5UASufpTqUGoaT+PDfF/neY Y2r09K4u6PItYV4q8874ZTX4Jxdh61FbtiEdkRvL8890YXv4n4QoiGHGLixz2s/IVsXHpHTsu6 xuI3tccitWPOFTY3w5O48w/O0HUCCy4h+7YwbzqPbb3QNLRtQXPS+IC8w3TyHri5BD7lPH7nRK jlXspFbT4Jnjeu/x5hiqG180yzTdlWabXpO7WbWL/KTZgmkwNB58uF+TkIqFQCB48NetyBhK4n TN1zqXOKV4KjzLG2iLwZjDgfdoi9dXgmg/3fLPRE9QE05A==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Transfer-Encoding: Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To:References: MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=PSBGfNVTgRV56x0YHJ1h7b3AEx+Ub8FhZVkUIEs4HAo=; b=PCeOtKXdzs9bgBzW4a+NAqsUZa /nUmr51eXxT4toOjFpnms12KVNKBFnGiPOVDouJ7O7hNW3aDYkGHzJE/SaIJdZg+yS7bOGYkn/U7w SvkqcShEkWcTa18JIytv0/OFXj06T8NrQcxGVi9UNVJ0uKYn+2sPdlKWJfUG1DMPrFJZ9uBGBKTxX 03vchTX6FLibuZhMhKvGnWT12EnKjcCdurl+gcsqjFCzWPOCrBOjQvtlKk8b9QY9ErGHTA/kL4ohw 0tZeiJjloWWjamWwS0pe1ldz9ifgTGCLK1fe74836oCbP9gjZ99RGmVNVpmvR2NYYW3C63YBcQQYe h5IxMrdQ==; Received: by zero.zsh.org with local id 1qWm7s-000FOA-7T; Thu, 17 Aug 2023 23:10:00 +0000 Authentication-Results: zsh.org; iprev=pass (mail-lj1-f181.google.com) smtp.remote-ip=209.85.208.181; dkim=pass header.d=brasslantern-com.20221208.gappssmtp.com header.s=20221208 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-lj1-f181.google.com ([209.85.208.181]:59852) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1qWm7M-000EfJ-8x; Thu, 17 Aug 2023 23:09:29 +0000 Received: by mail-lj1-f181.google.com with SMTP id 38308e7fff4ca-2b9db1de50cso4663261fa.3 for ; Thu, 17 Aug 2023 16:09:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20221208.gappssmtp.com; s=20221208; t=1692313767; x=1692918567; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=PSBGfNVTgRV56x0YHJ1h7b3AEx+Ub8FhZVkUIEs4HAo=; b=aRsgEI/pDWogC3vMl6rQ4DirjMi8f1uWEX+0ZGOm3BoaQpuO71lsiL1ma7bGx/tpjf KoQYqFCLbNZ/3ayI/LJGeRjDy1e/guualn1+mlHQ1xRCUVBX7rgLJffGhUTiao2RBgxs ePRZYgHD9j3Q8Eogs5/Fy+EM+KOPq3F3Laajy/3jFsSz8nLG9iRfU4faJB3FO/XKSJaZ /tWZfgpJd4itNhZUQZTZtFThMyQvU76zSKLysptK5nmJyeP4hBLpEiNvAGOCJOMJ5b9w PFSO8GXlX0wznjlVKprqhGt4IaJKjnHL1LNwo/vjDTGAN2yPoOUEJjMg3qY6CNwXxdgT M1Iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692313767; x=1692918567; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PSBGfNVTgRV56x0YHJ1h7b3AEx+Ub8FhZVkUIEs4HAo=; b=P3FB8nuuUjDE0PBSP06QDm578gB/SMVZW6zcNuodecokd7fgoqInLkRjQPJPGE+Syk keolCF4AlsdmpFJ3Z5r8vT0uU7RZWNRAaudS+Eem2iFtcnDxnlxzNqsD5+XHgygseEbZ FbdlhBUvWvVmReBoDOpbdaA8J+UzIq5VPK1I1lS9qFfJu/P5JVGIlrWp55astuBAa4U+ 9qhRtP0WI58vhJ7R5sbiFVZD9dVD4nNw8AtTHJRIKNujr9gOg6EAevxuNa8sghfU2Wta SLqzNZUB7VO0p52zMXFdGjJzZz75S8U1CLp01xir28TeuZj9k4VKqX8CvCak72kzNlvy pQug== X-Gm-Message-State: AOJu0YxZBeThRWBff29/Awn1E3r+6dSW2psehcmGm5xnnTj21zh0lTiY WXUeoa2CAH8SO4KtIQLZ9nd71NShQvq/oYunPyNoYA== X-Google-Smtp-Source: AGHT+IFXp/+Ln8IxVEzCXzn2Xt5zjyab79SDyl7pDXF40hAa2CJQ2a2ZhEQfC6kefYib5XRXQLJmYwmui+nwyqlRB3A= X-Received: by 2002:a2e:8747:0:b0:2b6:d700:fbdd with SMTP id q7-20020a2e8747000000b002b6d700fbddmr531162ljj.15.1692313767068; Thu, 17 Aug 2023 16:09:27 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Bart Schaefer Date: Thu, 17 Aug 2023 16:09:16 -0700 Message-ID: Subject: Re: Help: f (repeat) modifier, and histsubstpattern + :s/l/r/ modifier escaping of [{()}] To: Andy Kluger Cc: zsh-users@zsh.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Seq: 29160 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: On Wed, Aug 16, 2023 at 8:19=E2=80=AFPM Bart Schaefer 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 =3D (c =3D=3D 'S'); if (hsubl && hsubr) - subst(©, hsubl, hsubr, gbal, hsubpatopt); + subst(©, dupstring(hsubl), dupstring(hsubr), + gbal, hsubpatopt); break; case 'q': copy =3D quotestring(copy, QT_BACKSLASH_SHOWNULL); @@ -4627,7 +4628,8 @@ modify(char **str, char **ptr, int inbrace) case 'S': hsubpatopt =3D (c =3D=3D 'S'); if (hsubl && hsubr) - subst(str, hsubl, hsubr, gbal, hsubpatopt); + subst(str, dupstring(hsubl), dupstring(hsubr), + gbal, hsubpatopt); break; case 'q': *str =3D quotestring(*str, QT_BACKSLASH);