summaryrefslogtreecommitdiffstats
path: root/src/misc/extra/extraUtilUtil.c
diff options
context:
space:
mode:
authorMathias Soeken <mathias.soeken@gmail.com>2017-02-22 19:00:28 -0800
committerMathias Soeken <mathias.soeken@gmail.com>2017-02-22 19:00:28 -0800
commit28e8e7f3e79d1391a2f3a31cefe3afe234aa3b8e (patch)
tree6b7962dc72653e3bf615c5901854774eca9d23c8 /src/misc/extra/extraUtilUtil.c
parent5af44731bff0061c724912cf76e86dddbb4f2c7a (diff)
parentdd8cc7e9a27e2bd962d612911c6fd9508c6c1e0d (diff)
downloadabc-28e8e7f3e79d1391a2f3a31cefe3afe234aa3b8e.tar.gz
abc-28e8e7f3e79d1391a2f3a31cefe3afe234aa3b8e.tar.bz2
abc-28e8e7f3e79d1391a2f3a31cefe3afe234aa3b8e.zip
Merged alanmi/abc into default
Diffstat (limited to 'src/misc/extra/extraUtilUtil.c')
-rw-r--r--src/misc/extra/extraUtilUtil.c54
1 files changed, 32 insertions, 22 deletions
diff --git a/src/misc/extra/extraUtilUtil.c b/src/misc/extra/extraUtilUtil.c
index 253d9e3c..2f0f4559 100644
--- a/src/misc/extra/extraUtilUtil.c
+++ b/src/misc/extra/extraUtilUtil.c
@@ -102,35 +102,45 @@ int Extra_UtilGetopt( int argc, char *argv[], const char *optstring )
globalUtilOptarg = NULL;
- if (pScanStr == NULL || *pScanStr == '\0') {
- if (globalUtilOptind == 0) globalUtilOptind++;
- if (globalUtilOptind >= argc) return EOF;
- place = argv[globalUtilOptind];
- if (place[0] != '-' || place[1] == '\0') return EOF;
- globalUtilOptind++;
- if (place[1] == '-' && place[2] == '\0') return EOF;
- pScanStr = place+1;
+ if (pScanStr == NULL || *pScanStr == '\0')
+ {
+ if (globalUtilOptind == 0)
+ globalUtilOptind++;
+ if (globalUtilOptind >= argc)
+ return EOF;
+ place = argv[globalUtilOptind];
+ if (place[0] != '-' || place[1] == '\0')
+ return EOF;
+ globalUtilOptind++;
+ if (place[1] == '-' && place[2] == '\0')
+ return EOF;
+ pScanStr = place+1;
}
c = *pScanStr++;
place = strchr(optstring, c);
if (place == NULL || c == ':') {
- (void) fprintf(stderr, "%s: unknown option %c\n", argv[0], c);
- return '?';
- }
- if (*++place == ':') {
- if (*pScanStr != '\0') {
- globalUtilOptarg = pScanStr;
- pScanStr = NULL;
- } else {
- if (globalUtilOptind >= argc) {
- (void) fprintf(stderr, "%s: %c requires an argument\n",
- argv[0], c);
+ (void) fprintf(stderr, "%s: unknown option %c\n", argv[0], c);
return '?';
- }
- globalUtilOptarg = argv[globalUtilOptind];
- globalUtilOptind++;
}
+ if (*++place == ':')
+ {
+ if (*pScanStr != '\0')
+ {
+ globalUtilOptarg = pScanStr;
+ pScanStr = NULL;
+ }
+ else
+ {
+ if (globalUtilOptind >= argc)
+ {
+ (void) fprintf(stderr, "%s: %c requires an argument\n",
+ argv[0], c);
+ return '?';
+ }
+ globalUtilOptarg = argv[globalUtilOptind];
+ globalUtilOptind++;
+ }
}
return c;
}