nepx / halfix

x86 PC emulator that runs both natively and in the browser, via WebAssembly
https://nepx.github.io/halfix-demo/
GNU General Public License v3.0
669 stars 86 forks source link

Options handling #22

Closed maronz closed 3 years ago

maronz commented 3 years ago

Hi, I'm quite impressed with what you've done with this project. But I ran into a problem, as I wanted to have a play with the "native" version (on a Linux system). I initially failed to get the '-c' option to work for me.

First up, I believe that the "long" options typically work with a double dash (e.g. '--help'), and the "short" alias with a single dash (e.g. '-h'), which is not what the help text actually shows. This might be addressed via a small change to 'src/main.c':

@@ -51 +51 @@ static void generic_help(const struct op
-        int linelength = sprintf(line, " -%s", o->name);
+        int linelength = sprintf(line, " --%s", o->name);
@@ -53 +53 @@ static void generic_help(const struct op
-            linelength += sprintf(line + linelength, " --%s", o->alias);
+            linelength += sprintf(line + linelength, " -%s", o->alias);

Secondly, the "custom config file" parameter does not get parsed correctly, which I managed to solve for myself (in the same source file) via:

@@ -88 +88 @@ int main(int argc, char** argv)
-                    if (!(data = argv[i++])) {
+                    if (!(data = argv[++i])) {

Cheers, Martin

nepx commented 3 years ago

Thanks for the fix, I believe that everything should be OK now.