Exemplo n.º 1
0
/**
 * Test that the parser correctly parses a choice value.
 */
TEST(choice_option_test, parse_choice)
{
    auto parser = qflags::parser();
    auto option = qflags::choice_option("foo", {"bar", "baz"}, "bar");

    ASSERT_EQ(true, parser.add_argument(&option));
    {
        char const* argv[] = { "--foo", "bar" };
        auto command_line = qflags::command_line(argv);

        std::string errors;

        ASSERT_EQ(true, parser.parse(command_line, &errors));
        EXPECT_EQ("bar", static_cast<std::string>(parser["foo"]));
        EXPECT_EQ("bar", static_cast<std::string>(option));
        EXPECT_EQ(2, parser.argc());
        EXPECT_EQ(0, parser.remaining_argc());
        EXPECT_EQ(0u, errors.length());
    }

    {
        char const* argv[] = { "--foo", "baz" };
        auto command_line = qflags::command_line(argv);

        std::string errors;

        ASSERT_EQ(true, parser.parse(command_line, &errors));
        EXPECT_EQ("baz", static_cast<std::string>(parser["foo"]));
        EXPECT_EQ("baz", static_cast<std::string>(option));
        EXPECT_EQ(2, parser.argc());
        EXPECT_EQ(0, parser.remaining_argc());
        EXPECT_EQ(0u, errors.length());
    }
}
Exemplo n.º 2
0
void
test_parse_args_aio(void)
{
    argv[argc()] = "-A";
    argv[argc()] = dummy_file;
    cut_assert_equal_int(0, parse_args(argc(), argv, &option));
    cut_assert_true(option.aio);
}
Exemplo n.º 3
0
void
test_parse_args_aio_nr_events(void)
{
    argv[argc()] = "-E";
    argv[argc()] = "1024";
    argv[argc()] = dummy_file;
    cut_assert_equal_int(0, parse_args(argc(), argv, &option));
    cut_assert_equal_int(1024, option.aio_nr_events);
}
Exemplo n.º 4
0
void
test_parse_args_aio_trace_fail(void)
{
    const char *tracefile;

    // -T must be specified with -A
    argv[argc()] = "-T";
    argv[argc()] = (char *) cut_take_strdup("tracefileXXXXXX");
    argv[argc()] = dummy_file;
    cut_assert_not_equal_int(0, parse_args(argc(), argv, &option));
}
Exemplo n.º 5
0
void
test_parse_args_aio_trace(void)
{
    const char *tracefile;

    tracefile = cut_take_strdup("tracefileXXXXXX");

    argv[argc()] = "-A";
    argv[argc()] = "-T";
    argv[argc()] = (char *) tracefile;
    argv[argc()] = dummy_file;
    cut_assert_equal_int(0, parse_args(argc(), argv, &option));
    cut_assert_equal_string(tracefile, option.aio_tracefile);
}
Exemplo n.º 6
0
void AQWebApplication::init()
{
  if (initDone_)
    return;
  initDone_ = true;
  aq_web_main(argc(), argv());
}
Exemplo n.º 7
0
void DropDownConsole::parseCommandOnInput()
{
    if (this->commands.size() <= 0) return;

    if (this->currentCommand)
        delete this->currentCommand;

    this->userJustSentACommand = true;

    // See first word of the input buffer and compare with
    // all commands stored in memory
    int i;
    int size = this->commands.size();
    for (i = 0; i < size; i++)
    {
        std::string firstWord = arg(0, this->inputBuffer);

        if (firstWord == this->commands[i]->command)
        {
            this->currentCommand = new Command(this->commands[i]->command,
                                               this->commands[i]->value);

            int argAmmount = argc(this->inputBuffer);

            for (int i = 0; i < argAmmount; i++)
                this->currentCommand->addArgument(arg(i, this->inputBuffer));

            break;
        }
    }
    if (i == size) // no command found
        this->currentCommand = NULL;
}
Exemplo n.º 8
0
SQL_ROW &SQL_ROW::operator =(const SQL_ROW &s) {
  if (this != &s) {
    size_t i;
    std::string *p;
    for (i=0;i<argc();i++) {
      if (pval[i]) {
        delete pval[i];
#ifdef DEBUG_ALLOCATIONS
        fprintf(stderr,"std::string deleted at 0x%p\n",p);
        fflush(stderr);
#endif
      }
    }
    pval.clear();
    for (i=0;i<s.argc();i++) {
      if (s[i]) {
        p=new std::string(*(s[i]));
#ifdef DEBUG_ALLOCATIONS
        fprintf(stderr,"std::string allocated at 0x%p\n",p);
        fflush(stderr);
#endif
      } else {
        p=0;
      }
      pval.push_back(p);
    }
  }
  return *this;
}
Exemplo n.º 9
0
bool Argv::set(int index,const char*value)
{
  if (index>=argc())
    return false;
  FREE(_argv[index]);
  _argv[index]=STRDUP(value);
  return true;
}
Exemplo n.º 10
0
      /*!
       * Get a vector of args.
       *
       * \return an vector of args.
       *
       */
      std::vector< string_type > arg_vector()
      {
         std::vector< string_type > args;
         for (int i = 0; i < argc(); ++i)
            args.push_back(argv()[i]);

         return args;
      }
