-
Notifications
You must be signed in to change notification settings - Fork 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
native: prettify argument parsing #6337
Conversation
151ec76
to
44240e3
Compare
44240e3
to
e9d13d7
Compare
Honestly I can't remember why I chose to do so. Probably I was just too lazy. The reason why I did not change it is that it does not make that much of a difference IMHO. It's not like this is on a hot path or something ;) Another reason might be that historically this information was also used in a different module and this made the internal API simpler. Look at the git history if you are really interested and not just trying to troll me :-p |
You have my general blessing for making the long due switch to getopt per se ;) However I do not have time to carefully test, or capacity to think through it though. |
Not trying to troll you, just honest bewilderment. Seems like it was laziness after all (or because of stuff you never commited), since it is like this basically since its inception in 864267f |
Actually this is what I had in mind when I wrote:
Modules are cpu and board in this case. |
Did someone check on BSD or OSX? @kYc0o, @emmanuelsearch, @smlng? |
|
||
switch (stdiotype) { | ||
case _STDIOTYPE_STDIO: | ||
return -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.
Maybe you change this to a nice ERRNO?
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.
It's native internal and I just check if an error accured. I don't see the point to use an errno here.
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.
I thought it would ease refactoring to have macro constant instead of a literal, but no strong opinion.
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.
It's just this internal function and the check is either <0
or =0
, so even if there is refactoring needed in the future, it shouldn't be that extensive. ;-)
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.
Remember: we are talking about the error-handling of some file-internal function that executes commands by a value that was set due to user input. ;-)
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.
just tested (a little) on macOS: works
what does "a little" mean, did you check long options and short e.g.? |
|
@OlegHahm Go home, you're drunk |
I tested with [edit] for the nit picky: on macOS, of course |
Btw. the elf file grows by about 4kB. |
Just to test both long and short options, because during implementation I wasn't sure |
I find more readable code and easier handling of command-line options actually better for native-only code, than thinking about code-size ;-) |
That's about 5% for More interesting (although probably as insignificant): what's the increase in RAM usage? |
I always found it quite weird how native parses it's command-line arguments. This PR moves that to libc's
getopt_long()
. According to my research this should also be available on OSX and BSD. I also cleaned up some weird state settings (using strings instead of enums oO, what was that about).Reminder to self: fix #6121 and #6311 for this if this PR gets merged.