-
Notifications
You must be signed in to change notification settings - Fork 14
Better strtoul and printf precision for strings #13
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
Better strtoul and printf precision for strings #13
Conversation
|
As each implementation can come from a different place, the general rule is to put the licence information into each file. You've removed my copyright and Blue Oak Model Licence statement from strtoul, which is fair as you've also removed the implementation. But you've stated above the implementation is copied from libiberty, which has licence text at the top that you need to follow. Specifically: I am not a lawyer, but doing a source conversion from C to Rust and publishing the result would appear to me to be a copyright violation unless performed within the licence terms offered. |
|
The licence also needs to be added to LICENCES.md |
|
I'm also not a lawyer, so I'll just add the license info |
|
Oh well, this is strange. Atoi fails on Linux but not on my Windows... |
|
Should be good now |
src/strtoul.rs
Outdated
| // Rust doesn't support "\f" | ||
| const FEED: u8 = 0x0C; | ||
| const SPACE_CHARACTERS: [u8; 6] = [b' ', b'\n', b'\t', VERTICAL_TAB, FEED, b'\r']; | ||
| SPACE_CHARACTERS |
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.
SPACE_CHARACTERS.contains(&argument) would match the other functions.
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.
True, fixed it
|
Oh, whoops, forgot to fmt |
|
So ehh, do I have to merge this? It's been approved, but I don't see a button for me to click. Or does somebody else need to? |
|
I guess I need to? |
I should have contributed earlier because that would've saved people some work.
Anyways, I worked on this while updating nrfxlib and making a new async wrapper around it.
I think the current
strtoulimplementation is wrong. It only takes a single string parameter while the real function has more: https://cplusplus.com/reference/cstdlib/strtoul/My implementation is a port from a C implementation I found (I believe it was from this one: https://github.com/gcc-mirror/gcc/blob/master/libiberty/strtoul.c)
Also I made string precision support for the printf function.
Nrfxlib has a new API for AT commands where it calls printf. I want the users to not have to care about putting in a null byte after all their AT command strings. So I need a way to print up until a given length instead of up until a null byte. See the usage here: https://github.com/diondokter/nrf-modem/blob/c4a01f5062b86771df57fc283a5d4c82f24eec39/src/at.rs#L163-L169