path: root/git-compat-util.h
diff options
authorAndreas Ericsson <>2007-11-10 11:55:48 (GMT)
committerJunio C Hamano <>2007-11-11 20:10:35 (GMT)
commit9e79f00f06a5500b30941e6925adda070504e6cf (patch)
tree16c6e6ce8b4cbe33d845ae2ff0fe9bbd9873800b /git-compat-util.h
parentb9c62321380374d09cc99570cdd1390674532832 (diff)
Simplify strchrnul() compat code
strchrnul() was introduced in glibc in April 1999 and included in glibc-2.1. Checking for that version means the majority of all git users would get to use the optimized version in glibc. Of the remaining few some might get to use a slightly slower version than necessary but probably not slower than what we have today. Unfortunately, __GLIBC_PREREQ() macro was not available in glibc 2.1.1 which was short lived but already supported strchrnul(). Odd minority users of that library needs to live with our compatibility inline version. Rediffed-against-next-by: Rene Scharfe <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'git-compat-util.h')
1 files changed, 7 insertions, 2 deletions
diff --git a/git-compat-util.h b/git-compat-util.h
index e72654b..92d7967 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -183,9 +183,14 @@ void *gitmemmem(const void *haystack, size_t haystacklen,
const void *needle, size_t needlelen);
+#if !defined(__GLIBC_PREREQ) && !__GLIBC_PREREQ(2, 1)
#define strchrnul gitstrchrnul
-char *gitstrchrnul(const char *s, int c);
+static inline char *gitstrchrnul(const char *s, int c)
+ while (*s && *s != c)
+ s++;
+ return (char *)s;
extern void release_pack_memory(size_t, int);