]> git.saurik.com Git - apple/libc.git/blobdiff - string/FreeBSD/strerror.c
Libc-825.25.tar.gz
[apple/libc.git] / string / FreeBSD / strerror.c
index 7da979614eaaf3de5b8fb91e638609ead9857099..63e81019947f0f37873fedbbc145c34c20e50c4b 100644 (file)
@@ -52,12 +52,13 @@ __FBSDID("$FreeBSD: src/lib/libc/string/strerror.c,v 1.16 2007/01/09 00:28:12 im
  */
 #define        EBUFSIZE        (20 + 2 + sizeof(UPREFIX))
 
+#ifndef BUILDING_VARIANT
 /*
  * Doing this by hand instead of linking with stdio(3) avoids bloat for
  * statically linked binaries.
  */
-static void
-errstr(int num, char *uprefix, char *buf, size_t len)
+__private_extern__ void
+__errstr(int num, char *uprefix, char *buf, size_t len)
 {
        char *t;
        unsigned int uerr;
@@ -87,8 +88,8 @@ strerror_r(int errnum, char *strerrbuf, size_t buflen)
        catd = catopen("libc", NL_CAT_LOCALE);
 #endif
 
-       if (errnum < 1 || errnum >= sys_nerr) {
-               errstr(errnum,
+       if (errnum < 0 || errnum >= sys_nerr) {
+               __errstr(errnum,
 #if defined(NLS)
                        catgets(catd, 1, 0xffff, UPREFIX),
 #else
@@ -114,13 +115,20 @@ strerror_r(int errnum, char *strerrbuf, size_t buflen)
 
        return (retval);
 }
+#else /* BUILDING_VARIANT */
+__private_extern__ void __errstr(int, char *, size_t);
+#endif /* !BUILDING_VARIANT */
 
 char *
 strerror(int num)
 {
        static char ebuf[NL_TEXTMAX];
 
+#if !__DARWIN_UNIX03
        if (strerror_r(num, ebuf, sizeof(ebuf)) != 0)
        errno = EINVAL;
+#else
+       (void)strerror_r(num, ebuf, sizeof(ebuf));
+#endif
        return (ebuf);
 }