From: Gerhard Sittig Date: Wed, 6 Jun 2018 16:50:26 +0000 (+0200) Subject: main.cpp: straighten the getopt/optind adjustment before openfiles X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=commitdiff_plain;h=6a96e1b2b56b22acd68a92fe554e068f5d42da82 main.cpp: straighten the getopt/optind adjustment before openfiles 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. --- diff --git a/main.cpp b/main.cpp index cdc750aa..780371b9 100644 --- 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;