From a380bbcafa8d6ef58fa4149db9987d6a69b4b6f0 Mon Sep 17 00:00:00 2001 From: Bryce Harrington Date: Thu, 25 Feb 2016 10:48:51 -0800 Subject: inkview: Drop use of obsolete getopt This lets us drop getopt as a cmake requirement. Patch from rindolf, thanks! http://www.shlomifish.org/Files/files/code/inkscape-cmake-get-rid-of-getopt-check-2.diff (bzr r14668) --- src/inkview.cpp | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'src/inkview.cpp') diff --git a/src/inkview.cpp b/src/inkview.cpp index aab4b4a20..c0c6f0b2c 100644 --- a/src/inkview.cpp +++ b/src/inkview.cpp @@ -30,10 +30,6 @@ # include "config.h" #endif -#ifdef HAVE_GETOPT_H -#include -#endif - #include #include #include @@ -179,17 +175,22 @@ main (int argc, const char **argv) num_parsed_options = 0; // the list of arguments is in the net line - while ((option = getopt(argc, (char* const* )argv, "t:")) != -1) - { - switch(option) { - case 't': // for timer - // fprintf(stderr, "set timer arg %s\n", optarg ); - ss.timer = atoi(optarg); - num_parsed_options += 2; // 2 because of flag + option + for (int i = 1; i < argc; i++) { + if ((argv[i][0] == '-')) { + if (!strcmp(argv[i], "--")) { break; - case '?': - default: - usage(); + } + else if ((!strcmp(argv[i], "-t"))) { + if (i + 1 >= argc) { + usage(); + } + ss.timer = atoi(argv[i+1]); + num_parsed_options = i+1; + i++; + } + else { + usage(); + } } } -- cgit v1.2.3