summaryrefslogtreecommitdiff
path: root/src/lib/libc/stdlib/strtoul.3
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libc/stdlib/strtoul.3')
-rw-r--r--src/lib/libc/stdlib/strtoul.369
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
72value. 75value.
73The 76The
77.Fn strtoumax
78function converts the string in
79.Fa nptr
80to a
81.Li umaxint_t
82value.
83The
74.Fn strtouq 84.Fn strtouq
75function is a deprecated equivalent of 85function is a deprecated equivalent of
76.Fn strtoull 86.Fn strtoull
@@ -139,32 +149,32 @@ is
139on return, the entire string was valid.) 149on return, the entire string was valid.)
140.Sh RETURN VALUES 150.Sh RETURN VALUES
141The 151The
142.Fn strtoul 152.Fn strtoul ,
143function returns the result of the conversion, 153.Fn strtoull ,
144unless the value would overflow, in which case 154.Fn strtoumax
145.Dv ULONG_MAX 155and
146is returned and 156.Fn strtouq
147.Va errno 157functions return either the result of the conversion or,
148is set to 158if there was a leading minus sign,
149.Er ERANGE . 159the negation of the result of the conversion,
150If there was a leading minus sign, 160unless the original (non-negated) value would overflow.
151.Fn strtoul 161If overflow occurs,
152returns the (unsigned) negation of the absolute value of the number, unless
153the absolute value would overflow.
154In this case,
155.Fn strtoul 162.Fn strtoul
156returns 163returns
157.Dv ULONG_MAX 164.Dv ULONG_MAX ,
158and sets the global variable
159.Va errno
160to
161.Er ERANGE .
162.Pp
163The
164.Fn strtoull 165.Fn strtoull
165function has identical return values except that 166returns
167.Dv ULLONG_MAX ,
168.Fn strtoumax
169returns
170.Dv UINTMAX_MAX ,
171.Fn strtouq
172returns
166.Dv ULLONG_MAX 173.Dv ULLONG_MAX
167is used to indicate overflow. 174and the global variable
175.Va errno
176is set to
177.Er ERANGE .
168.Pp 178.Pp
169There is no way to determine if 179There 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
219The 229The
220.Fn strtoul 230.Fn strtoul ,
231.Fn strtoull ,
221and 232and
222.Fn strtoull 233.Fn strtoumax
223functions conform to 234functions conform to
224.St -ansiC-99 . 235.St -ansiC-99 .
225The 236The