diff options
| author | schwarze <> | 2017-09-05 03:16:14 +0000 |
|---|---|---|
| committer | schwarze <> | 2017-09-05 03:16:14 +0000 |
| commit | ee3d993af12eabdf8fd0c5434438a911a4285f8b (patch) | |
| tree | d7f851bfa426cf869a3a3aec05ffba386b6f2ce5 /src/lib/libc/string/strerror.3 | |
| parent | 03cdb5baba30326ba37cf707fc3767747ee4173e (diff) | |
| download | openbsd-ee3d993af12eabdf8fd0c5434438a911a4285f8b.tar.gz openbsd-ee3d993af12eabdf8fd0c5434438a911a4285f8b.tar.bz2 openbsd-ee3d993af12eabdf8fd0c5434438a911a4285f8b.zip | |
New POSIX xlocale implementation written from scratch.libressl-v2.6.1
Complete in the sense that all POSIX *locale(3) and *_l(3) functions
are included, but in OpenBSD, we of course only really care about
LC_CTYPE and we only support ASCII and UTF-8.
With important help from kettenis@, guenther@, and jca@.
Repeated testing in ports bulk builds by naddy@.
Additional testing by jca@, sebastia@, dcoppa@, and others.
OK kettenis@ dcoppa@, and guenther@ on an earlier version.
Riding guenther@'s libc/librthread major bump.
Diffstat (limited to 'src/lib/libc/string/strerror.3')
| -rw-r--r-- | src/lib/libc/string/strerror.3 | 75 |
1 files changed, 52 insertions, 23 deletions
diff --git a/src/lib/libc/string/strerror.3 b/src/lib/libc/string/strerror.3 index 8b2d32ea75..0d4f084e5e 100644 --- a/src/lib/libc/string/strerror.3 +++ b/src/lib/libc/string/strerror.3 | |||
| @@ -1,4 +1,7 @@ | |||
| 1 | .\" $OpenBSD: strerror.3,v 1.15 2017/09/05 03:16:13 schwarze Exp $ | ||
| 2 | .\" | ||
| 1 | .\" Copyright (c) 1980, 1991 Regents of the University of California. | 3 | .\" Copyright (c) 1980, 1991 Regents of the University of California. |
| 4 | .\" Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org> | ||
| 2 | .\" All rights reserved. | 5 | .\" All rights reserved. |
| 3 | .\" | 6 | .\" |
| 4 | .\" This code is derived from software contributed to Berkeley by | 7 | .\" This code is derived from software contributed to Berkeley by |
| @@ -29,46 +32,61 @@ | |||
| 29 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 32 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 30 | .\" SUCH DAMAGE. | 33 | .\" SUCH DAMAGE. |
| 31 | .\" | 34 | .\" |
| 32 | .\" $OpenBSD: strerror.3,v 1.14 2014/11/30 21:21:59 schwarze Exp $ | 35 | .Dd $Mdocdate: September 5 2017 $ |
| 33 | .\" | ||
| 34 | .Dd $Mdocdate: November 30 2014 $ | ||
| 35 | .Dt STRERROR 3 | 36 | .Dt STRERROR 3 |
| 36 | .Os | 37 | .Os |
| 37 | .Sh NAME | 38 | .Sh NAME |
| 38 | .Nm strerror , | 39 | .Nm strerror , |
| 40 | .Nm strerror_l , | ||
| 39 | .Nm strerror_r | 41 | .Nm strerror_r |
| 40 | .Nd get error message string | 42 | .Nd get error message string |
| 41 | .Sh SYNOPSIS | 43 | .Sh SYNOPSIS |
| 42 | .In string.h | 44 | .In string.h |
| 43 | .Ft char * | 45 | .Ft char * |
| 44 | .Fn strerror "int errnum" | 46 | .Fn strerror "int errnum" |
| 47 | .Ft char * | ||
| 48 | .Fn strerror_l "int errnum" "locale_t locale" | ||
| 45 | .Ft int | 49 | .Ft int |
| 46 | .Fn strerror_r "int errnum" "char *strerrbuf" "size_t buflen" | 50 | .Fn strerror_r "int errnum" "char *strerrbuf" "size_t buflen" |
| 47 | .Sh DESCRIPTION | 51 | .Sh DESCRIPTION |
| 48 | The | 52 | These functions map the error number |
| 49 | .Fn strerror | ||
| 50 | and | ||
| 51 | .Fn strerror_r | ||
| 52 | functions map the error number | ||
| 53 | .Fa errnum | 53 | .Fa errnum |
| 54 | to a language-dependent error message string. | 54 | to an error message string. |
| 55 | .Pp | 55 | .Pp |
| 56 | .Fn strerror | 56 | .Fn strerror |
| 57 | returns a string containing a maximum of | 57 | and |
| 58 | .Fn strerror_l | ||
| 59 | return a string containing a maximum of | ||
| 58 | .Dv NL_TEXTMAX | 60 | .Dv NL_TEXTMAX |
| 59 | characters, including the trailing NUL. | 61 | characters, including the trailing NUL. |
| 60 | This string is not to be modified by the calling program, | 62 | This string is not to be modified by the calling program. |
| 61 | but may be overwritten by subsequent calls to | 63 | The string returned by |
| 62 | .Fn strerror . | 64 | .Fn strerror |
| 65 | may be overwritten by subsequent calls to | ||
| 66 | .Fn strerror | ||
| 67 | in any thread. | ||
| 68 | The string returned by | ||
| 69 | .Fn strerror_l | ||
| 70 | may be overwritten by subsequent calls to | ||
| 71 | .Fn strerror_l | ||
| 72 | in the same thread. | ||
| 63 | .Pp | 73 | .Pp |
| 64 | .Fn strerror_r | 74 | .Fn strerror_r |
| 65 | is a thread safe version of | 75 | is a thread safe version of |
| 66 | .Fn strerror | 76 | .Fn strerror |
| 67 | that places the error message in the specified buffer | 77 | that places the error message in the specified buffer |
| 68 | .Fa strerrbuf . | 78 | .Fa strerrbuf . |
| 79 | .Pp | ||
| 80 | On | ||
| 81 | .Ox , | ||
| 82 | the global locale, the thread-specific locale, and the | ||
| 83 | .Fa locale | ||
| 84 | argument are ignored. | ||
| 69 | .Sh RETURN VALUES | 85 | .Sh RETURN VALUES |
| 70 | .Fn strerror | 86 | .Fn strerror |
| 71 | returns a pointer to the error message string. | 87 | and |
| 88 | .Fn strerror_l | ||
| 89 | return a pointer to the error message string. | ||
| 72 | If an error occurs, the error code is stored in | 90 | If an error occurs, the error code is stored in |
| 73 | .Va errno . | 91 | .Va errno . |
| 74 | .Pp | 92 | .Pp |
| @@ -77,11 +95,16 @@ returns zero upon successful completion. | |||
| 77 | If an error occurs, the error code is stored in | 95 | If an error occurs, the error code is stored in |
| 78 | .Va errno | 96 | .Va errno |
| 79 | and the error code is returned. | 97 | and the error code is returned. |
| 80 | .Sh ERRORS | 98 | .Sh ENVIRONMENT |
| 99 | On other operating systems, the behaviour of | ||
| 81 | .Fn strerror | 100 | .Fn strerror |
| 82 | and | 101 | and |
| 83 | .Fn strerror_r | 102 | .Fn strerror_r |
| 84 | may fail if: | 103 | may depend on the |
| 104 | .Dv LC_MESSAGES | ||
| 105 | .Xr locale 1 . | ||
| 106 | .Sh ERRORS | ||
| 107 | All these functions may fail if: | ||
| 85 | .Bl -tag -width Er | 108 | .Bl -tag -width Er |
| 86 | .It Bq Er EINVAL | 109 | .It Bq Er EINVAL |
| 87 | .Fa errnum | 110 | .Fa errnum |
| @@ -91,7 +114,7 @@ The returned error string will consist of an error message that includes | |||
| 91 | .El | 114 | .El |
| 92 | .Pp | 115 | .Pp |
| 93 | .Fn strerror_r | 116 | .Fn strerror_r |
| 94 | may fail if: | 117 | may also fail if: |
| 95 | .Bl -tag -width Er | 118 | .Bl -tag -width Er |
| 96 | .It Bq Er ERANGE | 119 | .It Bq Er ERANGE |
| 97 | The error message is larger than | 120 | The error message is larger than |
| @@ -101,6 +124,7 @@ The message will be truncated to fit. | |||
| 101 | .El | 124 | .El |
| 102 | .Sh SEE ALSO | 125 | .Sh SEE ALSO |
| 103 | .Xr intro 2 , | 126 | .Xr intro 2 , |
| 127 | .Xr newlocale 3 , | ||
| 104 | .Xr perror 3 , | 128 | .Xr perror 3 , |
| 105 | .Xr setlocale 3 | 129 | .Xr setlocale 3 |
| 106 | .Sh STANDARDS | 130 | .Sh STANDARDS |
| @@ -109,15 +133,20 @@ The | |||
| 109 | function conforms to | 133 | function conforms to |
| 110 | .St -isoC-99 . | 134 | .St -isoC-99 . |
| 111 | The | 135 | The |
| 136 | .Fn strerror_l | ||
| 137 | and | ||
| 112 | .Fn strerror_r | 138 | .Fn strerror_r |
| 113 | function conforms to | 139 | functions conform to |
| 114 | .St -p1003.1-2008 . | 140 | .St -p1003.1-2008 . |
| 115 | .Sh HISTORY | 141 | .Sh HISTORY |
| 116 | The | 142 | The |
| 117 | .Fn strerror | 143 | .Fn strerror |
| 118 | function first appeared in | 144 | function has been available since |
| 119 | .Bx 4.3 Reno . | 145 | .Bx 4.3 Reno , |
| 120 | The | ||
| 121 | .Fn strerror_r | 146 | .Fn strerror_r |
| 122 | function first appeared in | 147 | since |
| 123 | .Ox 3.3 . | 148 | .Ox 3.3 , |
| 149 | and | ||
| 150 | .Fn strerror_l | ||
| 151 | since | ||
| 152 | .Ox 6.2 . | ||
