diff options
Diffstat (limited to 'mkfontscale')
-rw-r--r-- | mkfontscale/configure.ac | 2 | ||||
-rw-r--r-- | mkfontscale/hash.c | 7 | ||||
-rw-r--r-- | mkfontscale/ident.c | 1 | ||||
-rw-r--r-- | mkfontscale/man/mkfontscale.man | 5 | ||||
-rw-r--r-- | mkfontscale/mkfontscale.c | 50 |
5 files changed, 43 insertions, 22 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/hash.c b/mkfontscale/hash.c index 3adfb6861..58f1b6940 100644 --- a/mkfontscale/hash.c +++ b/mkfontscale/hash.c @@ -23,6 +23,7 @@ #include "config.h" #include <stdlib.h> +#include <unistd.h> #include <stdio.h> #include <string.h> #include <ctype.h> @@ -150,7 +151,8 @@ hashElements(HashTablePtr table) static int key_first_cmp(const void *v1, const void *v2) { - const HashBucketPtr *b1 = v1, *b2 = v2; + const HashBucketPtr *b1 = (const HashBucketPtr *)v1; + const HashBucketPtr *b2 = (const HashBucketPtr *)v2; int c1 = strcasecmp((*b1)->key, (*b2)->key); if(c1 != 0) return c1; return strcmp((*b1)->value, (*b2)->value); @@ -159,7 +161,8 @@ key_first_cmp(const void *v1, const void *v2) static int value_first_cmp(const void *v1, const void *v2) { - const HashBucketPtr *b1 = v1, *b2 = v2; + const HashBucketPtr *b1 = (const HashBucketPtr *)v1; + const HashBucketPtr *b2 = (const HashBucketPtr *)v2; int c1 = strcmp((*b1)->value, (*b2)->value); if(c1 != 0) return c1; return strcasecmp((*b1)->key, (*b2)->key); diff --git a/mkfontscale/ident.c b/mkfontscale/ident.c index 22d364830..a3af2033f 100644 --- a/mkfontscale/ident.c +++ b/mkfontscale/ident.c @@ -52,6 +52,7 @@ #endif #include <stdlib.h> +#include <unistd.h> #include <string.h> #include "zlib.h" #include "ident.h" 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 e605cf9bd..b01d80a27 100644 --- a/mkfontscale/mkfontscale.c +++ b/mkfontscale/mkfontscale.c @@ -24,7 +24,11 @@ #include <stdio.h> #include <stdlib.h> +#include <unistd.h> #include <string.h> +#ifdef _MSC_VER +#include <direct.h> +#endif #include <sys/types.h> #include <sys/stat.h> @@ -34,6 +38,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 +117,24 @@ static ListPtr encodingsToDo; static int reencodeLegacy; static char *encodingPrefix; static char *exclusionSuffix; +static char *ProgramName; static void 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 +missing_arg (const char *option) +{ + fprintf(stderr, "%s: %s requires an argument\n", ProgramName, option); + usage(); } int @@ -131,6 +145,7 @@ main(int argc, char **argv) int rc, ll = 0; char prefix[NPREFIX]; + ProgramName = argv[0]; encodingPrefix = NULL; exclusionSuffix = NULL; @@ -144,9 +159,9 @@ main(int argc, char **argv) outfilename = NULL; - encodings = makeList(encodings_array, countof(encodings_array), NULL, 0); + encodings = makeList((char **)encodings_array, countof(encodings_array), NULL, 0); - extra_encodings = makeList(extra_encodings_array, + extra_encodings = makeList((char**)extra_encodings_array, countof(extra_encodings_array), NULL, 0); doBitmaps = 0; @@ -166,34 +181,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 +234,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 +248,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); } } |