]>
Commit | Line | Data |
---|---|---|
1f2f436a A |
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/ | |
224c7076 | 4 | */ |
1f2f436a | 5 | #define EBUFSIZE (20 + 2 + sizeof(UPREFIX)) |
224c7076 A |
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 | |
1f2f436a | 13 | -errstr(int num, char *uprefix, char *buf, size_t len) |
224c7076 | 14 | +__private_extern__ void |
1f2f436a | 15 | +__errstr(int num, char *uprefix, char *buf, size_t len) |
224c7076 A |
16 | { |
17 | char *t; | |
18 | unsigned int uerr; | |
1f2f436a A |
19 | @@ -87,8 +88,8 @@ strerror_r(int errnum, char *strerrbuf, |
20 | catd = catopen("libc", NL_CAT_LOCALE); | |
21 | #endif | |
224c7076 A |
22 | |
23 | - if (errnum < 1 || errnum >= sys_nerr) { | |
1f2f436a | 24 | - errstr(errnum, |
224c7076 | 25 | + if (errnum < 0 || errnum >= sys_nerr) { |
1f2f436a A |
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); | |
224c7076 A |
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) | |
1f2f436a A |
40 | { |
41 | static char ebuf[NL_TEXTMAX]; | |
224c7076 | 42 | |
224c7076 | 43 | +#if !__DARWIN_UNIX03 |
1f2f436a | 44 | if (strerror_r(num, ebuf, sizeof(ebuf)) != 0) |
224c7076 | 45 | errno = EINVAL; |
1f2f436a A |
46 | +#else |
47 | + (void)strerror_r(num, ebuf, sizeof(ebuf)); | |
48 | +#endif | |
224c7076 A |
49 | return (ebuf); |
50 | } |