summaryrefslogtreecommitdiff
path: root/src/internal
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2024-01-27 21:14:22 +0000
committermidipix <writeonce@midipix.org>2024-01-27 22:20:37 +0000
commitd155298c21574414238fd644718e039977bc2375 (patch)
treee907bbb703b0107f2d60f29b9093256192fe4310 /src/internal
parentcaeffbe9e30652f13156c181550ee69140d7906b (diff)
downloadmdso-d155298c21574414238fd644718e039977bc2375.tar.bz2
mdso-d155298c21574414238fd644718e039977bc2375.tar.xz
argv.h: argv_scan(): whitespace meditation.
Diffstat (limited to 'src/internal')
-rw-r--r--src/internal/argv/argv.h50
1 files changed, 34 insertions, 16 deletions
diff --git a/src/internal/argv/argv.h b/src/internal/argv/argv.h
index 407c640..99c2ecc 100644
--- a/src/internal/argv/argv.h
+++ b/src/internal/argv/argv.h
@@ -418,49 +418,67 @@ static void argv_scan(
ch = *parg;
}
- if (fhybrid && !(option->flags & ARGV_OPTION_HYBRID_SWITCH))
+ /* now verify the proper setting of option values */
+ if (fhybrid && !(option->flags & ARGV_OPTION_HYBRID_SWITCH)) {
ferr = ARGV_ERROR_HYBRID_NONE;
- else if (!fhybrid && (option->flags & ARGV_OPTION_HYBRID_ONLY))
+
+ } else if (!fhybrid && (option->flags & ARGV_OPTION_HYBRID_ONLY)) {
ferr = ARGV_ERROR_HYBRID_ONLY;
- else if (option->optarg == ARGV_OPTARG_NONE) {
+
+ } else if (option->optarg == ARGV_OPTARG_NONE) {
if (val[0]) {
ferr = ARGV_ERROR_OPTARG_NONE;
ctx->errch = val + 1;
- } else
+ } else {
fval = false;
+ }
+
} else if (val[0] && (option->flags & ARGV_OPTION_HYBRID_JOINED)) {
fval = true;
ch = val;
- } else if (fhybrid && !val[0] && !(option->flags & ARGV_OPTION_HYBRID_SPACE))
+
+ } else if (fhybrid && !val[0] && !(option->flags & ARGV_OPTION_HYBRID_SPACE)) {
ferr = ARGV_ERROR_HYBRID_SPACE;
- else if (fhybrid && (val[0]=='=') && !(option->flags & ARGV_OPTION_HYBRID_EQUAL))
+
+ } else if (fhybrid && (val[0]=='=') && !(option->flags & ARGV_OPTION_HYBRID_EQUAL)) {
ferr = ARGV_ERROR_HYBRID_EQUAL;
- else if (fhybrid && (val[0]==',') && !(option->flags & ARGV_OPTION_HYBRID_COMMA))
+
+ } else if (fhybrid && (val[0]==',') && !(option->flags & ARGV_OPTION_HYBRID_COMMA)) {
ferr = ARGV_ERROR_HYBRID_COMMA;
- else if (!fhybrid && (val[0]==','))
+
+ } else if (!fhybrid && (val[0]==',')) {
ferr = ARGV_ERROR_HYBRID_COMMA;
- else if (val[0] && !val[1])
+
+ } else if (val[0] && !val[1]) {
ferr = ARGV_ERROR_OPTARG_REQUIRED;
- else if (val[0] && val[1]) {
+
+ } else if (val[0] && val[1]) {
fval = true;
ch = ++val;
+
} else if (option->optarg == ARGV_OPTARG_REQUIRED) {
- if (!val[0] && !*parg)
+ if (!val[0] && !*parg) {
ferr = ARGV_ERROR_OPTARG_REQUIRED;
- else if (*parg && is_short_option(*parg))
+
+ } else if (*parg && is_short_option(*parg)) {
ferr = ARGV_ERROR_OPTARG_REQUIRED;
- else if (*parg && is_long_option(*parg))
+
+ } else if (*parg && is_long_option(*parg)) {
ferr = ARGV_ERROR_OPTARG_REQUIRED;
- else if (*parg && is_last_option(*parg))
+
+ } else if (*parg && is_last_option(*parg)) {
ferr = ARGV_ERROR_OPTARG_REQUIRED;
- else
+
+ } else {
fval = true;
+ }
} else {
/* ARGV_OPTARG_OPTIONAL */
fval = val[0];
}
- } else
+ } else {
ferr = ARGV_ERROR_LONG_OPTION;
+ }
}
if (ferr == ARGV_ERROR_OK)