From: Brian Norris Date: Fri, 2 Nov 2012 22:50:48 +0000 (-0700) Subject: main: fixup parameter parsing for user program X-Git-Tag: oopsla2013~539^2^2~24 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=5e822c431b0282de735336d6ef4b055203fa1d29;p=model-checker.git main: fixup parameter parsing for user program The user program expects 'optind' to be reset and for 'argv' and 'argc' to include the program name as the first argument variable. Note: our mmap()/mprotect()-based snapshotting does not snapshot this 'optind' global, so user-progs that use optarg() functionality might fail. --- diff --git a/main.cc b/main.cc index 8a17a18..e8d4f9a 100644 --- a/main.cc +++ b/main.cc @@ -75,8 +75,10 @@ static void parse_options(struct model_params *params, int *argc, char ***argv) break; } } - (*argc) -= optind; - (*argv) += optind; + (*argv)[optind - 1] = (*argv)[0]; + (*argc) -= (optind - 1); + (*argv) += (optind - 1); + optind = 1; if (error) print_usage(params);