From 77e2b1ff53bd806a681c9a887cd5b026681d271b Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Wed, 8 Feb 2017 18:57:16 -0800 Subject: Autotuner for 'satoko'. --- src/misc/extra/extraUtilUtil.c | 54 +++++++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 22 deletions(-) (limited to 'src/misc/extra') 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; } -- cgit v1.2.3