summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2021-05-13 06:55:24 +0000
committermidipix <writeonce@midipix.org>2021-05-13 07:35:04 +0000
commit5b1d0eb3aedc298d93a660992e06aed50bc3fd7b (patch)
treeb24aa96501e948e03731a1fe22f0fca830fbbc42 /src
parentdea897bf4775c9de9b7b64655734dd33dc42fbd5 (diff)
downloadslibtool-5b1d0eb3aedc298d93a660992e06aed50bc3fd7b.tar.bz2
slibtool-5b1d0eb3aedc298d93a660992e06aed50bc3fd7b.tar.xz
driver: properly handle --help after --mode.
Diffstat (limited to 'src')
-rw-r--r--src/driver/slbt_driver_ctx.c39
1 files changed, 27 insertions, 12 deletions
diff --git a/src/driver/slbt_driver_ctx.c b/src/driver/slbt_driver_ctx.c
index 02b0617..68cb136 100644
--- a/src/driver/slbt_driver_ctx.c
+++ b/src/driver/slbt_driver_ctx.c
@@ -289,6 +289,7 @@ static int slbt_split_argv(
struct argv_meta * meta;
struct argv_entry * entry;
struct argv_entry * mode;
+ struct argv_entry * help;
struct argv_entry * config;
struct argv_entry * finish;
struct argv_entry * features;
@@ -335,12 +336,14 @@ static int slbt_split_argv(
meta = argv_get(argv,optv,ARGV_VERBOSITY_NONE,fderr);
}
- /* missing all of --mode, --config, --features, and --finish? */
- mode = config = finish = features = ccwrap = 0;
+ /* missing all of --mode, --help, --config, --features, and --finish? */
+ mode = help = config = finish = features = ccwrap = 0;
for (entry=meta->entries; entry->fopt; entry++)
if (entry->tag == TAG_MODE)
mode = entry;
+ else if (entry->tag == TAG_HELP)
+ help = entry;
else if (entry->tag == TAG_CONFIG)
config = entry;
else if (entry->tag == TAG_FINISH)
@@ -352,7 +355,7 @@ static int slbt_split_argv(
argv_free(meta);
- if (!mode && !config && !finish && !features) {
+ if (!mode && !help && !config && !finish && !features) {
slbt_dprintf(fderr,
"%s: error: --mode must be specified.\n",
program);
@@ -360,7 +363,7 @@ static int slbt_split_argv(
}
/* missing compiler? */
- if (!ctx.unitidx && !finish && !features) {
+ if (!ctx.unitidx && !help && !finish && !features) {
if (flags & SLBT_DRIVER_VERBOSITY_ERRORS)
slbt_dprintf(fderr,
"%s: error: <compiler> is missing.\n",
@@ -482,7 +485,10 @@ static int slbt_split_argv(
return -1;
/* --features and no <compiler>? */
- if (features && !ctx.unitidx) {
+ if (ctx.unitidx) {
+ (void)0;
+
+ } else if (help || features) {
for (i=0; i<argc; i++)
sargv->targv[i] = argv[i];
@@ -1386,13 +1392,22 @@ int slbt_get_driver_ctx(
switch (entry->tag) {
case TAG_HELP:
case TAG_HELP_ALL:
- return (flags & SLBT_DRIVER_VERBOSITY_USAGE)
- ? slbt_driver_usage(
- fdctx->fdout,program,
- entry->arg,optv,
- meta,&sargv,
- (cctx.drvflags & SLBT_DRIVER_ANNOTATE_NEVER))
- : SLBT_USAGE;
+ switch (cctx.mode) {
+ case SLBT_MODE_INSTALL:
+ case SLBT_MODE_UNINSTALL:
+ break;
+
+ default:
+ return (flags & SLBT_DRIVER_VERBOSITY_USAGE)
+ ? slbt_driver_usage(
+ fdctx->fdout,program,
+ entry->arg,optv,
+ meta,&sargv,
+ (cctx.drvflags & SLBT_DRIVER_ANNOTATE_NEVER))
+ : SLBT_USAGE;
+ }
+
+ break;
case TAG_VERSION:
cctx.drvflags |= SLBT_DRIVER_VERSION;