aboutsummaryrefslogtreecommitdiff
path: root/mkfontscale
diff options
context:
space:
mode:
Diffstat (limited to 'mkfontscale')
-rw-r--r--mkfontscale/configure.ac2
-rw-r--r--mkfontscale/man/mkfontscale.man5
-rw-r--r--mkfontscale/mkfontscale.c44
3 files changed, 32 insertions, 19 deletions
diff --git a/mkfontscale/configure.ac b/mkfontscale/configure.ac
index 971ae5c39..cc13259ab 100644
--- a/mkfontscale/configure.ac
+++ b/mkfontscale/configure.ac
@@ -54,7 +54,7 @@ fi
# Checks for pkg-config packages
PKG_CHECK_MODULES(MKFONTSCALE, fontenc freetype2)
-PKG_CHECK_MODULES(X11, xproto)
+PKG_CHECK_MODULES(X11, [xproto >= 7.0.25])
dnl Allow checking code with lint, sparse, etc.
XORG_WITH_LINT
diff --git a/mkfontscale/man/mkfontscale.man b/mkfontscale/man/mkfontscale.man
index 4aa88ab04..cb1845817 100644
--- a/mkfontscale/man/mkfontscale.man
+++ b/mkfontscale/man/mkfontscale.man
@@ -38,6 +38,8 @@ mkfontscale \- create an index of scalable font files for X
] [
.B \-u | \-U
] [
+.B \-v
+] [
.B \-\-
] [
.I directory
@@ -132,6 +134,9 @@ is useful when generating encoding directories only.
disable (\fI-u\fP) or enable (\fI-U\fP) indexing of ISO 10646:1 font
encodings (default: enabled).
.TP
+.B \-v
+print program version and exit.
+.TP
.B \-\-
end of options.
.SH SEE ALSO
diff --git a/mkfontscale/mkfontscale.c b/mkfontscale/mkfontscale.c
index a67f28338..a494f931d 100644
--- a/mkfontscale/mkfontscale.c
+++ b/mkfontscale/mkfontscale.c
@@ -34,6 +34,7 @@
#include <ctype.h>
#include <X11/Xos.h>
+#include <X11/Xfuncproto.h>
#include <X11/fonts/fontenc.h>
#include <ft2build.h>
#include FT_FREETYPE_H
@@ -112,15 +113,24 @@ static ListPtr encodingsToDo;
static int reencodeLegacy;
static char *encodingPrefix;
static char *exclusionSuffix;
+static char *ProgramName;
-static void
+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 ] "
+ " [ -a encoding ] [ -f fuzz ] [ -l ]\n"
" [ -e directory ] [ -p prefix ] [ -n ] [ -r ] \n"
- " [-u] [-U] [ directory ]...\n");
+ " [-u] [-U] [-v] [ directory ]...\n");
+ 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
@@ -131,6 +141,7 @@ main(int argc, char **argv)
int rc, ll = 0;
char prefix[NPREFIX];
+ ProgramName = argv[0];
encodingPrefix = NULL;
exclusionSuffix = NULL;
@@ -166,34 +177,31 @@ main(int argc, char **argv)
break;
} else if (strcmp(argv[argn], "-x") == 0) {
if(argn >= argc - 1) {
- usage();
- exit(1);
+ missing_arg("-x");
}
exclusionSuffix = argv[argn + 1];
argn += 2;
} else if(strcmp(argv[argn], "-a") == 0) {
if(argn >= argc - 1) {
- usage();
- exit(1);
+ missing_arg("-a");
}
makeList(&argv[argn + 1], 1, encodings, 0);
argn += 2;
} else if(strcmp(argv[argn], "-p") == 0) {
if(argn >= argc - 1) {
- usage();
- exit(1);
+ 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();
- exit(1);
}
free(encodingPrefix);
encodingPrefix = dsprintf("%s", argv[argn + 1]);
argn += 2;
} else if(strcmp(argv[argn], "-e") == 0) {
if(argn >= argc - 1) {
- usage();
- exit(1);
+ missing_arg("-e");
}
rc = readEncodings(encodingsToDo, argv[argn + 1]);
if(rc < 0)
@@ -222,15 +230,13 @@ main(int argc, char **argv)
argn++;
} else if(strcmp(argv[argn], "-o") == 0) {
if(argn >= argc - 1) {
- usage();
- exit(1);
+ missing_arg("-o");
}
outfilename = argv[argn + 1];
argn += 2;
} else if(strcmp(argv[argn], "-f") == 0) {
if(argn >= argc - 1) {
- usage();
- exit(1);
+ missing_arg("-f");
}
bigEncodingFuzz = atof(argv[argn + 1]) / 100.0;
argn += 2;
@@ -238,9 +244,11 @@ main(int argc, char **argv)
argn++;
} else if (strcmp(argv[argn], "-n") == 0) {
argn++;
+ } else if (strcmp(argv[argn], "-v") == 0) {
+ printf("%s\n", PACKAGE_STRING);
+ exit(0);
} else {
usage();
- exit(1);
}
}