From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8212 invoked from network); 2 May 2007 00:11:56 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.8 (2007-02-13) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00,FORGED_RCVD_HELO autolearn=ham version=3.1.8 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 2 May 2007 00:11:56 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 45919 invoked from network); 2 May 2007 00:11:50 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 2 May 2007 00:11:49 -0000 Received: (qmail 16784 invoked by alias); 2 May 2007 00:11:47 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 23376 Received: (qmail 16774 invoked from network); 2 May 2007 00:11:46 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 2 May 2007 00:11:46 -0000 Received: (qmail 45556 invoked from network); 2 May 2007 00:11:46 -0000 Received: from redoubt.spodhuis.org (HELO mx.spodhuis.org) (193.202.115.177) by a.mx.sunsite.dk with SMTP; 2 May 2007 00:11:43 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=first1; d=spodhuis.org; h=Received:Date:From:To:Subject:Message-ID:Mail-Followup-To:References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; b=L/HCiwS2KtdHoM74MiD/ErZVOn+LGwu7fchUctPnnww2brf9l+NNC4AvOaD44V1pdsxOM5YLp6Q4MerROMsS6UnXdMPeOK5SKIbMj4WtqqjBNgSWPF4G/G+GQu1ogJEcW7HAX45AaKQgKD8fBhy1mt82ST6ymOUHsHcQiqWdUEQ=; Received: by smtp.spodhuis.org with local id 1Hj2Ra-000Fsm-RL; Wed, 02 May 2007 00:11:42 +0000 Date: Tue, 1 May 2007 17:11:42 -0700 From: Phil Pennock To: zsh-workers@sunsite.dk Subject: Re: PATCH: zsh/regex and =~ Message-ID: <20070502001142.GA89340@redoubt.spodhuis.org> Mail-Followup-To: zsh-workers@sunsite.dk References: <20070428075635.GA17419@redoubt.spodhuis.org> <20070501225933.c40ac724.p.w.stephenson@ntlworld.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20070501225933.c40ac724.p.w.stephenson@ntlworld.com> On 2007-05-01 at 22:59 +0100, Peter Stephenson wrote: > I didn't put RE_MATCH_PCRE on by default; it seems to me to be a > user choice and having it depend on the shell emulation is more > confusing than useful. Similarly, I've made the condition code > behave identically (apart, obviously, from the module =~ uses) > whether or not the option is set; if the module you didn't > ask for is not available, you get an error message rather than > a different sort of regular expression. Makes sense. > I've fixed the doc for =~ and tweaked at least one other minor typo. English really is my first language. *cough* Similarly, regex.c: /* if you want Basic syntax, make it an alternative options */ s/options/option/ > I've added the option NO_CASE_MATCH to zsh/regex handling (like bash). > I don't know enough about the PCRE library to decide whether it's > sensible to have the same effect there, but if it is that's fine by me. It is. If you look at bin_pcre_compile(), you can see that if the -i option is passed, it ORs in the bitflag PCRE_CASELESS. Both bin_pcre_compile() and cond_pcre_match() need the obvious: if (!isset(CASEMATCH)) pcre_opts |= PCRE_CASELESS; at a place of your choosing, before the call to pcre_compile(). You _can_ achieve the same thing using embedded options: % [[ FoO =~ ^(?i)f([aeiou]+) ]] && print -l $MATCH $match FoO oO but I see no reason to not be as compatible as possible in interpreting basic behavioural options. Aside: the embedded options parsing means that the default stringification by ruby of a regexp type can be directly parsed by zsh's pcre_compile, a happy accident for me which I noticed yesterday. % zrb '/^f([aeiou]+)/' ; print $zrb_value (?-mix:^f([aeiou]+)) % pcre_compile $zrb_value ; pcre_match faui && print $match aui Neat. :^) > I've added some debugging code to test for a bad id passed to > the regex-match handler. This doesn't do a heck of a lot at > the moment, but the case statement was looking a bit lonely > with just one entry. Doh. Yes, of course, not something I normally skip. Thanks. > I'll commit this even if there are quibbles, to establish either a stick > in the ground or a line in the sand. (I asked what the difference > was and was told one was horizontal and the other vertical.) You can tell the time by the stick in the ground, on a sunny day, if you draw lines in the sand to mark the hours. Doing so accurately obviously requires control of both the horizontal and the vertical. I've reached the outer limit of what I'll say on this topic.