-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Forbid octal numbers for width parameter #3613
Conversation
Nice to see you here ;) |
Could you please add a test? probably tests/by-util/test_ls.rs |
Maybe it's also good to add a small comment that GNU supports octal, but uutils doesn't (yet). |
I've gone the way I did in code due to the way the ticket was written. We can alternatively go and, for numbers with a leading 0, use https://doc.rust-lang.org/std/primitive.u16.html#method.from_str_radix with a base of 8 for parsing and support octal numbers? Not that I can imagine a good reason for wanting to use octal numbers for width, but meh. Which way preferred, error out or support? |
For now, I was just simply suggesting a comment in the code, just so that somebody who reads the code can understand why we don't allow leading zeros, but supporting it would also be good, I think. Ultimately, I guess we do want to support it for compatibility. |
If the goal is full compatibility, then lets go that way. |
} else { | ||
u | ||
Some(x) => { | ||
if x.starts_with('0') && x.len() > 1 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra check for the len is not technically needed, from_str_radix with a 0 gets us correct results.
But using it we will only use from_str_radix on numbers that truly look octal (0 and one more following) and thje rest, like now, goes through the normal parse function.
This will fix issue #3609