zsh-workers
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@candle.brasslantern.com>
To: <zsh-workers@sunsite.dk>
Subject: Re: Patterns quoting in subscript (was: Re: PATCH: Assorted parameter stuff)
Date: Wed, 18 Apr 2001 20:14:41 +0000	[thread overview]
Message-ID: <1010418201441.ZM8481@candle.brasslantern.com> (raw)
In-Reply-To: <1010418172622.ZM30038@candle.brasslantern.com>

On Apr 18,  5:26pm, Bart Schaefer wrote:
}
} [...] So if you want to match 4 backslashes, you need 16 backslashes;
} but if you want to match 4 backslashes followed by a literal question
} mark, you need a whopping 34 backslashes, because you have to double
} all 16 of those backslashes and then add two more to quote the `?'
} itself.
}
} Clearly this is silly; it results because of the extra call to
} parsestr() that happens when the `needtok' loop in getarg() detects an
} ispecial() (the `?' in this example). I'll see if that can't be made
} to behave a bit more intelligibly.

By relocating one remnulargs() call relative to 14008 and removing one
INULL() "optimization", it's possible to get a consistent 4-to-1 ratio
of backslashes in the input subscript to match one backslash in the
array value by pattern match.

That applies only with (i) (I) (r) (R); it's the usual 2-to-1 ratio for
a direct associative-array lookup.

The following goes on top of 14008.

--- current/Src/params.c	Tue Apr 17 23:30:50 2001
+++ ../zsh-4.0/Src/params.c	Wed Apr 18 11:56:33 2001
@@ -919,22 +919,19 @@
 	    i++;
 	else if (c == Outbrack)
 	    i--;
-	if (INULL(c)) {
-	    if (!*++t)
-		break;
-	} else if (ispecial(c))
+	if (ispecial(c))
 	    needtok = 1;
     }
     if (!c)
 	return 0;
     s = dupstrpfx(s, t - s);
-    remnulargs(s);
     *str = tt = t;
     if (needtok) {
 	if (parsestr(s))
 	    return 0;
 	singsub(&s);
     }
+    remnulargs(s);
     if (!rev) {
 	if (ishash) {
 	    HashTable ht = v->pm->gets.hfn(v->pm);
@@ -942,7 +939,6 @@
 		ht = newparamtable(17, v->pm->nam);
 		v->pm->sets.hfn(v->pm, ht);
 	    }
-	    remnulargs(s);
 	    untokenize(s);
 	    if (!(v->pm = (Param) ht->getnode(ht, s))) {
 		HashTable tht = paramtab;

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


      reply	other threads:[~2001-04-18 20:47 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-04-15  8:06 PATCH: Assorted parameter stuff Bart Schaefer
2001-04-17  3:54 ` Example from manual seems broken F. G. Marx
2001-04-17  4:45   ` Bart Schaefer
2001-04-18  6:57     ` PATCH: Assorted parameter stuff Bart Schaefer
2001-04-18  8:44       ` Sven Wischnowsky
2001-04-19  3:57         ` Bart Schaefer
2001-04-19  7:05           ` Sven Wischnowsky
2001-04-19  8:53             ` fpath problem on clean install Andrej Borsenkow
2001-04-19  9:50               ` PATCH: " Sven Wischnowsky
2001-04-19 14:02                 ` Andrej Borsenkow
2001-04-19  9:20             ` PATCH: Assorted parameter stuff Andrej Borsenkow
2001-04-19  9:47               ` Bart Schaefer
2001-04-19  9:34             ` Bart Schaefer
2001-04-20  5:20               ` Bart Schaefer
2001-04-17 18:30 ` Patterns quoting in subscript (was: Re: PATCH: Assorted parameter stuff) Andrej Borsenkow
2001-04-18  7:38   ` Bart Schaefer
2001-04-18  8:10     ` Bart Schaefer
2001-04-18  8:34     ` Andrej Borsenkow
2001-04-18  8:45     ` Andrej Borsenkow
2001-04-18 17:26       ` Bart Schaefer
2001-04-18 20:14         ` Bart Schaefer [this message]

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=1010418201441.ZM8481@candle.brasslantern.com \
    --to=schaefer@candle.brasslantern.com \
    --cc=zsh-workers@sunsite.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).