zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@cambridgesiliconradio.com>
To: zsh-workers@sunsite.auc.dk (Zsh hackers list)
Subject: PATCH: substitution anchors
Date: Fri, 05 May 2000 15:26:16 +0100	[thread overview]
Message-ID: <0FU300484C3RBN@la-la.cambridgesiliconradio.com> (raw)
In-Reply-To: "Your message of Fri, 05 May 2000 17:32:58 +0400." <001701bfb696$6d2abbd0$21c9ca95@mow.siemens.ru>

> That's because I used wrong syntax in _arguments (_long_options at the
> time of writing). This patch gets it right and replaces # with (#s),
> that also works. Patch attached.

OK, this would remove the effect of anchors in substituted parameters, and
makes it a bit clearer what's going on.  I don't if Bart is still keen on
keeping this effect.  This needs Andrej's patch (the only effect at the
moment is whether `configure' shows all --enable/--disable pairs when the
help text contains one of them, as is usual) and I will commit the two
together or not at all.

Index: Doc/Zsh/expn.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/expn.yo,v
retrieving revision 1.11
diff -u -r1.11 expn.yo
--- Doc/Zsh/expn.yo	2000/05/04 06:21:18	1.11
+++ Doc/Zsh/expn.yo	2000/05/05 14:20:23
@@ -456,13 +456,21 @@
 Replace the longest possible match of var(pattern) in the expansion of
 parameter var(name) by string var(repl).  The first form
 replaces just the first occurrence, the second form all occurrences.
+Both var(pattern) and var(repl) are subject to double-quoted substitution,
+so that expressions like tt(${name/$opat/$npat}) will work, but note the
+usual rule that pattern characters in tt($opat) are not treated specially
+unless either the option tt(GLOB_SUBST) is set, or tt($opat) is instead
+substituted as tt(${~opat}).
+
 The var(pattern) may begin with a `tt(#)', in which case the
 var(pattern) must match at the start of the string, or `tt(%)', in
 which case it must match at the end of the string.  The var(repl) may
 be an empty string, in which case the final `tt(/)' may also be omitted.
 To quote the final `tt(/)' in other cases it should be preceded by two
 backslashes (i.e., a quoted backslash); this is not necessary if the
-`tt(/)' occurs inside a substituted parameter.
+`tt(/)' occurs inside a substituted parameter.  Note also that the `tt(#)'
+and `tt(%)' are not active if they occur inside a substituted parameter,
+even at the start.
 
 The first `tt(/)' may be preceded by a `tt(:)', in which case the match
 will only succeed if it matches the entire word.  Note also the
Index: Src/subst.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/subst.c,v
retrieving revision 1.3
diff -u -r1.3 subst.c
--- Src/subst.c	2000/05/03 12:21:56	1.3
+++ Src/subst.c	2000/05/05 14:20:23
@@ -1466,6 +1466,13 @@
 		char t = s[-1];
 
 		singsub(&s);
+#if 0
+		/*
+		 * This allows # and % to be at the start of
+		 * a parameter in the substitution, which is
+		 * a bit nasty, and can be done (although
+		 * less efficiently) with anchors.
+		 */
 		if (t == '/' && (flags & SUB_SUBSTR)) {
 		    if ((c = *s) == '#' || c == '%') {
 			flags &= ~SUB_SUBSTR;
@@ -1476,6 +1483,7 @@
 			s++;
 		    }
 		}
+#endif
 	    }
 
 	    if (!vunset && isarr) {

-- 
Peter Stephenson <pws@cambridgesiliconradio.com>
Cambridge Silicon Radio, Unit 300, Science Park, Milton Road,
Cambridge, CB4 0XL, UK                          Tel: +44 (0)1223 392070


  reply	other threads:[~2000-05-05 14:27 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-04-06  9:15 Modifier substitutions Peter Stephenson
2000-04-06  9:32 ` Andrej Borsenkow
2000-04-06 12:49   ` Andrej Borsenkow
2000-04-12 12:26   ` Should we backup this change? " Andrej Borsenkow
2000-04-12 12:34     ` Sven Wischnowsky
2000-04-12 14:53       ` Bart Schaefer
2000-04-12 15:06         ` Andrej Borsenkow
2000-04-12 20:54           ` Peter Stephenson
2000-04-13  6:00             ` Andrej Borsenkow
2000-04-13  8:59               ` Peter Stephenson
2000-05-04  7:02         ` Let's do it " Andrej Borsenkow
2000-05-04 15:56           ` Peter Stephenson
2000-05-05 13:32             ` PATCH:RE: Let's do it RE: Should we backup this change? RE: Modifiersubstitutions Andrej Borsenkow
2000-05-05 14:26               ` Peter Stephenson [this message]
2000-05-05 14:52                 ` PATCH: substitution anchors Bart Schaefer
2000-05-05 14:55                   ` Andrej Borsenkow

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=0FU300484C3RBN@la-la.cambridgesiliconradio.com \
    --to=pws@cambridgesiliconradio.com \
    --cc=zsh-workers@sunsite.auc.dk \
    /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).