From: Michael Schutte <michi@uiae.at>
To: kbd@lists.altlinux.org, 528357@bugs.debian.org,
Jakub Wilk <ubanus@users.sf.net>
Subject: Re: [kbd] Bug#528357: /usr/bin/showconsolefont: produces garbage
Date: Mon, 18 May 2009 20:00:13 +0200
Message-ID: <20090518180013.GA29833@graeme> (raw)
In-Reply-To: <20090516191525.GA23674@graeme>
[-- 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 --]
prev parent reply other threads:[~2009-05-18 18:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-16 19:15 ` Michael Schutte
2009-05-18 18:00 ` Michael Schutte [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090518180013.GA29833@graeme \
--to=michi@uiae.at \
--cc=528357@bugs.debian.org \
--cc=kbd@lists.altlinux.org \
--cc=ubanus@users.sf.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Linux console tools development discussion
This inbox may be cloned and mirrored by anyone:
git clone --mirror http://lore.altlinux.org/kbd/0 kbd/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 kbd kbd/ http://lore.altlinux.org/kbd \
kbd@lists.altlinux.org kbd@lists.altlinux.ru kbd@lists.altlinux.com
public-inbox-index kbd
Example config snippet for mirrors.
Newsgroup available over NNTP:
nntp://lore.altlinux.org/org.altlinux.lists.kbd
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git