Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/wsfontload - don't use embedded font name if -N is ...



details:   https://anonhg.NetBSD.org/src/rev/9ef65884c7f1
branches:  trunk
changeset: 354650:9ef65884c7f1
user:      macallan <macallan%NetBSD.org@localhost>
date:      Fri Jun 23 18:40:03 2017 +0000

description:
- don't use embedded font name if -N is given
- assume mono bitmap font when reading from stdin

diffstat:

 usr.sbin/wsfontload/wsfontload.c |  14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diffs (49 lines):

diff -r 2967a08e4a8e -r 9ef65884c7f1 usr.sbin/wsfontload/wsfontload.c
--- a/usr.sbin/wsfontload/wsfontload.c  Fri Jun 23 17:40:15 2017 +0000
+++ b/usr.sbin/wsfontload/wsfontload.c  Fri Jun 23 18:40:03 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: wsfontload.c,v 1.20 2017/06/23 17:40:15 macallan Exp $ */
+/* $NetBSD: wsfontload.c,v 1.21 2017/06/23 18:40:03 macallan Exp $ */
 
 /*
  * Copyright (c) 1999
@@ -138,6 +138,7 @@
        struct stat st;
        int c, res, wsfd, ffd, verbose = 0;
        size_t len;
+       int use_embedded_name = 1;
        void *buf;
        char nbuf[65];
 
@@ -170,6 +171,7 @@
                        break;
                case 'N':
                        f.name = optarg;
+                       use_embedded_name = 0;
                        break;
                case 'b':
                        f.bitorder = WSDISPLAY_FONTORDER_R2L;
@@ -208,7 +210,7 @@
        if (!f.stride)
                f.stride = (f.fontwidth + 7) / 8;
        len = f.fontheight * f.numchars * f.stride;
-       if (fstat(ffd, &st) == 0) {
+       if ((ffd != 0) && (fstat(ffd, &st) == 0)) {
                if ((off_t)len != st.st_size) {
                        uint32_t foo = 0;
                        char b[65];
@@ -218,9 +220,11 @@
                        if (strncmp(b, "WSFT", 4) != 0)
                                errx(1, "invalid wsf file ");
                        read(ffd, b, 64);
-                       b[64] = 0;
-                       strcpy(nbuf, b);
-                       f.name = nbuf;
+                       if (use_embedded_name) {
+                               b[64] = 0;
+                               strcpy(nbuf, b);
+                               f.name = nbuf;
+                       }
                        read(ffd, &foo, 4);
                        f.firstchar = le32toh(foo);
                        read(ffd, &foo, 4);



Home | Main Index | Thread Index | Old Index