From 978c3a7e8d11b1e84147c6da7fa5908182dbf6f1 Mon Sep 17 00:00:00 2001 From: millert <> Date: Fri, 13 Jan 2006 17:58:09 +0000 Subject: Add lldiv(), imaxabs(), imaxdiv(), strtoimax() and strtoumax() --- src/lib/libc/stdlib/strtoul.3 | 69 +++++++++++++++++++++++++------------------ 1 file changed, 40 insertions(+), 29 deletions(-) (limited to 'src/lib/libc/stdlib/strtoul.3') 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 @@ .\" 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 .Fd #include .Ft unsigned long .Fn strtoul "const char *nptr" "char **endptr" "int base" .Pp -.Fd #include -.Fd #include .Ft unsigned long long .Fn strtoull "const char *nptr" "char **endptr" "int base" .Pp +.Fd #include +.Ft uintmax_t +.Fn strtoumax "const char *nptr" "char **endptr" "int base" +.Pp .Fd #include .Fd #include .Fd #include @@ -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 -- cgit v1.2.3-55-g6feb