Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [bug] type -m '^foo'



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 <pws@xxxxxxx>                  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
**********************************************************************



Messages sorted by: Reverse Date, Date, Thread, Author