From: James Turner Date: Tue, 26 Jan 2016 06:47:38 +0000 (+0100) Subject: Possible fix for Mac strncmp crashes. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=acb630095d941fd52015e54096091f62a7c538ba;p=flightgear.git Possible fix for Mac strncmp crashes. --- diff --git a/src/Main/options.cxx b/src/Main/options.cxx index 339233ced..97d9cc8d2 100644 --- a/src/Main/options.cxx +++ b/src/Main/options.cxx @@ -2564,11 +2564,20 @@ bool Options::checkForArg(int argc, char* argv[], const char* checkArg) { for (int i = 0; i < argc; ++i) { char* arg = argv[i]; - if (!strncmp("--", arg, 2) && !strcmp(arg + 2, checkArg)) { - return true; + if (arg == 0) { + continue; } - - if ((arg[0] == '-') && !strcmp(arg + 1, checkArg)) { + + if (*arg != '-') { // we only care about args with a leading hypen + continue; + } + + arg++; + if (*arg == '-') { // skip double hypens + arg++; + } + + if (strcmp(arg, checkArg) == 0) { return true; } }