]> git.sur5r.net Git - openldap/blobdiff - include/ac/string.h
Merge remote branch 'origin/mdb.master' into OPENLDAP_REL_ENG_2_4
[openldap] / include / ac / string.h
index c35605ae080b523cc7f4b1eacef123204ac9e076..a6a5ae348c5bbc33e7a92d8b5df991da87746807 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * 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
@@ -94,19 +94,25 @@ int (strncasecmp)();
 #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 */