Re:“People who implement new and improved interfaces always ...
by jandrese on Friday September 11, 2015 @12:13PM
(#10204517)
IMHO, "leading zero indicates octal" is as old as it is wrong. There are a handful of cases where this is helpful, and an ocean of cases where it breaks things unexpectedly because someone tried inputting prettyprinted data.
At least with Hex you can't mistake the 0x prefix for anything else.
One of the best features of inet_pton over inet_addr is that the former doesn't do automatic conversions and instead assumes every field is a decimal number. The latter has a hidden trap where 192.168.0.11 is different than 192.168.000.011.
Re:“People who implement new and improved interfaces always ...
by acveilleux on Friday September 11, 2015 @12:59PM
(#10204784)
Yeah, so it's a wrong thing in 2015 where the only significant use of octal is in unix permissions which themselves are only octal because of PDP-7/8.
The 9/18/36-bits architectures have lost but octal conventions of C was made on the PDP-7 (18 bits) and until the early 1980s, 36-bit machines were commercially available (PDP-10.)
Re:“People who implement new and improved interfaces always ...
by SixSigma on Friday September 11, 2015 @06:36PM
(#10206515)
I use octal with tr
Re:“People who implement new and improved interfaces always ...
by victorNicollet on Friday September 11, 2015 @12:20PM
(#10204561)
I agree. Still, that's the behaviour of parse_integer (specifically, base determination in _parse_integer_fixup_radix).
Re:“People who implement new and improved interfaces always ...
by detaro on Friday September 11, 2015 @12:27PM
(#10204596)
It is the specified behavior of the discussed code when not passing in a specified base to parse_integer. Now if that is a needed feature in the example context (or a fixed base of 10 would work as well) I don't know. It is an odd convention though, I agree. Hex I somewhat get, but octal?
Re:“People who implement new and improved interfaces always ...
by victorNicollet on Friday September 11, 2015 @12:27PM
(#10204592)
Unless I'm mistaken, this would treat character '9' as not part of the number string, return zero and advance the string pointer by one.
Re:“People who implement new and improved interfaces always ...
by detaro on Friday September 11, 2015 @12:31PM
(#10204614)
Yeah, you're right. Missed that 0 didn't advance it, only 0x.
Re:“People who implement new and improved interfaces always ...
by tedunangst on Friday September 11, 2015 @01:12PM
(#10204852)
Percentage chance that's what the user desires?
But that is parsed as "0" and the 9 is left in the string.