Re: [PATCH] Simplify strchrnul() compat code
- From
Jakub Narebski <jnareb@gmail.com>
- Date
- Nov 12, 2007, 10:07 UTC
- Message-ID
- <fh98ku$da6$1@ger.gmane.org>
- In-Reply-To
- <ee77f5c20711120152i4955ed3bh484c9ac76a7f1f5c@mail.gmail.com>
David Symonds wrote:
> On Nov 12, 2007 8:50 PM, Johannes Sixt <j.sixt@viscovery.net> wrote:
Show 14 quoted lines
>> -#if !defined(__GLIBC_PREREQ) && !__GLIBC_PREREQ(2, 1)
>> +#ifdef __GLIBC_PREREQ
>> +#if __GLIBC_PREREQ(2, 1)
>> +#define HAVE_STRCHRNUL
>> +#endif
>> +#endif
>> +
>> +#ifndef HAVE_STRCHRNUL
>>
>> #define strchrnul gitstrchrnul
>> static inline char *gitstrchrnul(const char *s, int c)
>> {
>
> Yep, that works just fine. Ack.This version has also the following advantage that you can set HAVE_STRCHRNULL if above test does not detect it in your library.
Althought you'd better write then:
+#if __GLIBC_PREREQ(2, 1) && !defined(HAVE_STRCHRNUL)
Ack.
-- Jakub Narebski Warsaw, Poland ShadeHawk on #git