From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 394 invoked from network); 29 Apr 2007 00:51:47 -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; 29 Apr 2007 00:51:47 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 88779 invoked from network); 29 Apr 2007 00:51:40 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 29 Apr 2007 00:51:40 -0000 Received: (qmail 29453 invoked by alias); 29 Apr 2007 00:51:34 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 23342 Received: (qmail 29443 invoked from network); 29 Apr 2007 00:51:32 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 29 Apr 2007 00:51:32 -0000 Received: (qmail 88392 invoked from network); 29 Apr 2007 00:51:32 -0000 Received: from redoubt.spodhuis.org (HELO mx.spodhuis.org) (193.202.115.177) by a.mx.sunsite.dk with SMTP; 29 Apr 2007 00:51:29 -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=fJDBIzd+h6hjENX4Phhw15AU394X8tl3t0qglEbqJ9WHGDDvZeWH6fPw0qhgIs2jbigkpiQCi3zqfz8h1kbusQdTHxnfvYMEM+mqgdjY0revpouENevNK3hdlCXbxYasyuoYiHhywf1ScSGUyB6L+ipRePNsjIOIPAUopbMZQn4=; Received: by smtp.spodhuis.org with local id 1HhxdQ-000200-QK; Sun, 29 Apr 2007 00:51:28 +0000 Date: Sat, 28 Apr 2007 17:51:28 -0700 From: Phil Pennock To: zsh-workers@sunsite.dk Subject: Re: PATCH: zsh/regex and =~ Message-ID: <20070429005128.GA6995@redoubt.spodhuis.org> Mail-Followup-To: zsh-workers@sunsite.dk References: <20070428075635.GA17419@redoubt.spodhuis.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="J2SCkAp4GZ/dPZZf" Content-Disposition: inline In-Reply-To: <20070428075635.GA17419@redoubt.spodhuis.org> --J2SCkAp4GZ/dPZZf Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On 2007-04-28 at 00:56 -0700, Phil Pennock wrote: > The attached patch and files, which includes documentation, adds a new > loadable module, zsh/regex. I've not examined widechar issues and which > regex libraries actually do handle these. I've not looked at linkage > issues on platforms where regex (the POSIX interface, not regexp) is not > a part of libc. I noticed a gcc complaint that a variable might be used uninitialised; this was bogus, but understandable. The first patch below fixes it. The second patch is a spelling correction in the docs. Alternatively, it might be a sign that the option needs to be renamed ... arr is only initialised if nelem. Later there are two references to it. The second is guarded by "if (nelem)"; the first is guarded by "if (isset(BASHREMATCH))". If BASHREMATCH is set, nelem is always at least 1. Assuming re.re_nsub is never negative, which it isn't. And the patch also affirms this for sheer paranoia's sake. -Phil --J2SCkAp4GZ/dPZZf Content-Type: text/x-diff; charset=us-ascii Content-Disposition: inline; filename="zsh-regex-bogus-unused.patch" --- Src/Modules/regex.c.old Sat Apr 28 17:40:12 2007 +++ Src/Modules/regex.c Sat Apr 28 17:43:27 2007 @@ -75,6 +75,11 @@ zcond_regex_match(char **a, int id) /* re.re_nsub is number of parenthesized groups, we also need * 1 for the 0 offset, which is the entire matched portion */ + if (re.re_nsub < 0) { + zwarn("INTERNAL ERROR: regcomp() returned " + "negative subpattern count %d", re.re_nsub); + break; + } matchessz = (re.re_nsub + 1) * sizeof(regmatch_t); matches = zalloc(matchessz); r = regexec(&re, lhstr, re.re_nsub+1, matches, reflags); @@ -88,6 +93,7 @@ zcond_regex_match(char **a, int id) start = 1; nelem = re.re_nsub; } + arr = NULL; /* bogus gcc warning of used uninitialised */ /* entire matched portion + re_nsub substrings + NULL */ if (nelem) { arr = x = (char **) zalloc(sizeof(char *) * (nelem + 1)); --J2SCkAp4GZ/dPZZf Content-Type: text/x-diff; charset=us-ascii Content-Disposition: inline; filename="zsh-regex-speling.patch" --- Doc/Zsh/mod_regex.yo.old Sat Apr 28 17:45:57 2007 +++ Doc/Zsh/mod_regex.yo Sat Apr 28 17:45:35 2007 @@ -15,7 +15,7 @@ [[ alphabetical -regex-match ^a([^a]+)a([^a]+)a ]] && print -l $MATCH X $match -If tt(REGMATCH_PCRE) is not set, then the tt(=~) operator will automatically +If tt(REMATCH_PCRE) is not set, then the tt(=~) operator will automatically load this module as needed and will invoke the tt(-regex-match) operator. If tt(BASH_REMATCH) is set, then tt($BASH_REMATCH) will be set instead of --J2SCkAp4GZ/dPZZf--