From 19e63a00346133dcb4d5522a193616746327c19c Mon Sep 17 00:00:00 2001 From: Rainer Keller Date: Mon, 29 Jul 2013 11:24:53 +0200 Subject: Remove argument from list in advance Change-Id: I0ab91bce1f290f3a04f27e776eb88a2a385e87e8 Reviewed-by: Samuli Piippo --- main.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/main.cpp b/main.cpp index 4574542..e8deb74 100644 --- a/main.cpp +++ b/main.cpp @@ -168,35 +168,36 @@ int main(int argc, char **argv) Config config = parseConfigFile(); while (!args.isEmpty()) { - if (args[0] == "--port-range") { - if (args.size() < 2) { - qWarning("--port-range requires a range specification"); + const QString arg(args.takeFirst()); + + if (arg == "--port-range") { + if (args.isEmpty()) { + fprintf(stderr, "--port-range requires a range specification\n"); return 1; } - range = Utils::PortList::fromString(args[1]); - args.removeFirst(); + range = Utils::PortList::fromString(args.takeFirst()); if (!range.hasMore()) { qWarning("Invalid port range"); return 1; } - } else if (args[0] == "--debug-gdb") { + } else if (arg == "--debug-gdb") { useGDB = true; setpgid(0,0); // must be called before setsid() setsid(); - } else if (args[0] == "--debug-qml") { + } else if (arg == "--debug-qml") { useQML = true; - } else if (args[0] == "--stop") { + } else if (arg == "--stop") { stop(); return 0; - } else if (args[0] == "--show-platform") { + } else if (arg == "--show-platform") { printf("base:%s\nplatform:%s\n", config.base.toLocal8Bit().constData(), config.platform.toLocal8Bit().constData()); return 0; } else { + args.prepend(arg); break; } - args.removeFirst(); } if (args.isEmpty()) { -- cgit v1.2.3