From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17863 invoked from network); 4 Oct 2004 10:32:31 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 4 Oct 2004 10:32:31 -0000 Received: (qmail 76082 invoked from network); 4 Oct 2004 10:32:25 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 4 Oct 2004 10:32:25 -0000 Received: (qmail 3851 invoked by alias); 4 Oct 2004 10:32:12 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 20443 Received: (qmail 3837 invoked from network); 4 Oct 2004 10:32:11 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 4 Oct 2004 10:32:11 -0000 Received: (qmail 75743 invoked from network); 4 Oct 2004 10:32:11 -0000 Received: from lhuumrelay3.lnd.ops.eu.uu.net (62.189.58.19) by a.mx.sunsite.dk with SMTP; 4 Oct 2004 10:32:10 -0000 Received: from MAILSWEEPER01.csr.com (mailhost1.csr.com [62.189.183.235]) by lhuumrelay3.lnd.ops.eu.uu.net (8.11.0/8.11.0) with ESMTP id i94AW9v03941 for ; Mon, 4 Oct 2004 10:32:09 GMT Received: from EXCHANGE02.csr.com (unverified [192.168.137.45]) by MAILSWEEPER01.csr.com (Content Technologies SMTPRS 4.3.12) with ESMTP id for ; Mon, 4 Oct 2004 11:31:10 +0100 Received: from news01.csr.com ([192.168.143.38]) by EXCHANGE02.csr.com with Microsoft SMTPSVC(5.0.2195.6713); Mon, 4 Oct 2004 11:34:15 +0100 Received: from news01.csr.com (localhost.localdomain [127.0.0.1]) by news01.csr.com (8.12.11/8.12.11) with ESMTP id i94AW7Zf011800 for ; Mon, 4 Oct 2004 11:32:08 +0100 Received: from csr.com (pws@localhost) by news01.csr.com (8.12.11/8.12.11/Submit) with ESMTP id i94AW6pa011797 for ; Mon, 4 Oct 2004 11:32:07 +0100 Message-Id: <200410041032.i94AW6pa011797@news01.csr.com> X-Authentication-Warning: news01.csr.com: pws owned process doing -bs To: zsh-workers@sunsite.dk Subject: Re: [bug] type -m '^foo' In-reply-to: References: <20041001145038.GB1772@frhdtmp102861.morse.corp.wan> <200410011822.i91IMxeM009020@news01.csr.com> Date: Mon, 04 Oct 2004 11:32:05 +0100 From: Peter Stephenson X-OriginalArrivalTime: 04 Oct 2004 10:34:15.0146 (UTC) FILETIME=[B20134A0:01C4A9FD] 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 Bart Schaefer wrote: > 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. Yes, I agree with all of that... however, rewriting the whole thing not to require NULL-terminated strings is quite a big change (there's no "memncmp" function, for example, and I'm not sure if you can guarantee memcmp will stop comparing soon enough). Only a few of the nasty negative pattern matches need to rejig the string, so it would probably make the vast majority of matches a bit slower. I'll put it on the list to look at. -- Peter Stephenson Software Engineer CSR Ltd., Science Park, Milton Road, Cambridge, CB4 0WH, UK Tel: +44 (0)1223 692070 ********************************************************************** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This footnote also confirms that this email message has been swept by MIMEsweeper for the presence of computer viruses. www.mimesweeper.com **********************************************************************