[SYSTEM] Apply patch from SUSE.
authorAlexey Gladkov <legion@altlinux.org>
Sun, 28 Jan 2007 21:03:58 +0000 (00:03 +0300)
committerAlexey Gladkov <legion@altlinux.org>
Sun, 28 Jan 2007 21:03:58 +0000 (00:03 +0300)
Apply kbd-1.12-showconsolefont-info.diff patch from SUSE distribution.
- Add -i option in showconsolefont to show ROWSxCOLSxCOUNT.
- Update usage.

Signed-off-by: Alexey Gladkov <legion@altlinux.org>
src/kdfontop.c
src/showconsolefont.c

index effb61225489fb47d8deebfc8b8d012de3c70e10..2bdf50ba9455c12698ee18a4948fd97cf29bb584 100644 (file)
@@ -143,8 +143,11 @@ font_charheight(char *buf, int count, int width) {
        return h;
 }
 
-/* may be called with buf==NULL if we only want info */
-/* must not exit - we may have cleanup to do */
+/*
+ * May be called with buf==NULL if we only want info.
+ * May be called with width==NULL and height==NULL.
+ * Must not exit - we may have cleanup to do.
+ */
 int
 getfont(int fd, char *buf, int *count, int *width, int *height) {
        struct consolefontdesc cfd;
@@ -194,6 +197,10 @@ getfont(int fd, char *buf, int *count, int *width, int *height) {
                fprintf(stderr, _("bug: getfont called with count<256\n"));
                return -1;
        }
+       if (!buf) {
+           fprintf(stderr, _("bug: getfont using GIO_FONT needs buf.\n"));
+           return -1;
+       }
        i = ioctl(fd, GIO_FONT, buf);
        if (i) {
                perror("getfont: GIO_FONT");
@@ -207,11 +214,11 @@ getfont(int fd, char *buf, int *count, int *width, int *height) {
 
 int
 getfontsize(int fd) {
-       int count, width, height;
+       int count;
        int i;
 
-       count = width = height = 0;
-       i = getfont(fd, NULL, &count, &width, &height);
+       count = 0;
+       i = getfont(fd, NULL, &count, NULL, NULL);
        return (i == 0) ? count : 256;
 }
 
index 8d6907976f3a7eabcb0028a64243407689afcfe2..1bd7f2f439d84e3d7f96e9ce798cc8448aade4ec 100644 (file)
@@ -101,8 +101,15 @@ setnewunicodemap(int *list, int cnt) {
 static void
 usage(void) {
        fprintf(stderr,
-               _("usage: showconsolefont [-v|-V]\n"
-                 "(probably after loading a font with `setfont font')\n"));
+               _("usage: showconsolefont -V|--version\n"
+                 "       showconsolefont [-C tty] [-v] [-i]\n"
+                 "(probably after loading a font with `setfont font')\n"
+                 "\n"
+                 "Valid options are:\n"
+                 " -C tty   Device to read the font from. Default: current tty.\n"
+                 " -v       Be more verbose.\n"
+                 " -i       Don't print out the font table, just show\n"
+                 "          ROWSxCOLSxCOUNT and exit.\n"));
        exit(1);
 }
 
@@ -110,7 +117,7 @@ int
 main (int argc, char **argv) {
        int c, n, cols, rows, nr, i, j, k;
        char *sep, *console = NULL;
-       int list[64], lth, verbose = 0;
+       int list[64], lth, info = 0, verbose = 0;
 
        set_progname(argv[0]);
 
@@ -122,8 +129,11 @@ main (int argc, char **argv) {
            (!strcmp(argv[1], "-V") || !strcmp(argv[1], "--version")))
                print_version_and_exit();
 
-       while ((c = getopt(argc, argv, "vC:")) != EOF) {
+       while ((c = getopt(argc, argv, "ivC:")) != EOF) {
                switch (c) {
+               case 'i':
+                       info = 1;
+                       break;
                case 'v':
                        verbose = 1;
                        break;
@@ -135,9 +145,25 @@ main (int argc, char **argv) {
                }
        }
 
-       if (argc != 1)
+       if (optind != argc)
                usage();
 
+        if (info) {
+           nr = rows = cols = 0;
+           n = getfont(fd, NULL, &nr, &rows, &cols);
+           if (n != 0)
+             leave(1);
+
+           if (verbose) {
+               printf("Character count: %d\n", nr);
+               printf("Font width     : %d\n", rows);
+               printf("Font height    : %d\n", cols);
+           }
+           else
+               printf("%dx%dx%d\n", rows, cols, nr);
+           leave(0);
+         }
+
        fd = getfd(console);
 
        settrivialscreenmap();