Front page | perl.perl5.porters |
Postings from July 2014
From: Jarkko Hietaniemi
July 23, 2014 03:05
Message ID: 53CF266D.email@example.com
In 6313e544..f4379102 I implement a new rabid^Wthoughtful
interface for parsing unsigned integers. This was then used
to replace the uses of atoi/atoll?/strtoll?/strtoull? in the core.
atoi is notoriously bad in detecting failures, it cannot be used
for incremental parsing ("how far did we get?"), and to top it all,
it believes locale settings (at least the amusingly badly named
"thousands separator", maybe even isdigit?).
strtol family is much better in the first two items, but it fails the
The new interface is called "grok_atou" (the branch name was
"krakatau"... I'll be here all week, folks, please tip the waiters).
It *only* handles unsigned integers (Size_t), by design. If fancy
features like negative inputs or optional leading whitespace are
required-- use the C, Luke.
I extended my new toy, t/porting/libperl.t, to detect and punish if
someone attempts to reintroduce any of the atoi/atol/strtoblah back to
For earlier discussion, see:
grok_atou is completely new code, instead of trying to bolt
new parameters/flags to grok_number. This makes it easier to
be extremely strict, and not worry about breaking grok_number.
by Jarkko Hietaniemi