Exemplo n.º 11
0
        bool checkArg(int i, Checker checker) const
        {
            if (argc() < i)
            {
                return false;
            }

            return checker(_args[i]);
        }
Exemplo n.º 12
0
int TileWorldApp::RunTWorld()
{
	if (!setjmp(m_jmpBuf))	// try
	{
		return tworld(argc(), argv());
	}
	else	// catch (int)
	{
		return 0;
	}
}
Exemplo n.º 13
0
SQL_ROW::~SQL_ROW() {
  size_t i;
  for (i=0;i<argc();i++) {
    if (pval[i]) {
      delete pval[i];
#ifdef DEBUG_ALLOCATIONS
      fprintf(stderr,"std::string deleted at 0x%p\n",pval[i]);
      fflush(stderr);
#endif
    }
    pval[i]=0;
  }
}
Exemplo n.º 14
0
void ossimArgumentParser::reportRemainingOptionsAsUnrecognized(ossimErrorSeverity severity)
{
    std::set<std::string> options;
    if (theUsage)
    {
        // parse the usage options to get all the option that the application can potential handle.
        for(ossimApplicationUsage::UsageMap::const_iterator itr=theUsage->getCommandLineOptions().begin();
            itr!=theUsage->getCommandLineOptions().end();
            ++itr)
        {
            const std::string& option = itr->first;
            std::string::size_type prevpos = 0, pos = 0;
            while ((pos=option.find(' ',prevpos))!=std::string::npos)
            {
                if (option[prevpos]=='-')
                {
                    options.insert(std::string(option,prevpos,pos-prevpos));
                }
                prevpos=pos+1;
            }
            if (option[prevpos]=='-')
            {

                options.insert(std::string(option,prevpos,std::string::npos));
            }
        }

    }

    for(int pos=1;pos<argc();++pos)
    {
        // if an option and havn't been previous querried for report as unrecognized.
        if (isOption(pos) && options.find(theArgv[pos])==options.end())
        {
            reportError(getApplicationName() +": unrecognized option "+theArgv[pos],severity);
        }
    }
}
Exemplo n.º 15
0
void ScribusQApp::parseCommandLine()
{
	showSplash=!neverSplashExists();
	QString arg("");
	bool usage=false;
	bool header=false;
	bool availlangs=false;
	bool version=false;
	bool runUpgradeCheck=false;
	showFontInfo=false;
	showProfileInfo=false;
	swapDialogButtonOrder=false;

	//Parse for command line information options, and lang
	for(int i = 1; i < argc(); i++)
	{
		arg = argv()[i];

		if ((arg == ARG_LANG || arg == ARG_LANG_SHORT) && (++i < argc())) {
			lang = argv()[i];
		}
		else if (arg == ARG_VERSION || arg == ARG_VERSION_SHORT) {
			header=true;
			version=true;
		} else if (arg == ARG_HELP || arg == ARG_HELP_SHORT) {
			header=true;
			usage=true;
		} else if (arg == ARG_AVAILLANG || arg == ARG_AVAILLANG_SHORT) {
			header=true;
			availlangs=true;
		} else if (arg == ARG_UPGRADECHECK || arg == ARG_UPGRADECHECK_SHORT) {
			header=true;
			runUpgradeCheck=true;
		}
	}
	//Init translations
	initLang();
	//Show command line help
	if (header)
		showHeader();
	if (version)
		showVersion();
	if (availlangs)
		showAvailLangs();
	if (usage)
		showUsage();
	if (runUpgradeCheck)
	{
		UpgradeChecker uc;
		uc.fetch();
	}
	//Dont run the GUI init process called from main.cpp, and return
	if (!header)
		useGUI=true;
	else
		return;
	//We are going to run something other than command line help
	for(int i = 1; i < argc(); i++) {
		arg = argv()[i];

		if ((arg == ARG_LANG || arg == ARG_LANG_SHORT) && (++i < argc())) {
			continue;
		} else if ( arg == ARG_CONSOLE || arg == ARG_CONSOLE_SHORT ) {
			continue;
		} else if (arg == ARG_NOSPLASH || arg == ARG_NOSPLASH_SHORT) {
			showSplash = false;
		}
		else if (arg == ARG_NEVERSPLASH || arg == ARG_NEVERSPLASH_SHORT) {
			showSplash = false;
			neverSplash(true);
		} else if (arg == ARG_NOGUI || arg == ARG_NOGUI_SHORT) {
			useGUI=false;
		} else if (arg == ARG_FONTINFO || arg == ARG_FONTINFO_SHORT) {
			showFontInfo=true;
		} else if (arg == ARG_PROFILEINFO || arg == ARG_PROFILEINFO_SHORT) {
			showProfileInfo=true;
		} else if (arg == ARG_SWAPDIABUTTONS || arg == ARG_SWAPDIABUTTONS_SHORT) {
			swapDialogButtonOrder=true;
		} else if ((arg == ARG_DISPLAY || arg==ARG_DISPLAY_SHORT || arg==ARG_DISPLAY_QT) && ++i < argc()) {
			// allow setting of display, QT expect the option -display <display_name> so we discard the
			// last argument. FIXME: Qt only understands -display not --display and -d , we need to work
			// around this.
		} else if (arg == ARG_PREFS || arg == ARG_PREFS_SHORT) {
			prefsUserFile = QFile::decodeName(argv()[i + 1]);
			if (!QFileInfo(prefsUserFile).exists()) {
				showHeader();
				if (fileName.left(1) == "-" || fileName.left(2) == "--") {
					std::cout << tr("Invalid argument: ").toLocal8Bit().data() << fileName.toLocal8Bit().data() << std::endl;
				} else {
					std::cout << tr("File %1 does not exist, aborting.").arg(fileName).toLocal8Bit().data() << std::endl;
				}
				showUsage();
				useGUI=false;
				return;
			} else {
				++i;
			}
		} else if (strncmp(arg.toLocal8Bit().data(),"-psn_",4) == 0)
		{
			// Andreas Vox: Qt/Mac has -psn_blah flags that must be accepted.
		} else {
			fileName = QFile::decodeName(argv()[i]);
			if (!QFileInfo(fileName).exists()) {
				showHeader();
				if (fileName.left(1) == "-" || fileName.left(2) == "--") {
					std::cout << tr("Invalid argument: %1").arg(fileName).toLocal8Bit().data() << std::endl;
				} else {
					std::cout << tr("File %1 does not exist, aborting.").arg(fileName).toLocal8Bit().data() << std::endl;
				}
				showUsage();
				useGUI=false;
				return;
			}
			else
			{
				filesToLoad.append(fileName);
			}
		}
	}
}
Exemplo n.º 16
0
std::string CommandLine::toString() const
{
    return CommandLineProgramContext(argc(), argv()).commandLine();
}
Exemplo n.º 17
0
void ScribusQApp::parseCommandLine()
{
	m_showSplash=!neverSplashExists();
	QString arg("");
	bool usage=false;
	bool header=false;
	bool availlangs=false;
	bool version=false;
	bool runUpgradeCheck=false;
#ifdef WITH_TESTS
	bool runtests = false;
	char** testargsv;
	int testargsc;
#endif
	m_showFontInfo=false;
	m_showProfileInfo=false;	
	bool neversplash = false;

	//Parse for command line options
	// Qt5 port: do this in a Qt compatible manner
	QStringList args = arguments();
	int argsc = args.count();

	useGUI = true;
	int argi = 1;
	for( ; argi < argsc; argi++)
	{ //handle options (not positional parameters)
		arg = args[argi];
		if (arg == ARG_PYTHONSCRIPT || arg == ARG_PYTHONSCRIPT_SHORT)
		{
			if (argi+1 == argsc)
			{
				std::cout << tr("Option %1 requires an argument.").arg(arg).toLocal8Bit().data() << std::endl;
				std::exit(EXIT_FAILURE);
			}
			pythonScript = QFile::decodeName(args[argi + 1].toLocal8Bit());
			if (!QFileInfo(pythonScript).exists())
			{
				std::cout << tr("Python script %1 does not exist, aborting.").arg(pythonScript).toLocal8Bit().data() << std::endl;
				std::exit(EXIT_FAILURE);
			}
			++argi;

			while (++argi < argsc && (args[argi] != CMD_OPTIONS_END))
			{
				pythonScriptArgs.append(args[argi]); // script argument
			}
			// We reached end of all arguments or CMD_OPTIONS_END marker. Stop parsing options
			if (argi < argsc)
			{
				argi++; // skip CMD_OPTIONS_END
			}
			break;
		}
		else if ((arg == ARG_LANG || arg == ARG_LANG_SHORT))
		{
			if  (++argi < argsc)
				m_lang = args[argi];
			else
			{
				std::cout << tr("Option %1 requires an argument.").arg(arg).toLocal8Bit().data() << std::endl;
				std::exit(EXIT_FAILURE);
			}
		}
		else if (arg == ARG_VERSION || arg == ARG_VERSION_SHORT)
		{
			header=true;
			version=true;
		} else if (arg == ARG_HELP || arg == ARG_HELP_SHORT)
		{
			header=true;
			usage=true;
		}
#ifdef WITH_TESTS
		else if (arg == ARG_TESTS || arg == ARG_TESTS_SHORT)
		{
			header=true;
			runtests=true;
			testargsc = argc() - argi;
			testargsv = argv() + argi;
			break;
		}
#endif
		else if (arg == ARG_AVAILLANG || arg == ARG_AVAILLANG_SHORT)
		{
			header=true;
			availlangs=true;
		} else if (arg == ARG_UPGRADECHECK || arg == ARG_UPGRADECHECK_SHORT)
		{
			header=true;
			runUpgradeCheck=true;
		}
		else if ( arg == ARG_CONSOLE || arg == ARG_CONSOLE_SHORT )
		{
			continue;
		} else if (arg == ARG_NOSPLASH || arg == ARG_NOSPLASH_SHORT)
		{
			m_showSplash = false;
		}
		else if (arg == ARG_NEVERSPLASH || arg == ARG_NEVERSPLASH_SHORT)
		{
			m_showSplash = false;
			neversplash = true;
		}
		else if (arg == ARG_NOGUI || arg == ARG_NOGUI_SHORT)
		{
			useGUI=false;
		}
		else if (arg == ARG_FONTINFO || arg == ARG_FONTINFO_SHORT)
		{
			m_showFontInfo=true;
		}
		else if (arg == ARG_PROFILEINFO || arg == ARG_PROFILEINFO_SHORT)
		{
			m_showProfileInfo=true;
		}
		else if ((arg == ARG_DISPLAY || arg==ARG_DISPLAY_SHORT || arg==ARG_DISPLAY_QT) && ++argi < argsc)
		{
			// allow setting of display, QT expect the option -display <display_name> so we discard the
			// last argument. FIXME: Qt only understands -display not --display and -d , we need to work
			// around this.
		}
		else if (arg == ARG_PREFS || arg == ARG_PREFS_SHORT)
		{
			if (argi+1 == argsc)
			{
				std::cout << tr("Option %1 requires an argument.").arg(arg).toLocal8Bit().data() << std::endl;
				std::exit(EXIT_FAILURE);
			}
			m_prefsUserFile = QFile::decodeName(args[argi + 1].toLocal8Bit());
			if (!QFileInfo(m_prefsUserFile).exists())
			{
				std::cout << tr("Preferences file %1 does not exist, aborting.").arg(m_prefsUserFile).toLocal8Bit().data() << std::endl;
				std::exit(EXIT_FAILURE);
			} else {
				++argi;
			}
		}
		else if (strncmp(arg.toLocal8Bit().data(),"-psn_",4) == 0)
		{
			// Andreas Vox: Qt/Mac has -psn_blah flags that must be accepted.
		}
		else if (arg == CMD_OPTIONS_END)
		{ //double dash, indicates end of command line options, see http://unix.stackexchange.com/questions/11376/what-does-double-dash-mean-also-known-as-bare-double-dash
			argi++;
			break;
		}
		else
		{ //argument is not a known option, but either positional parameter or invalid.
			if (arg.left(1) == "-")
			{
				std::cout << tr("Invalid argument: %1").arg(arg).toLocal8Bit().data() << std::endl;
				std::exit(EXIT_FAILURE);
			}
			m_fileName = QFile::decodeName(args[argi].toLocal8Bit());
			if (!QFileInfo(m_fileName).exists())
			{
				std::cout << tr("File %1 does not exist, aborting.").arg(m_fileName).toLocal8Bit().data() << std::endl;
				std::exit(EXIT_FAILURE);
			}
			else
			{
				m_filesToLoad.append(m_fileName);
			}
		}
	}
	// parse for remaining (positional) arguments, if any
	for ( ; argi<argsc; argi++)
	{
		m_fileName = QFile::decodeName(args[argi].toLocal8Bit());
		if (!QFileInfo(m_fileName).exists())
		{
			std::cout << tr("File %1 does not exist, aborting.").arg(m_fileName).toLocal8Bit().data() << std::endl;
			std::exit(EXIT_FAILURE);
		}
		else
		{
			m_filesToLoad.append(m_fileName);
		}
	}
	//Init translations
	initLang();
	
	//Show command line info
	if (header)
	{
		useGUI = false;
		showHeader();
	}
	if (version)
		showVersion();
	if (availlangs)
		showAvailLangs();
	if (usage)
		showUsage();
#ifdef WITH_TESTS
	if (runtests)
		RunTests::runTests(testargsc, testargsv);
#endif
	if (runUpgradeCheck)
	{
		UpgradeChecker uc;
		uc.fetch();
	}
	//Don't run the GUI init process called from main.cpp, and return
	if (header)
		std::exit(EXIT_SUCCESS);
	//proceed
	if(neversplash)
		neverSplash(true);
	
}
Exemplo n.º 18
0
int _Tt_signature::
match(
    const _Tt_string &op,
    const _Tt_arg_list_ptr &args,
    const _Tt_context_list_ptr &contexts,
    _Tt_string &reason,
    int &was_exact
) const
{
    was_exact = 0;
    if (_op != op) {
        reason = "op";
        return 0;
    }
    /* according to the spec if there are no arguments in */
    /* the signature then args should be ignored in the   */
    /* match. (see p.22)				      */
    if (_args->count() == 0) {
        if (args.is_null() || (args->count() == 0)) {
            was_exact = 1;
        }
        return 1;
    }
    /* for each arg in args match arg_kind and type */
    /* against corresponding arg in signature.      */

    if (! args.is_null() && args->count() != _args->count()) {
        reason = "args";
        return 0;
    }

    _Tt_arg_list_cursor	margc(args);
    _Tt_arg_list_cursor	argc(_args);
    int score = 1;
    was_exact = 1;
    while (argc.next() && margc.next()) {
        int used_wildcard;
        int points = argc->match_score( **margc, used_wildcard );
        if (used_wildcard) {
            was_exact = 0;
        }
        if (points <= 0) {
            reason = "args";
            return 0;
        }
        score += points;
    }

    if (_contexts->count() == 0) {
        return score;
    }
    /* for each context in contexts match slotname against */
    /* corresponding arg in signature.		       */

    _Tt_context_list_cursor	mc(contexts);
    _Tt_context_list_cursor	sc(_contexts);

    mc.next();
    sc.next();

    while (mc.is_valid() && sc.is_valid()) {
        int cmpres = mc->slotName().cmp(sc->slotName());
        if (cmpres<0) { // target less than signature
            // The target has a context slot which is not in
            // the signature.  If we are matching a message
            // for possible delivery, this still could be a
            // match, but if we are matching another signature
            // for replacement in a tt_type_comp merge,
            // we should only replace exact matches.
            // Continue on to look for other mismatches,
            // but return partial mismatch to caller so it can
            // determine what to do.
            was_exact = 0;
            mc.next();
        } else if (cmpres==0) { // target same as signature
            // Context in target matches context in sig.
            mc.next();
            sc.next();
        } else  {	// target greater than signature
            // The signature has a context slot which is not
            // in the target.  This match fails.
            was_exact = 0;
            reason = "contexts";
            return 0;
        }
    }

    if (mc.is_valid() && !sc.is_valid()) {

        // Unconsumed context slots in target.
        was_exact = 0;

    } else if (!mc.is_valid() && sc.is_valid()) {

        // Unsatisfied context slots in signature
        was_exact = 0;
        reason = "contexts";
        return 0;

    } // else both are invalid, or both are valid. result stands..

    return score;
}
Exemplo n.º 19
0
std::string CommandLine::toString() const
{
    return ProgramInfo(argc(), argv()).commandLine();
}
Exemplo n.º 20
0
 String arg(size_t index)
 {
     if(index >= argc())
         return String::null();
     return argv[index];
 }
