* Re: [kbd] Bug#528357: /usr/bin/showconsolefont: produces garbage
2009-05-16 19:15 ` [kbd] Bug#528357: /usr/bin/showconsolefont: produces garbage Michael Schutte
@ 2009-05-18 18:00 ` Michael Schutte
0 siblings, 0 replies; 2+ messages in thread
From: Michael Schutte @ 2009-05-18 18:00 UTC (permalink / raw)
To: kbd, 528357, Jakub Wilk
[-- Attachment #1.1: Type: text/plain, Size: 300 bytes --]
tag 528357 + patch
thanks
On Sat, May 16, 2009 at 09:15:25PM +0200, Michael Schutte wrote:
> One way to solve this would be to check which mode the VT is in and then
> using the appropriate way to print spaces.
The attached patch uses this approach.
--
Michael Schutte <michi@uiae.at>
[-- Attachment #1.2: 528357.patch --]
[-- Type: text/x-diff, Size: 2436 bytes --]
From 8c30fa09c9738b6b3605d94d681cee5e5ca2b371 Mon Sep 17 00:00:00 2001
From: Michael Schutte <michi@uiae.at>
Date: Mon, 18 May 2009 19:47:00 +0200
Subject: [PATCH] showconsolefont: Print adequate space chars
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Figure out whether the console is in Unicode or XLATE mode to decide
whether to use a direct-to-font (U+F020) or a simple ASCII space
character, respectively. This avoids showconsolefont’s output becoming
a mess, cf. <http://bugs.debian.org/528357>.
Signed-off-by: Michael Schutte <michi@uiae.at>
---
src/showconsolefont.c | 24 +++++++++++++++++-------
1 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/src/showconsolefont.c b/src/showconsolefont.c
index c0b58d6..733e634 100644
--- a/src/showconsolefont.c
+++ b/src/showconsolefont.c
@@ -116,7 +116,8 @@ usage(void) {
int
main (int argc, char **argv) {
int c, n, cols, rows, nr, i, j, k;
- char *sep, *console = NULL;
+ int mode;
+ char *space, *sep, *console = NULL;
int list[64], lth, info = 0, verbose = 0;
set_progname(argv[0]);
@@ -148,6 +149,17 @@ main (int argc, char **argv) {
if (optind != argc)
usage();
+ fd = getfd(console);
+
+ if (ioctl(fd, KDGKBMODE, &mode)) {
+ perror("KDGKBMODE");
+ leave(1);
+ }
+ if (mode == K_UNICODE)
+ space = "\xef\x80\xa0"; /* U+F020 (direct-to-font space) */
+ else
+ space = " ";
+
if (info) {
nr = rows = cols = 0;
n = getfont(fd, NULL, &nr, &rows, &cols);
@@ -164,8 +176,6 @@ main (int argc, char **argv) {
leave(0);
}
- fd = getfd(console);
-
settrivialscreenmap();
getoldunicodemap();
@@ -175,7 +185,7 @@ main (int argc, char **argv) {
cols = ((n > 256) ? 32 : 16);
nr = 64/cols;
rows = (n+cols-1)/cols;
- sep = ((cols == 16) ? " " : " ");
+ sep = ((cols == 16) ? "%1$s%1$s" : "%1$s");
for (i=0; i<rows; i++) {
if (i % nr == 0) {
@@ -185,12 +195,12 @@ main (int argc, char **argv) {
list[lth++] = k+j*rows;
setnewunicodemap(list, lth);
}
- printf(" ");
+ printf("%1$s%1$s%1$s%1$s", space);
for(j=0; j < cols && i+j*rows < n; j++) {
putchar(BASE + (i%nr)*cols+j);
- printf("%s", sep);
+ printf(sep, space);
if (j%8 == 7)
- printf("%s", sep);
+ printf(sep, space);
}
putchar('\n');
if (i%8 == 7)
--
1.6.2.4
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 489 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread