diff options
author | midipix <writeonce@midipix.org> | 2016-01-11 14:50:24 -0500 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2016-11-11 00:22:34 -0500 |
commit | 5ae6fcf65acc8aadccb369562f7f9e5599288693 (patch) | |
tree | 6f22b2af36e3cd3ebe54daaf1ec7f4b4f685801e /src/internal/argv | |
parent | ce8ba9b35831de63e49d7c99c9b8df4212df3e11 (diff) | |
download | mdso-5ae6fcf65acc8aadccb369562f7f9e5599288693.tar.bz2 mdso-5ae6fcf65acc8aadccb369562f7f9e5599288693.tar.xz |
argv.h: reluctantly add ARGV_OPTION_HYBRID_JOINED support.
Diffstat (limited to 'src/internal/argv')
-rw-r--r-- | src/internal/argv/argv.h | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/src/internal/argv/argv.h b/src/internal/argv/argv.h index 0433597..2b11312 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; |