Exemplo n.º 21
0
void ScribusQApp::parseCommandLine()
{
	showSplash=!neverSplashExists();
	QString arg("");
	bool usage=false;
	bool header=false;
	bool availlangs=false;
	bool version=false;
	bool runUpgradeCheck=false;
#ifdef WITH_TESTS
	bool runtests = false;
	char** testargsv;
	int testargsc;
#endif
	showFontInfo=false;
	showProfileInfo=false;

	//Parse for command line information options, and lang
	// Qt5 port: do this in a Qt compatible manner
	QStringList args = arguments();
	int argsc = args.count();
	for(int i = 1; i < argsc; i++)
	{
		arg = args[i];

		if ((arg == ARG_LANG || arg == ARG_LANG_SHORT) && (++i < argsc)) {
			lang = args[i];
		}
		else if (arg == ARG_VERSION || arg == ARG_VERSION_SHORT) {
			header=true;
			version=true;
		} else if (arg == ARG_HELP || arg == ARG_HELP_SHORT) {
			header=true;
			usage=true;
		}
#ifdef WITH_TESTS
		else if (arg == ARG_TESTS || arg == ARG_TESTS_SHORT) {
			header=true;
			runtests=true;
			testargsc = argc() - i;
			testargsv = argv() + i;
			break;
		}
#endif
		else if (arg == ARG_AVAILLANG || arg == ARG_AVAILLANG_SHORT) {
			header=true;
			availlangs=true;
		} else if (arg == ARG_UPGRADECHECK || arg == ARG_UPGRADECHECK_SHORT) {
			header=true;
			runUpgradeCheck=true;
		}
	}
	//Init translations
	initLang();
	//Show command line help
	if (header)
		showHeader();
	if (version)
		showVersion();
	if (availlangs)
		showAvailLangs();
	if (usage)
		showUsage();
#ifdef WITH_TESTS
	if (runtests)
		RunTests::runTests(testargsc, testargsv);
#endif
	if (runUpgradeCheck)
	{
		UpgradeChecker uc;
		uc.fetch();
	}
	//Dont run the GUI init process called from main.cpp, and return
	if (header)
		std::exit(EXIT_SUCCESS);
	useGUI = true;
	//We are going to run something other than command line help
	for(int i = 1; i < argsc; i++) {
		arg = args[i];

		if ((arg == ARG_LANG || arg == ARG_LANG_SHORT) && (++i < argsc)) {
			continue;
		} else if ( arg == ARG_CONSOLE || arg == ARG_CONSOLE_SHORT ) {
			continue;
		} else if (arg == ARG_NOSPLASH || arg == ARG_NOSPLASH_SHORT) {
			showSplash = false;
		}
		else if (arg == ARG_NEVERSPLASH || arg == ARG_NEVERSPLASH_SHORT) {
			showSplash = false;
			neverSplash(true);
		} else if (arg == ARG_NOGUI || arg == ARG_NOGUI_SHORT) {
			useGUI=false;
		} else if (arg == ARG_FONTINFO || arg == ARG_FONTINFO_SHORT) {
			showFontInfo=true;
		} else if (arg == ARG_PROFILEINFO || arg == ARG_PROFILEINFO_SHORT) {
			showProfileInfo=true;
		} else if ((arg == ARG_DISPLAY || arg==ARG_DISPLAY_SHORT || arg==ARG_DISPLAY_QT) && ++i < argsc) {
			// allow setting of display, QT expect the option -display <display_name> so we discard the
			// last argument. FIXME: Qt only understands -display not --display and -d , we need to work
			// around this.
		} else if (arg == ARG_PREFS || arg == ARG_PREFS_SHORT) {
			prefsUserFile = QFile::decodeName(args[i + 1].toLocal8Bit());
			if (!QFileInfo(prefsUserFile).exists()) {
				showHeader();
				if (prefsUserFile.left(1) == "-" || prefsUserFile.left(2) == "--") {
					std::cout << tr("Invalid argument: ").toLocal8Bit().data() << prefsUserFile.toLocal8Bit().data() << std::endl;
				} else {
					std::cout << tr("File %1 does not exist, aborting.").arg(prefsUserFile).toLocal8Bit().data() << std::endl;
				}
				showUsage();
				std::exit(EXIT_FAILURE);
			} else {
				++i;
			}
		} else if (strncmp(arg.toLocal8Bit().data(),"-psn_",4) == 0)
		{
			// Andreas Vox: Qt/Mac has -psn_blah flags that must be accepted.
		} else if (arg == ARG_PYTHONSCRIPT || arg == ARG_PYTHONSCRIPT_SHORT) {
			pythonScript = QFile::decodeName(args[i + 1].toLocal8Bit());
			if (!QFileInfo(pythonScript).exists()) {
				showHeader();
				if (pythonScript.left(1) == "-" || pythonScript.left(2) == "--") {
					std::cout << tr("Invalid argument: ").toLocal8Bit().data() << pythonScript.toLocal8Bit().data() << std::endl;
				} else {
					std::cout << tr("File %1 does not exist, aborting.").arg(pythonScript).toLocal8Bit().data() << std::endl;
				}
				showUsage();
				std::exit(EXIT_FAILURE);
			} else {
				++i;
			}
		} else {
			fileName = QFile::decodeName(args[i].toLocal8Bit());
			if (!QFileInfo(fileName).exists()) {
				showHeader();
				if (fileName.left(1) == "-" || fileName.left(2) == "--") {
					std::cout << tr("Invalid argument: %1").arg(fileName).toLocal8Bit().data() << std::endl;
				} else {
					std::cout << tr("File %1 does not exist, aborting.").arg(fileName).toLocal8Bit().data() << std::endl;
				}
				showUsage();
				std::exit(EXIT_FAILURE);
			}
			else
			{
				filesToLoad.append(fileName);
			}
		}
	}
}