pixel / hexedit

View and edit files in hexadecimal or in ASCII
http://rigaux.org/hexedit.html
GNU General Public License v2.0
98 stars 41 forks source link

1.7 - Better arg parsing #71

Open bradenbest opened 3 months ago

bradenbest commented 3 months ago

Feel free to review my changes. I'm not used to automake/m4, but I think I got everything. I even logged my changes in the changelog, which I've duplicated above (that's just how I format my commits).

I made an effort to keep the style as similar to yours as possible. I observed camelCase, 2-space indent and next line braces. I did break the rules in a couple places, namely parseArg_matchOpt. The underscores are a "pseudo namespace". I think it's reasonable. I also added one type, ParseArgCallbackFn, in PascalCase because I assume that's the convention (PascalCase for types, camelCase for functions and variables).

I tried to keep the changes small in scope, which is why the LUT in parseArg is an anonymous struct and why there aren't any enums, like for the return value of parseArg_matchOpt.

The new arg parser loop doesn't behave completely identically to the old one, but the changes I made are sane and reasonable. For example, the order no longer matters, you can do filename -s or -s filename. There was also some stipulation about throwing the usage if argc > 1 after the arg parser loop is done. I did away with that. I was careful to preserve the behavior when fileName is NULL: the program will make one attempt to obtain it interactively (findFile), and then either exit with an error message or open the file.

That's about all that comes to mind. Nice app! -Braden Best (bradenbest)

edit: fixes #70

bradenbest commented 3 months ago

Oh, I forgot to include this in the commit: fixes #70

bradenbest commented 3 months ago

okay, not sure what happened to the manpage edit. The changes were basically:

The fact that the 1.7 is the only change that persists tells me that it's autogenerated by the build system. So that's one thing I messed up. Alas, I'm not sure what to change to make it stick.

Here's what the manpage on my system looks like after I manually edited it: image