summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdlib/strtoul.3
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>2006-01-13 17:58:09 +0000
committermillert <millert@openbsd.org>2006-01-13 17:58:09 +0000
commitaa522acb7767a019ec34685ba2d2710fbd672ae7 (patch)
treec7fe2edc0074a72efe96645f2d920f15227a1fad /lib/libc/stdlib/strtoul.3
parentUse long long and intmax_t instead of quad_t throughout. Adapted in (diff)
downloadwireguard-openbsd-aa522acb7767a019ec34685ba2d2710fbd672ae7.tar.xz
wireguard-openbsd-aa522acb7767a019ec34685ba2d2710fbd672ae7.zip
Add lldiv(), imaxabs(), imaxdiv(), strtoimax() and strtoumax()
Diffstat (limited to 'lib/libc/stdlib/strtoul.3')
-rw-r--r--lib/libc/stdlib/strtoul.369
1 files changed, 40 insertions, 29 deletions
diff --git a/lib/libc/stdlib/strtoul.3 b/lib/libc/stdlib/strtoul.3
index 4f6d6a51f9b..2ea5e83297b 100644
--- a/lib/libc/stdlib/strtoul.3
+++ b/lib/libc/stdlib/strtoul.3
@@ -29,27 +29,30 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $OpenBSD: strtoul.3,v 1.15 2003/06/02 20:18:38 millert Exp $
+.\" $OpenBSD: strtoul.3,v 1.16 2006/01/13 17:58:09 millert Exp $
.\"
-.Dd June 25, 1992
+.Dd January 3, 2006
.Dt STRTOUL 3
.Os
.Sh NAME
.Nm strtoul ,
.Nm strtoull ,
+.Nm strtoumax ,
.Nm strtouq
-.Nd "convert a string to an unsigned long or unsigned long long integer"
+.Nd "convert a string to an unsigned long, unsigned long long or uintmax_t integer"
.Sh SYNOPSIS
.Fd #include <stdlib.h>
.Fd #include <limits.h>
.Ft unsigned long
.Fn strtoul "const char *nptr" "char **endptr" "int base"
.Pp
-.Fd #include <stdlib.h>
-.Fd #include <limits.h>
.Ft unsigned long long
.Fn strtoull "const char *nptr" "char **endptr" "int base"
.Pp
+.Fd #include <inttypes.h>
+.Ft uintmax_t
+.Fn strtoumax "const char *nptr" "char **endptr" "int base"
+.Pp
.Fd #include <sys/types.h>
.Fd #include <stdlib.h>
.Fd #include <limits.h>
@@ -71,6 +74,13 @@ to an
.Li unsigned long long
value.
The
+.Fn strtoumax
+function converts the string in
+.Fa nptr
+to a
+.Li umaxint_t
+value.
+The
.Fn strtouq
function is a deprecated equivalent of
.Fn strtoull
@@ -139,32 +149,32 @@ is
on return, the entire string was valid.)
.Sh RETURN VALUES
The
-.Fn strtoul
-function returns the result of the conversion,
-unless the value would overflow, in which case
-.Dv ULONG_MAX
-is returned and
-.Va errno
-is set to
-.Er ERANGE .
-If there was a leading minus sign,
-.Fn strtoul
-returns the (unsigned) negation of the absolute value of the number, unless
-the absolute value would overflow.
-In this case,
+.Fn strtoul ,
+.Fn strtoull ,
+.Fn strtoumax
+and
+.Fn strtouq
+functions return either the result of the conversion or,
+if there was a leading minus sign,
+the negation of the result of the conversion,
+unless the original (non-negated) value would overflow.
+If overflow occurs,
.Fn strtoul
returns
-.Dv ULONG_MAX
-and sets the global variable
-.Va errno
-to
-.Er ERANGE .
-.Pp
-The
+.Dv ULONG_MAX ,
.Fn strtoull
-function has identical return values except that
+returns
+.Dv ULLONG_MAX ,
+.Fn strtoumax
+returns
+.Dv UINTMAX_MAX ,
+.Fn strtouq
+returns
.Dv ULLONG_MAX
-is used to indicate overflow.
+and the global variable
+.Va errno
+is set to
+.Er ERANGE .
.Pp
There is no way to determine if
.Fn strtoul
@@ -217,9 +227,10 @@ The given string was out of range; the value converted has been clamped.
.Xr strtol 3
.Sh STANDARDS
The
-.Fn strtoul
+.Fn strtoul ,
+.Fn strtoull ,
and
-.Fn strtoull
+.Fn strtoumax
functions conform to
.St -ansiC-99 .
The