]> sigrok.org Git - pulseview.git/commitdiff
main.cpp: straighten the getopt/optind adjustment before openfiles
authorGerhard Sittig <redacted>
Wed, 6 Jun 2018 16:50:26 +0000 (18:50 +0200)
committerGerhard Sittig <redacted>
Tue, 19 Jun 2018 16:49:50 +0000 (18:49 +0200)
The pulseview(1) application accepts input file specs either as argument
to the -i option, or as positional arguments after the command line options.

Simplify the logic which collects remaining non-option command line words
after getopt(3) is done. As a byproduct the application code no longer
manipulates a variable that is owned by an external library.

main.cpp

index cdc750aa80aade18b21916708463189c78a41f9a..780371b9945b396514ffeac40b0678ebca946a33 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -254,11 +254,11 @@ int main(int argc, char *argv[])
                        break;
                }
        }
+       argc -= optind;
+       argv += optind;
 
-       while (argc - optind > 0) {
-               open_files.push_back(argv[optind]);
-               optind++;
-       }
+       for (int i = 0; i < argc; i++)
+               open_files.push_back(argv[i]);
 
        // Prepare the global settings since logging needs them early on
        pv::GlobalSettings settings;