From fa7db5e964775dc39e71661884de9f4f8bde7ef6 Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Sun, 2 Sep 2007 16:24:28 +0200 Subject: [PATCH] Added the AC_FUNC_STRERROR_R check. Even though Posix requires "strerror_r" to return an "int", some systems (e.g. the GNU libc) return a "char *" _and_ ignore the second argument. sstrerror() (in src/common.c) has been changed to be aware of this and handle both cases correctly. Signed-off-by: Sebastian Harl Signed-off-by: Florian Forster --- configure.in | 2 ++ src/common.c | 9 +++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/configure.in b/configure.in index 14fcaa7f..162acd74 100644 --- a/configure.in +++ b/configure.in @@ -424,6 +424,8 @@ AC_CHECK_FUNCS(strchr memcpy strstr strcmp strncmp strncpy strlen) AC_CHECK_FUNCS(strncasecmp strcasecmp) AC_CHECK_FUNCS(openlog syslog closelog) +AC_FUNC_STRERROR_R + AC_CHECK_FUNCS(getpwnam_r) AC_CHECK_FUNCS(getgrnam_r) diff --git a/src/common.c b/src/common.c index 9ebfe27c..f8655a98 100644 --- a/src/common.c +++ b/src/common.c @@ -70,12 +70,17 @@ char *sstrdup (const char *s) return (r); } -/* Don't use the return value of `strerror_r', because the GNU-people got - * inventive there.. -octo */ +/* Even though Posix requires "strerror_r" to return an "int", + * some systems (e.g. the GNU libc) return a "char *" _and_ + * ignore the second argument ... -tokkee */ char *sstrerror (int errnum, char *buf, size_t buflen) { buf[0] = '\0'; +#ifdef STRERROR_R_CHAR_P + buf = strerror_r (errnum, buf, buflen); +#else strerror_r (errnum, buf, buflen); +#endif /* STRERROR_R_CHAR_P */ return (buf); } /* char *sstrerror */ -- 2.11.0