From: Junio C Hamano Date: Sat, 28 Feb 2009 01:25:48 GMT Subject: Re: [PATCH 3/4] diffcore-pickaxe: further refactor count_match() Message-ID: <7vy6vrgxnn.fsf@gitster.siamese.dyndns.org> In-Reply-To: <49A88FA7.1020402@lsrfire.ath.cx> René Scharfe writes: >> - >> - } else { /* Classic exact string match */ >> - /* Yes, I've heard of strstr(), but the thing is *data may >> - * not be NUL terminated. Sue me. >> - */ >> + } else { >> + /* data many not be NUL terminated; we cannot use strstr() */ > > That looks fishy to me. regexec() expects data to be a NUL-terminated > string, so either the comment is wrong or the regexp case needs to take > better care to add a NUL at the end of the buffer. Probably yes, but regexp side is not my code and I never use it, so... ;-) > In any case, there is also memmem(), which uses the same fast algorithm > as strstr() in recent glibc versions. Like this? Thanks; it would be nice to bench this change.