summaryrefslogtreecommitdiff
path: root/numeric.c
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2014-07-21 15:15:42 -0400
committerJarkko Hietaniemi <jhi@iki.fi>2014-07-22 21:31:42 -0400
commit338aa8b061f430c2b3d9deaeed0aec523639aff7 (patch)
tree701139243fc4530fa33e0e4e53bbf5d4d6005632 /numeric.c
parent999448781bc711c8732271b98a45a724f7357c46 (diff)
downloadperl-338aa8b061f430c2b3d9deaeed0aec523639aff7.tar.gz
Document grok_atou as strtoul replacement.
Diffstat (limited to 'numeric.c')
-rw-r--r--numeric.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/numeric.c b/numeric.c
index d997d1150b..062c7669f4 100644
--- a/numeric.c
+++ b/numeric.c
@@ -789,16 +789,26 @@ Perl_grok_number_flags(pTHX_ const char *pv, STRLEN len, UV *valuep, U32 flags)
/*
=for perlapi
-grok_atou is a safer replacement for atoi.
+grok_atou is a safer replacement for atoi or strtoul.
-(atoi has severe problems with illegal inputs, and should not be used.
-atoi is also affected by locale settings, which can be seen as a bug.)
+atoi has severe problems with illegal inputs, and should not be used.
+
+atoi and strtoul are also affected by locale settings, which can
+be seen as a bug (global state controlled by user environment).
Returns the unsigned value, if a valid one can be parsed.
Only the decimal digits '0'..'9' are accepted.
-Does NOT allow optional leading whitespace, as opposed to atoi.
+As opposed to atoi or strtoul:
+- does NOT allow optional leading whitespace
+- does NOT allow negative inputs
+
+Also rejected:
+- leading plus signs
+- leading zeros (meaning that only "0" is the zero)
+
+Trailing non-digit bytes are allowed if the endptr is non-NULL.
On return the *endptr will contain the pointer to the first non-digit byte.