From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7464 invoked from network); 2 Oct 2004 02:18:42 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 2 Oct 2004 02:18:42 -0000 Received: (qmail 64724 invoked from network); 2 Oct 2004 02:18:36 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 2 Oct 2004 02:18:36 -0000 Received: (qmail 20471 invoked by alias); 2 Oct 2004 02:18:24 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 20440 Received: (qmail 20456 invoked from network); 2 Oct 2004 02:18:23 -0000 Received: from unknown (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 2 Oct 2004 02:18:23 -0000 Received: (qmail 64272 invoked from network); 2 Oct 2004 02:17:23 -0000 Received: from moonbase.zanshin.com (64.84.47.139) by a.mx.sunsite.dk with SMTP; 2 Oct 2004 02:17:22 -0000 Received: from toltec.zanshin.com (toltec.zanshin.com [64.84.47.166]) by moonbase.zanshin.com (8.13.1/8.13.1) with ESMTP id i922HKvn017446 for ; Fri, 1 Oct 2004 19:17:20 -0700 Date: Fri, 1 Oct 2004 19:17:20 -0700 (PDT) From: Bart Schaefer Reply-To: zsh-workers@sunsite.dk To: zsh-workers@sunsite.dk Subject: Re: [bug] type -m '^foo' In-Reply-To: <200410011822.i91IMxeM009020@news01.csr.com> Message-ID: References: <20041001145038.GB1772@frhdtmp102861.morse.corp.wan> <200410011822.i91IMxeM009020@news01.csr.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Checker-Version: SpamAssassin 2.63 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, hits=0.0 required=6.0 tests=none autolearn=no version=2.63 X-Spam-Hits: 0.0 On Fri, 1 Oct 2004, Peter Stephenson wrote: > > This fixes the crash, but it would be better if pattry() could be > > rewritten so as not to need to modify the string in place. > > I think this fixes it, but it's horribly complicated around there. Hmm, well, what I meant was that it would be better if it could be re- written so as not to need a null terminator at that point, i.e., to do everything with array indices or starting/ending pointers rather than rely on having a nul-terminated string. Copying and freeing the string down in the recursive guts of matching is probably more expensive (for certain patterns, although far less expensive for other patterns) than copying the whole string beforehand. On the other hand the code is already doing zshcalloc() in that vicinity, so perhaps a few more allocs/frees is not enough to worry about.