diff options
author | millert <> | 2006-01-13 17:58:09 +0000 |
---|---|---|
committer | millert <> | 2006-01-13 17:58:09 +0000 |
commit | 978c3a7e8d11b1e84147c6da7fa5908182dbf6f1 (patch) | |
tree | 302bb25ba83f38b5dc042943f23d0ff80c5d29d5 /src/lib/libc/stdlib/strtol.3 | |
parent | 1e745892f72a6490f4783b86b64e88e0c5c4bf61 (diff) | |
download | openbsd-978c3a7e8d11b1e84147c6da7fa5908182dbf6f1.tar.gz openbsd-978c3a7e8d11b1e84147c6da7fa5908182dbf6f1.tar.bz2 openbsd-978c3a7e8d11b1e84147c6da7fa5908182dbf6f1.zip |
Add lldiv(), imaxabs(), imaxdiv(), strtoimax() and strtoumax()
Diffstat (limited to 'src/lib/libc/stdlib/strtol.3')
-rw-r--r-- | src/lib/libc/stdlib/strtol.3 | 68 |
1 files changed, 39 insertions, 29 deletions
diff --git a/src/lib/libc/stdlib/strtol.3 b/src/lib/libc/stdlib/strtol.3 index 3f5375c5e3..1ba936dd0d 100644 --- a/src/lib/libc/stdlib/strtol.3 +++ b/src/lib/libc/stdlib/strtol.3 | |||
@@ -29,27 +29,30 @@ | |||
29 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 29 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
30 | .\" SUCH DAMAGE. | 30 | .\" SUCH DAMAGE. |
31 | .\" | 31 | .\" |
32 | .\" $OpenBSD: strtol.3,v 1.13 2003/06/02 20:18:38 millert Exp $ | 32 | .\" $OpenBSD: strtol.3,v 1.14 2006/01/13 17:58:09 millert Exp $ |
33 | .\" | 33 | .\" |
34 | .Dd June 25, 1992 | 34 | .Dd January 3, 2006 |
35 | .Dt STRTOL 3 | 35 | .Dt STRTOL 3 |
36 | .Os | 36 | .Os |
37 | .Sh NAME | 37 | .Sh NAME |
38 | .Nm strtol , | 38 | .Nm strtol , |
39 | .Nm strtoll , | 39 | .Nm strtoll , |
40 | .Nm strtoq | 40 | .Nm strtoimax , |
41 | .Nd "convert string value to a long or long long integer" | 41 | .Nm strtoq , |
42 | .Nd "convert string value to a long, long long or intmax_t integer" | ||
42 | .Sh SYNOPSIS | 43 | .Sh SYNOPSIS |
43 | .Fd #include <stdlib.h> | 44 | .Fd #include <stdlib.h> |
44 | .Fd #include <limits.h> | 45 | .Fd #include <limits.h> |
45 | .Ft long | 46 | .Ft long |
46 | .Fn strtol "const char *nptr" "char **endptr" "int base" | 47 | .Fn strtol "const char *nptr" "char **endptr" "int base" |
47 | .Pp | 48 | .Pp |
48 | .Fd #include <stdlib.h> | ||
49 | .Fd #include <limits.h> | ||
50 | .Ft long long | 49 | .Ft long long |
51 | .Fn strtoll "const char *nptr" "char **endptr" "int base" | 50 | .Fn strtoll "const char *nptr" "char **endptr" "int base" |
52 | .Pp | 51 | .Pp |
52 | .Fd #include <inttypes.h> | ||
53 | .Ft intmax_t | ||
54 | .Fn strtoimax "const char *nptr" "char **endptr" "int base" | ||
55 | .Pp | ||
53 | .Fd #include <sys/types.h> | 56 | .Fd #include <sys/types.h> |
54 | .Fd #include <stdlib.h> | 57 | .Fd #include <stdlib.h> |
55 | .Fd #include <limits.h> | 58 | .Fd #include <limits.h> |
@@ -71,6 +74,13 @@ to a | |||
71 | .Li long long | 74 | .Li long long |
72 | value. | 75 | value. |
73 | The | 76 | The |
77 | .Fn strtoimax | ||
78 | function converts the string in | ||
79 | .Fa nptr | ||
80 | to an | ||
81 | .Li intmax_t | ||
82 | value. | ||
83 | The | ||
74 | .Fn strtoq | 84 | .Fn strtoq |
75 | function is a deprecated equivalent of | 85 | function is a deprecated equivalent of |
76 | .Fn strtoll | 86 | .Fn strtoll |
@@ -98,7 +108,10 @@ is taken as 10 (decimal) unless the next character is | |||
98 | in which case it is taken as 8 (octal). | 108 | in which case it is taken as 8 (octal). |
99 | .Pp | 109 | .Pp |
100 | The remainder of the string is converted to a | 110 | The remainder of the string is converted to a |
101 | .Li long | 111 | .Li long , |
112 | .Li long long , | ||
113 | or | ||
114 | .Li intmax_t , | ||
102 | value in the obvious manner, | 115 | value in the obvious manner, |
103 | stopping at the first character which is not a valid digit | 116 | stopping at the first character which is not a valid digit |
104 | in the given base. | 117 | in the given base. |
@@ -133,29 +146,25 @@ is | |||
133 | on return, the entire string was valid.) | 146 | on return, the entire string was valid.) |
134 | .Sh RETURN VALUES | 147 | .Sh RETURN VALUES |
135 | The | 148 | The |
136 | .Fn strtol | 149 | .Fn strtol , |
137 | function returns the result of the conversion, | 150 | .Fn strtoll , |
151 | .Fn strtoimax , | ||
152 | and | ||
153 | .Fn strtoq | ||
154 | functions returns the result of the conversion, | ||
138 | unless the value would underflow or overflow. | 155 | unless the value would underflow or overflow. |
139 | If an underflow occurs, | 156 | If overflow or underflow occurs, |
140 | .Fn strtol | ||
141 | returns | ||
142 | .Dv LONG_MIN . | ||
143 | If an overflow occurs, | ||
144 | .Fn strtol | ||
145 | returns | ||
146 | .Dv LONG_MAX . | ||
147 | In both cases, | ||
148 | .Va errno | 157 | .Va errno |
149 | is set to | 158 | is set to |
150 | .Er ERANGE . | 159 | .Er ERANGE |
151 | .Pp | 160 | and the function return value is as follows: |
152 | The | 161 | .Bl -column -offset indent "strtoimax" "overflow" "underflow" |
153 | .Fn strtoll | 162 | .It Sy Function Ta Sy overflow Ta Sy underflow |
154 | function has identical return values except that | 163 | .It Fn strtol Ta Dv LONG_MIN Ta Dv LONG_MAX |
155 | .Dv LLONG_MIN | 164 | .It Fn strtoll Ta Dv LLONG_MIN Ta Dv LLONG_MAX |
156 | and | 165 | .It Fn strtoimax Ta Dv INTMAX_MIN Ta Dv INTMAX_MAX |
157 | .Dv LLONG_MAX | 166 | .It Fn strtoq Ta Dv LLONG_MIN Ta Dv LLONG_MAX |
158 | are used to indicate underflow and overflow respectively. | 167 | .El |
159 | .Sh EXAMPLES | 168 | .Sh EXAMPLES |
160 | Ensuring that a string is a valid number (i.e., in range and containing no | 169 | Ensuring that a string is a valid number (i.e., in range and containing no |
161 | trailing characters) requires clearing | 170 | trailing characters) requires clearing |
@@ -233,9 +242,10 @@ The given string was out of range; the value converted has been clamped. | |||
233 | .Xr strtoul 3 | 242 | .Xr strtoul 3 |
234 | .Sh STANDARDS | 243 | .Sh STANDARDS |
235 | The | 244 | The |
236 | .Fn strtol | 245 | .Fn strtol , |
246 | .Fn strtoll , | ||
237 | and | 247 | and |
238 | .Fn strtoll | 248 | .Fn strtoimax |
239 | functions conform to | 249 | functions conform to |
240 | .St -ansiC-99 . | 250 | .St -ansiC-99 . |
241 | The | 251 | The |