Thread (1 message) 1 message, 1 author, 2016-06-15

Re: [PATCH 3/4] diffcore-pickaxe: further refactor count_match()

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:46:18

René Scharfe [off-list ref] writes:
quoted
-
-	} 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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help