aboutsummaryrefslogtreecommitdiff
path: root/lib/libc/stdlib/strtol.3
diff options
context:
space:
mode:
authorAndrey A. Chernov <ache@FreeBSD.org>2001-09-04 16:39:11 +0000
committerAndrey A. Chernov <ache@FreeBSD.org>2001-09-04 16:39:11 +0000
commit4e6b1570629ce55fb6038c1d7ea2400c0a47a8a4 (patch)
tree7bcee0477a1db7819fa0b437d2bfb0714a1119df /lib/libc/stdlib/strtol.3
parentd6669bbcc23dde3f89519a5c2c10ca43fe24d6b7 (diff)
downloadsrc-4e6b1570629ce55fb6038c1d7ea2400c0a47a8a4.tar.gz
src-4e6b1570629ce55fb6038c1d7ea2400c0a47a8a4.zip
Locale *is* used in strto*l*(), at least for isspace(), so remove
'locale not used' statement from comments and BUGS section of manpage. strtol(): fix non-portable 'cutoff' calculation using the same method as in strtoll(). Cleanup 'cutoff' calculation, remove unneded casts. Misc. cleanup to make all functions looks the same. Implement EINVAL reaction per POSIX, document it in manpage, corresponding POSIX example quotes here: ------------------------------------------------ If the subject sequence is empty or does not have the expected form, no conversion is performed; the value of str is stored in the object pointed to by endptr, provided that endptr is not a null pointer. If no conversion could be performed, 0 shall be returned and errno may be set to [EINVAL]. [EINVAL] The value of base is not supported. Since 0, {LONG_MIN} or {LLONG_MIN}, and {LONG_MAX} or {LLONG_MAX} are returned on error and are also valid returns on success, an application wishing to check for error situations should set errno to 0, then call strtol( ) or strtoll ( ), then check errno. -----------------------------------------------------
Notes
Notes: svn path=/head/; revision=82975
Diffstat (limited to 'lib/libc/stdlib/strtol.3')
-rw-r--r--lib/libc/stdlib/strtol.317
1 files changed, 10 insertions, 7 deletions
diff --git a/lib/libc/stdlib/strtol.3 b/lib/libc/stdlib/strtol.3
index 00a65c58c433..1ee6add80fa8 100644
--- a/lib/libc/stdlib/strtol.3
+++ b/lib/libc/stdlib/strtol.3
@@ -144,9 +144,16 @@ on return, the entire string was valid.)
.Sh RETURN VALUES
The
.Fn strtol
+or
+.Fn strtoll
function
returns the result of the conversion,
unless the value would underflow or overflow.
+If no conversion could be performed, 0 shall be returned and
+.Va errno
+will be
+set to
+.Er EINVAL .
If an underflow occurs,
.Fn strtol
returns
@@ -155,11 +162,6 @@ If an overflow occurs,
.Fn strtol
returns
.Dv LONG_MAX .
-The
-.Fn strtoll
-function
-returns the result of the conversion,
-unless the value would underflow or overflow.
If an underflow occurs,
.Fn strtoll
returns
@@ -174,6 +176,9 @@ is set to
.Er ERANGE .
.Sh ERRORS
.Bl -tag -width Er
+.It Bq Er EINVAL
+The value of base is not supported or
+no conversion could be performed.
.It Bq Er ERANGE
The given string was out of range; the value converted has been clamped.
.El
@@ -198,5 +203,3 @@ The
.Bx
.Fn strtoq
function is deprecated.
-.Sh BUGS
-Ignores the current locale.