summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBryce Harrington <bryce@bryceharrington.org>2016-02-25 18:48:51 +0000
committerbryce <bryce@bryceharrington.org>2016-02-25 18:48:51 +0000
commita380bbcafa8d6ef58fa4149db9987d6a69b4b6f0 (patch)
treee5f693b9eb36d1a08f1c53e7e0f9a52b8154c0ab /src
parentpackaging: Note if there are uncommitted changes when trying to make a release (diff)
downloadinkscape-a380bbcafa8d6ef58fa4149db9987d6a69b4b6f0.tar.gz
inkscape-a380bbcafa8d6ef58fa4149db9987d6a69b4b6f0.zip
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)
Diffstat (limited to 'src')
-rw-r--r--src/inkview.cpp29
1 files changed, 15 insertions, 14 deletions
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 <getopt.h>
-#endif
-
#include <cstring>
#include <sys/stat.h>
#include <locale.h>
@@ -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();
+ }
}
}