summaryrefslogtreecommitdiffhomepage
path: root/src/internal/argv
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2016-08-01 12:04:02 -0400
committermidipix <writeonce@midipix.org>2016-08-01 12:06:51 -0400
commit97a847ee367c8cae1805a5ed9c3021c9c83ed1ce (patch)
treee4b2a3396bb868fe0a18a877ba5a92fcefa89c3d /src/internal/argv
parent61daf8549c18d089ca935a690a07a4e7a1096aa6 (diff)
downloadslibtool-97a847ee367c8cae1805a5ed9c3021c9c83ed1ce.tar.bz2
slibtool-97a847ee367c8cae1805a5ed9c3021c9c83ed1ce.tar.xz
argv.h: error message formatting: handle lonely long options.
Diffstat (limited to 'src/internal/argv')
-rw-r--r--src/internal/argv/argv.h29
1 files changed, 17 insertions, 12 deletions
diff --git a/src/internal/argv/argv.h b/src/internal/argv/argv.h
index 7f7c728..79c225a 100644
--- a/src/internal/argv/argv.h
+++ b/src/internal/argv/argv.h
@@ -497,6 +497,11 @@ static const char * argv_program_name(const char * program_path)
static void argv_show_error(struct argv_ctx * ctx)
{
+ char opt_short_name[2] = {0,0};
+
+ if (ctx->erropt && ctx->erropt->short_name)
+ opt_short_name[0] = ctx->erropt->short_name;
+
fprintf(stderr,"%s: error: ",ctx->program);
switch (ctx->errcode) {
@@ -509,21 +514,21 @@ static void argv_show_error(struct argv_ctx * ctx)
break;
case ARGV_ERROR_OPTARG_NONE:
- fprintf(stderr,"'%s' is not a valid option value for [%s%c%s%s%s] "
+ fprintf(stderr,"'%s' is not a valid option value for [%s%s%s%s%s] "
"(option values may not be specified)\n",
ctx->errch,
- ctx->erropt->short_name ? "-" : "",
- ctx->erropt->short_name,
- ctx->erropt->short_name ? "," : "",
+ opt_short_name[0] ? "-" : "",
+ opt_short_name,
+ opt_short_name[0] ? "," : "",
ctx->erropt->long_name ? "--" : "",
ctx->erropt->long_name);
break;
case ARGV_ERROR_OPTARG_REQUIRED:
- fprintf(stderr,"option [%s%c%s%s%s] requires %s %s%s%s\n",
- ctx->erropt->short_name ? "-" : "",
- ctx->erropt->short_name,
- ctx->erropt->short_name ? "," : "",
+ fprintf(stderr,"option [%s%s%s%s%s] requires %s %s%s%s\n",
+ opt_short_name[0] ? "-" : "",
+ opt_short_name,
+ opt_short_name[0] ? "," : "",
ctx->erropt->long_name ? "--" : "",
ctx->erropt->long_name,
ctx->erropt->paradigm ? "one of the following values:" : "a value",
@@ -533,11 +538,11 @@ static void argv_show_error(struct argv_ctx * ctx)
break;
case ARGV_ERROR_OPTARG_PARADIGM:
- fprintf(stderr,"'%s' is not a valid option value for [%s%c%s%s%s]={%s}\n",
+ fprintf(stderr,"'%s' is not a valid option value for [%s%s%s%s%s]={%s}\n",
ctx->errch,
- ctx->erropt->short_name ? "-" : "",
- ctx->erropt->short_name,
- ctx->erropt->short_name ? "," : "",
+ opt_short_name[0] ? "-" : "",
+ opt_short_name,
+ opt_short_name[0] ? "," : "",
ctx->erropt->long_name ? "--" : "",
ctx->erropt->long_name,
ctx->erropt->paradigm);