summaryrefslogtreecommitdiff
path: root/mkfontscale.c
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2013-11-08 23:48:28 -0800
committerAlan Coopersmith <alan.coopersmith@oracle.com>2013-11-22 22:30:52 -0800
commit880a0c4733e62e54e6a0f1238c7430727d23657b (patch)
tree4fe52d076897765b6da1f6bfe65e948b5af66985 /mkfontscale.c
parent26c89de6cdf0a5b7122a630a5df37fd67a4163e2 (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>
Diffstat (limited to 'mkfontscale.c')
-rw-r--r--mkfontscale.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/mkfontscale.c b/mkfontscale.c
index d27bb8d..a494f93 100644
--- a/mkfontscale.c
+++ b/mkfontscale.c
@@ -113,11 +113,12 @@ static ListPtr encodingsToDo;
static int reencodeLegacy;
static char *encodingPrefix;
static char *exclusionSuffix;
+static char *ProgramName;
static void _X_NORETURN _X_COLD
usage(void)
{
- fprintf(stderr,
+ fprintf(stderr, "Usage:\n"
"mkfontscale [ -b ] [ -s ] [ -o filename ] [-x suffix ]\n"
" [ -a encoding ] [ -f fuzz ] [ -l ]\n"
" [ -e directory ] [ -p prefix ] [ -n ] [ -r ] \n"
@@ -125,6 +126,13 @@ usage(void)
exit(1);
}
+static void _X_NORETURN _X_COLD
+missing_arg (const char *option)
+{
+ fprintf(stderr, "%s: %s requires an argument\n", ProgramName, option);
+ usage();
+}
+
int
main(int argc, char **argv)
{
@@ -133,6 +141,7 @@ main(int argc, char **argv)
int rc, ll = 0;
char prefix[NPREFIX];
+ ProgramName = argv[0];
encodingPrefix = NULL;
exclusionSuffix = NULL;
@@ -168,21 +177,23 @@ main(int argc, char **argv)
break;
} else if (strcmp(argv[argn], "-x") == 0) {
if(argn >= argc - 1) {
- usage();
+ missing_arg("-x");
}
exclusionSuffix = argv[argn + 1];
argn += 2;
} else if(strcmp(argv[argn], "-a") == 0) {
if(argn >= argc - 1) {
- usage();
+ missing_arg("-a");
}
makeList(&argv[argn + 1], 1, encodings, 0);
argn += 2;
} else if(strcmp(argv[argn], "-p") == 0) {
if(argn >= argc - 1) {
- usage();
+ missing_arg("-p");
}
if(strlen(argv[argn + 1]) > NPREFIX - 1) {
+ fprintf(stderr, "%s: argument to -p cannot be longer than "
+ "%d characters\n", ProgramName, NPREFIX - 1);
usage();
}
free(encodingPrefix);
@@ -190,7 +201,7 @@ main(int argc, char **argv)
argn += 2;
} else if(strcmp(argv[argn], "-e") == 0) {
if(argn >= argc - 1) {
- usage();
+ missing_arg("-e");
}
rc = readEncodings(encodingsToDo, argv[argn + 1]);
if(rc < 0)
@@ -219,13 +230,13 @@ main(int argc, char **argv)
argn++;
} else if(strcmp(argv[argn], "-o") == 0) {
if(argn >= argc - 1) {
- usage();
+ missing_arg("-o");
}
outfilename = argv[argn + 1];
argn += 2;
} else if(strcmp(argv[argn], "-f") == 0) {
if(argn >= argc - 1) {
- usage();
+ missing_arg("-f");
}
bigEncodingFuzz = atof(argv[argn + 1]) / 100.0;
argn += 2;