]> git.saurik.com Git - apple/libc.git/blob - string/FreeBSD/strerror.c.patch
0b8896074cb00ac1c8ff78c56c0e219246273430
[apple/libc.git] / string / FreeBSD / strerror.c.patch
1 --- strerror.c.orig 2010-10-07 16:06:39.000000000 -0700
2 +++ strerror.c 2010-10-07 16:17:59.000000000 -0700
3 @@ -52,12 +52,13 @@ __FBSDID("$FreeBSD: src/lib/libc/string/
4 */
5 #define EBUFSIZE (20 + 2 + sizeof(UPREFIX))
6
7 +#ifndef BUILDING_VARIANT
8 /*
9 * Doing this by hand instead of linking with stdio(3) avoids bloat for
10 * statically linked binaries.
11 */
12 -static void
13 -errstr(int num, char *uprefix, char *buf, size_t len)
14 +__private_extern__ void
15 +__errstr(int num, char *uprefix, char *buf, size_t len)
16 {
17 char *t;
18 unsigned int uerr;
19 @@ -87,8 +88,8 @@ strerror_r(int errnum, char *strerrbuf,
20 catd = catopen("libc", NL_CAT_LOCALE);
21 #endif
22
23 - if (errnum < 1 || errnum >= sys_nerr) {
24 - errstr(errnum,
25 + if (errnum < 0 || errnum >= sys_nerr) {
26 + __errstr(errnum,
27 #if defined(NLS)
28 catgets(catd, 1, 0xffff, UPREFIX),
29 #else
30 @@ -114,13 +115,20 @@ strerror_r(int errnum, char *strerrbuf,
31
32 return (retval);
33 }
34 +#else /* BUILDING_VARIANT */
35 +__private_extern__ void __errstr(int, char *, size_t);
36 +#endif /* !BUILDING_VARIANT */
37
38 char *
39 strerror(int num)
40 {
41 static char ebuf[NL_TEXTMAX];
42
43 +#if !__DARWIN_UNIX03
44 if (strerror_r(num, ebuf, sizeof(ebuf)) != 0)
45 errno = EINVAL;
46 +#else
47 + (void)strerror_r(num, ebuf, sizeof(ebuf));
48 +#endif
49 return (ebuf);
50 }