From acb630095d941fd52015e54096091f62a7c538ba Mon Sep 17 00:00:00 2001 From: James Turner Date: Tue, 26 Jan 2016 07:47:38 +0100 Subject: [PATCH] Possible fix for Mac strncmp crashes. --- src/Main/options.cxx | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) 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; } } -- 2.39.5