X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=include%2Fac%2Fstring.h;h=a6a5ae348c5bbc33e7a92d8b5df991da87746807;hb=b8edf539f21664f84c9acbb006ffa26aa7cd4931;hp=11ddb19489848a0b100b1ec35f63291c610853f7;hpb=dc0eacd40b625258355eea866d62188e5aa7ce3b;p=openldap diff --git a/include/ac/string.h b/include/ac/string.h index 11ddb19489..a6a5ae348c 100644 --- a/include/ac/string.h +++ b/include/ac/string.h @@ -2,7 +2,7 @@ /* $OpenLDAP$ */ /* This work is part of OpenLDAP Software . * - * Copyright 1998-2005 The OpenLDAP Foundation. + * Copyright 1998-2013 The OpenLDAP Foundation. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -89,19 +89,30 @@ int (strncasecmp)(); else AC_MEMCPY( (d), (s), (n) ); \ } while(0) +#ifdef NEED_MEMCMP_REPLACEMENT + int (lutil_memcmp)(const void *b1, const void *b2, size_t len); +#define memcmp lutil_memcmp +#endif + +void *(lutil_memrchr)(const void *b, int c, size_t n); +/* GNU extension (glibc >= 2.1.91), only declared when defined(_GNU_SOURCE) */ +#if defined(HAVE_MEMRCHR) && defined(_GNU_SOURCE) +#define lutil_memrchr(b, c, n) memrchr(b, c, n) +#endif /* ! HAVE_MEMRCHR */ + #define STRLENOF(s) (sizeof(s)-1) #if defined( HAVE_NONPOSIX_STRERROR_R ) # define AC_STRERROR_R(e,b,l) (strerror_r((e), (b), (l))) #elif defined( HAVE_STRERROR_R ) -# define AC_STRERROR_R(e,b,l) (strerror_r((e), (b), (l)) ? (b) : NULL) +# define AC_STRERROR_R(e,b,l) (strerror_r((e), (b), (l)) == 0 ? (b) : "Unknown error") #elif defined( HAVE_SYS_ERRLIST ) # define AC_STRERROR_R(e,b,l) ((e) > -1 && (e) < sys_nerr \ - ? sys_errlist[(e)] : NULL ) + ? sys_errlist[(e)] : "Unknown error" ) #elif defined( HAVE_STRERROR ) -# define AC_STRERROR_R(e,b,l) (strerror(e)) +# define AC_STRERROR_R(e,b,l) (strerror(e)) /* NOTE: may be NULL */ #else -# define AC_STRERROR_R(e,b,l) (NULL) +# define AC_STRERROR_R(e,b,l) ("Unknown error") #endif #endif /* _AC_STRING_H */