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/strtol.3 | 68 +++++++++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 29 deletions(-) (limited to 'src/lib/libc/stdlib/strtol.3') 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 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $OpenBSD: strtol.3,v 1.13 2003/06/02 20:18:38 millert Exp $ +.\" $OpenBSD: strtol.3,v 1.14 2006/01/13 17:58:09 millert Exp $ .\" -.Dd June 25, 1992 +.Dd January 3, 2006 .Dt STRTOL 3 .Os .Sh NAME .Nm strtol , .Nm strtoll , -.Nm strtoq -.Nd "convert string value to a long or long long integer" +.Nm strtoimax , +.Nm strtoq , +.Nd "convert string value to a long, long long or intmax_t integer" .Sh SYNOPSIS .Fd #include .Fd #include .Ft long .Fn strtol "const char *nptr" "char **endptr" "int base" .Pp -.Fd #include -.Fd #include .Ft long long .Fn strtoll "const char *nptr" "char **endptr" "int base" .Pp +.Fd #include +.Ft intmax_t +.Fn strtoimax "const char *nptr" "char **endptr" "int base" +.Pp .Fd #include .Fd #include .Fd #include @@ -71,6 +74,13 @@ to a .Li long long value. The +.Fn strtoimax +function converts the string in +.Fa nptr +to an +.Li intmax_t +value. +The .Fn strtoq function is a deprecated equivalent of .Fn strtoll @@ -98,7 +108,10 @@ is taken as 10 (decimal) unless the next character is in which case it is taken as 8 (octal). .Pp The remainder of the string is converted to a -.Li long +.Li long , +.Li long long , +or +.Li intmax_t , value in the obvious manner, stopping at the first character which is not a valid digit in the given base. @@ -133,29 +146,25 @@ is on return, the entire string was valid.) .Sh RETURN VALUES The -.Fn strtol -function returns the result of the conversion, +.Fn strtol , +.Fn strtoll , +.Fn strtoimax , +and +.Fn strtoq +functions returns the result of the conversion, unless the value would underflow or overflow. -If an underflow occurs, -.Fn strtol -returns -.Dv LONG_MIN . -If an overflow occurs, -.Fn strtol -returns -.Dv LONG_MAX . -In both cases, +If overflow or underflow occurs, .Va errno is set to -.Er ERANGE . -.Pp -The -.Fn strtoll -function has identical return values except that -.Dv LLONG_MIN -and -.Dv LLONG_MAX -are used to indicate underflow and overflow respectively. +.Er ERANGE +and the function return value is as follows: +.Bl -column -offset indent "strtoimax" "overflow" "underflow" +.It Sy Function Ta Sy overflow Ta Sy underflow +.It Fn strtol Ta Dv LONG_MIN Ta Dv LONG_MAX +.It Fn strtoll Ta Dv LLONG_MIN Ta Dv LLONG_MAX +.It Fn strtoimax Ta Dv INTMAX_MIN Ta Dv INTMAX_MAX +.It Fn strtoq Ta Dv LLONG_MIN Ta Dv LLONG_MAX +.El .Sh EXAMPLES Ensuring that a string is a valid number (i.e., in range and containing no trailing characters) requires clearing @@ -233,9 +242,10 @@ The given string was out of range; the value converted has been clamped. .Xr strtoul 3 .Sh STANDARDS The -.Fn strtol +.Fn strtol , +.Fn strtoll , and -.Fn strtoll +.Fn strtoimax functions conform to .St -ansiC-99 . The -- cgit v1.2.3-55-g6feb