Fix commandline option parsing

This commit is contained in:
David Sansome 2010-06-18 00:31:54 +00:00
parent 4c938c0da1
commit 28505857fc

View File

@ -21,8 +21,8 @@
#include <getopt.h> #include <getopt.h>
#include <iostream> #include <iostream>
#include <QFileInfo>
#include <QBuffer> #include <QBuffer>
#include <QFileInfo>
const char* CommandlineOptions::kHelpText = const char* CommandlineOptions::kHelpText =
"%1: clementine [%2] [%3]\n" "%1: clementine [%2] [%3]\n"
@ -100,10 +100,9 @@ bool CommandlineOptions::Parse() {
}; };
// Parse the arguments // Parse the arguments
int option_index = 0;
bool ok = false; bool ok = false;
forever { forever {
int c = getopt_long(argc_, argv_, "hptusrfv:alk:oe:", kOptions, &option_index); int c = getopt_long(argc_, argv_, "hptusrfv:alk:oe:", kOptions, NULL);
// End of the options // End of the options
if (c == -1) if (c == -1)
@ -208,7 +207,7 @@ bool CommandlineOptions::Parse() {
} }
// Get any filenames or URLs following the arguments // Get any filenames or URLs following the arguments
for (int i=option_index+1 ; i<argc_ ; ++i) { for (int i=optind+1 ; i<argc_ ; ++i) {
QString value = QString::fromLocal8Bit(argv_[i]); QString value = QString::fromLocal8Bit(argv_[i]);
if (value.contains("://")) if (value.contains("://"))
urls_ << value; urls_ << value;