summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2013-11-04 23:14:22 -0800
committerAlan Coopersmith <alan.coopersmith@oracle.com>2013-11-22 22:13:42 -0800
commit15d326027827c168511f923e72c64e2131515e19 (patch)
tree8354aa7b2cb15e62b8b0b47ce193e4541a396cef
parent64bc2b97d408d6fea16716e37f7b5ff1661d57fd (diff)
Print which option was in error along with usage message
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Gaetan Nadon <memsize@videotron.ca>
-rw-r--r--atobm.c26
-rw-r--r--bmtoa.c8
-rw-r--r--configure.ac2
3 files changed, 27 insertions, 9 deletions
diff --git a/atobm.c b/atobm.c
index 040fecb..ef6da7e 100644
--- a/atobm.c
+++ b/atobm.c
@@ -42,9 +42,11 @@ static char *ProgramName;
static void doit(FILE *fp, const char *filename, const char *chars,
int xhot, int yhot, const char *name);
-static void _X_NORETURN
-usage (void)
+static void _X_NORETURN _X_COLD
+usage (const char *msg)
{
+ if (msg)
+ fprintf(stderr, "%s: %s\n", ProgramName, msg);
fprintf (stderr, "usage: %s [-options ...] [filename]\n\n%s\n",
ProgramName,
"where options include:\n"
@@ -55,6 +57,14 @@ usage (void)
exit (1);
}
+static void _X_NORETURN _X_COLD
+missing_arg (const char *option)
+{
+ char msg[32];
+
+ snprintf(msg, sizeof(msg), "%s requires an argument", option);
+ usage(msg);
+}
static char *
cify_name (char *name)
@@ -106,23 +116,25 @@ main (int argc, char *argv[])
filename = NULL;
continue;
case 'c':
- if (++i >= argc) usage ();
+ if (++i >= argc) missing_arg("-chars");
chars = argv[i];
continue;
case 'n':
- if (++i >= argc) usage ();
+ if (++i >= argc) missing_arg("-name");
name = argv[i];
continue;
case 'x':
- if (++i >= argc) usage ();
+ if (++i >= argc) missing_arg("-xhot");
xhot = atoi (argv[i]);
continue;
case 'y':
- if (++i >= argc) usage ();
+ if (++i >= argc) missing_arg("-yhot");
yhot = atoi (argv[i]);
continue;
default:
- usage ();
+ fprintf(stderr, "%s: unrecognized option '%s'\n",
+ ProgramName, argv[i]);
+ usage (NULL);
}
} else {
filename = arg;
diff --git a/bmtoa.c b/bmtoa.c
index 0394038..a9de614 100644
--- a/bmtoa.c
+++ b/bmtoa.c
@@ -130,10 +130,16 @@ main (int argc, char *argv[])
filename = NULL;
continue;
case 'c':
- if (++i >= argc) usage ();
+ if (++i >= argc) {
+ fprintf(stderr, "%s: -chars requires an argument\n",
+ ProgramName);
+ usage ();
+ }
chars = argv[i];
continue;
default:
+ fprintf(stderr, "%s: unrecognized option '%s'\n",
+ ProgramName, argv[i]);
usage ();
}
} else {
diff --git a/configure.ac b/configure.ac
index 0b8cee6..d61ec7c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -56,7 +56,7 @@ AC_SUBST([MATH_LIBS])
# Obtain compiler/linker options from dependencies
PKG_CHECK_MODULES(BMTOA, [x11 xmu xproto >= 7.0.17])
-PKG_CHECK_MODULES(ATOBM, [xproto >= 7.0.17])
+PKG_CHECK_MODULES(ATOBM, [xproto >= 7.0.25])
PKG_CHECK_MODULES(BITMAP, xbitmaps xaw7 xmu)
PKG_CHECK_MODULES(APPDEFS, xt)