Am 30.11.2015 um 12:29 schrieb Siarhei Siamashka:
With this way of handling command line switches, "sunxi-fel -p -v ..." does not work right. But I guess, this can be fixed later.
I have attached a patch that addresses this - is this the way we want to handle it?
Regards, B. Nortmann -- You received this message because you are subscribed to the Google Groups "linux-sunxi" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
>From 6c2c0a004e87a40cfe4ef22f9d08c63449dff679 Mon Sep 17 00:00:00 2001 From: Bernhard Nortmann <[email protected]> Date: Wed, 16 Dec 2015 12:15:47 +0100 Subject: [PATCH sunxi-tools] fel: unify handling of "prefix"-type command line arguments This patch forces relevant options to be placed at the beginning of the command line, but also makes sure that their specific order does not matter. Currently this applies to "-p" (--progress) and "-v" (--verbose). Signed-off-by: Bernhard Nortmann <[email protected]> --- fel.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/fel.c b/fel.c index 12eae4d..fdd6d35 100644 --- a/fel.c +++ b/fel.c @@ -1342,9 +1342,14 @@ int main(int argc, char **argv) exit(1); } - if (argc > 1 && (strcmp(argv[1], "--verbose") == 0 || - strcmp(argv[1], "-v") == 0)) { - verbose = true; + /* process all "prefix"-type arguments first */ + while (argc > 1) { + if (strcmp(argv[1], "--verbose") == 0 || strcmp(argv[1], "-v") == 0) + verbose = true; + else if (strcmp(argv[1], "--progress") == 0 || strcmp(argv[1], "-p") == 0) + pflag_active = true; + else + break; /* no valid (prefix) option detected, exit loop */ argc -= 1; argv += 1; } @@ -1352,17 +1357,13 @@ int main(int argc, char **argv) while (argc > 1 ) { int skip = 1; - if (strcmp(argv[1], "--progress") == 0 || - strcmp(argv[1], "-p") == 0) { - pflag_active = true; - } else if (strncmp(argv[1], "hex", 3) == 0 && argc > 3) { + if (strncmp(argv[1], "hex", 3) == 0 && argc > 3) { aw_fel_hexdump(handle, strtoul(argv[2], NULL, 0), strtoul(argv[3], NULL, 0)); skip = 3; } else if (strncmp(argv[1], "dump", 4) == 0 && argc > 3) { aw_fel_dump(handle, strtoul(argv[2], NULL, 0), strtoul(argv[3], NULL, 0)); skip = 3; - } else if ((strncmp(argv[1], "exe", 3) == 0 && argc > 2) - ) { + } else if (strncmp(argv[1], "exe", 3) == 0 && argc > 2) { aw_fel_execute(handle, strtoul(argv[2], NULL, 0)); skip=3; } else if (strncmp(argv[1], "ver", 3) == 0 && argc > 1) { -- 2.4.6
