summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2016-01-11 14:49:15 -0500
committermidipix <writeonce@midipix.org>2016-01-11 14:49:15 -0500
commitae0e7aad9070d417ced2451f5073b489ac5907a8 (patch)
tree06e4ca30454bb672718fa8815dfb3c507b3d4e42
parenta6709e5e78c3253664b739ddc42a3c561141e18a (diff)
downloadsofort-ae0e7aad9070d417ced2451f5073b489ac5907a8.tar.bz2
sofort-ae0e7aad9070d417ced2451f5073b489ac5907a8.tar.xz
argv.h: reluctantly add ARGV_OPTION_HYBRID_JOINED support.
-rw-r--r--src/internal/argv/argv.h26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/internal/argv/argv.h b/src/internal/argv/argv.h
index 8ae6549..be1b5a0 100644
--- a/src/internal/argv/argv.h
+++ b/src/internal/argv/argv.h
@@ -47,6 +47,7 @@
/* EQUAL: -hybrid=VALUE (i.e. -std=c99) */
/* COMMA: -hybrid,VALUE (i.e. -Wl,<arg>) */
/* ONLY: -opt accepted, --opt rejected */
+/* JOINED: -optVALUE */
/* */
/*******************************************/
@@ -56,11 +57,15 @@
#define ARGV_OPTION_HYBRID_SPACE 0x02
#define ARGV_OPTION_HYBRID_EQUAL 0x04
#define ARGV_OPTION_HYBRID_COMMA 0x08
+#define ARGV_OPTION_HYBRID_JOINED 0x10
+#define ARGV_OPTION_HYBRID_CIRCUS (ARGV_OPTION_HYBRID_SPACE \
+ | ARGV_OPTION_HYBRID_JOINED)
#define ARGV_OPTION_HYBRID_DUAL (ARGV_OPTION_HYBRID_SPACE \
| ARGV_OPTION_HYBRID_EQUAL)
#define ARGV_OPTION_HYBRID_SWITCH (ARGV_OPTION_HYBRID_SPACE \
| ARGV_OPTION_HYBRID_EQUAL \
- | ARGV_OPTION_HYBRID_COMMA)
+ | ARGV_OPTION_HYBRID_COMMA \
+ | ARGV_OPTION_HYBRID_JOINED)
enum argv_optarg {
ARGV_OPTARG_NONE,
@@ -186,12 +191,11 @@ static const struct argv_option * argv_long_option(
if (len && !(strncmp(option->long_name,ch,len))) {
arg = ch + len;
- if (!*arg || (*arg == '=')) {
- entry->tag = option->tag;
- entry->fopt = true;
- return option;
- } else if ((option->flags & ARGV_OPTION_HYBRID_COMMA)
- && (*arg == ',')) {
+ if (!*arg
+ || (*arg == '=')
+ || (option->flags & ARGV_OPTION_HYBRID_JOINED)
+ || ((option->flags & ARGV_OPTION_HYBRID_COMMA)
+ && (*arg == ','))) {
entry->tag = option->tag;
entry->fopt = true;
return option;
@@ -380,7 +384,10 @@ static void argv_scan(
fval = false;
} else if (!fhybrid && (option->flags & ARGV_OPTION_HYBRID_ONLY))
ferror = ARGV_ERROR_HYBRID_ONLY;
- else if (fhybrid && !val[0] && !(option->flags & ARGV_OPTION_HYBRID_SPACE))
+ 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))
ferror = ARGV_ERROR_HYBRID_SPACE;
else if (fhybrid && (val[0]=='=') && !(option->flags & ARGV_OPTION_HYBRID_EQUAL))
ferror = ARGV_ERROR_HYBRID_EQUAL;
@@ -547,7 +554,8 @@ static void argv_show_error(struct argv_ctx * ctx)
ctx->erropt->long_name,
(ctx->erropt->flags & ARGV_OPTION_HYBRID_SPACE)
? " " : (ctx->erropt->flags & ARGV_OPTION_HYBRID_EQUAL)
- ? "=" : ",");
+ ? "=" : (ctx->erropt->flags & ARGV_OPTION_HYBRID_COMMA)
+ ? "," : "");
break;