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/strtoul.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/strtoul.3')
-rw-r--r-- | src/lib/libc/stdlib/strtoul.3 | 69 |
1 files changed, 40 insertions, 29 deletions
diff --git a/src/lib/libc/stdlib/strtoul.3 b/src/lib/libc/stdlib/strtoul.3 index 4f6d6a51f9..2ea5e83297 100644 --- a/src/lib/libc/stdlib/strtoul.3 +++ b/src/lib/libc/stdlib/strtoul.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: strtoul.3,v 1.15 2003/06/02 20:18:38 millert Exp $ | 32 | .\" $OpenBSD: strtoul.3,v 1.16 2006/01/13 17:58:09 millert Exp $ |
33 | .\" | 33 | .\" |
34 | .Dd June 25, 1992 | 34 | .Dd January 3, 2006 |
35 | .Dt STRTOUL 3 | 35 | .Dt STRTOUL 3 |
36 | .Os | 36 | .Os |
37 | .Sh NAME | 37 | .Sh NAME |
38 | .Nm strtoul , | 38 | .Nm strtoul , |
39 | .Nm strtoull , | 39 | .Nm strtoull , |
40 | .Nm strtoumax , | ||
40 | .Nm strtouq | 41 | .Nm strtouq |
41 | .Nd "convert a string to an unsigned long or unsigned long long integer" | 42 | .Nd "convert a string to an unsigned long, unsigned long long or uintmax_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 unsigned long | 46 | .Ft unsigned long |
46 | .Fn strtoul "const char *nptr" "char **endptr" "int base" | 47 | .Fn strtoul "const char *nptr" "char **endptr" "int base" |
47 | .Pp | 48 | .Pp |
48 | .Fd #include <stdlib.h> | ||
49 | .Fd #include <limits.h> | ||
50 | .Ft unsigned long long | 49 | .Ft unsigned long long |
51 | .Fn strtoull "const char *nptr" "char **endptr" "int base" | 50 | .Fn strtoull "const char *nptr" "char **endptr" "int base" |
52 | .Pp | 51 | .Pp |
52 | .Fd #include <inttypes.h> | ||
53 | .Ft uintmax_t | ||
54 | .Fn strtoumax "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 an | |||
71 | .Li unsigned long long | 74 | .Li unsigned long long |
72 | value. | 75 | value. |
73 | The | 76 | The |
77 | .Fn strtoumax | ||
78 | function converts the string in | ||
79 | .Fa nptr | ||
80 | to a | ||
81 | .Li umaxint_t | ||
82 | value. | ||
83 | The | ||
74 | .Fn strtouq | 84 | .Fn strtouq |
75 | function is a deprecated equivalent of | 85 | function is a deprecated equivalent of |
76 | .Fn strtoull | 86 | .Fn strtoull |
@@ -139,32 +149,32 @@ is | |||
139 | on return, the entire string was valid.) | 149 | on return, the entire string was valid.) |
140 | .Sh RETURN VALUES | 150 | .Sh RETURN VALUES |
141 | The | 151 | The |
142 | .Fn strtoul | 152 | .Fn strtoul , |
143 | function returns the result of the conversion, | 153 | .Fn strtoull , |
144 | unless the value would overflow, in which case | 154 | .Fn strtoumax |
145 | .Dv ULONG_MAX | 155 | and |
146 | is returned and | 156 | .Fn strtouq |
147 | .Va errno | 157 | functions return either the result of the conversion or, |
148 | is set to | 158 | if there was a leading minus sign, |
149 | .Er ERANGE . | 159 | the negation of the result of the conversion, |
150 | If there was a leading minus sign, | 160 | unless the original (non-negated) value would overflow. |
151 | .Fn strtoul | 161 | If overflow occurs, |
152 | returns the (unsigned) negation of the absolute value of the number, unless | ||
153 | the absolute value would overflow. | ||
154 | In this case, | ||
155 | .Fn strtoul | 162 | .Fn strtoul |
156 | returns | 163 | returns |
157 | .Dv ULONG_MAX | 164 | .Dv ULONG_MAX , |
158 | and sets the global variable | ||
159 | .Va errno | ||
160 | to | ||
161 | .Er ERANGE . | ||
162 | .Pp | ||
163 | The | ||
164 | .Fn strtoull | 165 | .Fn strtoull |
165 | function has identical return values except that | 166 | returns |
167 | .Dv ULLONG_MAX , | ||
168 | .Fn strtoumax | ||
169 | returns | ||
170 | .Dv UINTMAX_MAX , | ||
171 | .Fn strtouq | ||
172 | returns | ||
166 | .Dv ULLONG_MAX | 173 | .Dv ULLONG_MAX |
167 | is used to indicate overflow. | 174 | and the global variable |
175 | .Va errno | ||
176 | is set to | ||
177 | .Er ERANGE . | ||
168 | .Pp | 178 | .Pp |
169 | There is no way to determine if | 179 | There is no way to determine if |
170 | .Fn strtoul | 180 | .Fn strtoul |
@@ -217,9 +227,10 @@ The given string was out of range; the value converted has been clamped. | |||
217 | .Xr strtol 3 | 227 | .Xr strtol 3 |
218 | .Sh STANDARDS | 228 | .Sh STANDARDS |
219 | The | 229 | The |
220 | .Fn strtoul | 230 | .Fn strtoul , |
231 | .Fn strtoull , | ||
221 | and | 232 | and |
222 | .Fn strtoull | 233 | .Fn strtoumax |
223 | functions conform to | 234 | functions conform to |
224 | .St -ansiC-99 . | 235 | .St -ansiC-99 . |
225 | The | 236 | The |