Source-Changes-HG archive

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

[xsrc/trunk]: xsrc/local/programs/bdfload - convert remaining error output to...



details:   https://anonhg.NetBSD.org/xsrc/rev/ed3b1c32d830
branches:  trunk
changeset: 7131:ed3b1c32d830
user:      macallan <macallan%NetBSD.org@localhost>
date:      Tue Aug 16 20:27:33 2022 +0000

description:
- convert remaining error output to err()
- suppress console output unless -v is specified

diffstat:

 local/programs/bdfload/bdfload.c |  34 +++++++++++++++++++++-------------
 1 files changed, 21 insertions(+), 13 deletions(-)

diffs (98 lines):

diff -r 1cf104069178 -r ed3b1c32d830 local/programs/bdfload/bdfload.c
--- a/local/programs/bdfload/bdfload.c  Mon Aug 15 09:44:19 2022 +0000
+++ b/local/programs/bdfload/bdfload.c  Tue Aug 16 20:27:33 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bdfload.c,v 1.3 2022/06/08 19:19:42 uwe Exp $  */
+/*     $NetBSD: bdfload.c,v 1.4 2022/08/16 20:27:33 macallan Exp $     */
 
 /*
  * Copyright (c) 2018 Michael Lorenz
@@ -97,6 +97,7 @@
 
 const char *ofile = NULL;
 int encoding = -1;
+int verbose = 0;
 
 
 void
@@ -130,28 +131,29 @@
                        /* cut off quotation marks */
                        strncpy(name, arg + 1, 64);
                        name[strlen(name) - 1] = 0;
-                       printf("name: %s\n", name);
+                       if (verbose) printf("name: %s\n", name);
                } else if (strcmp(line, "FONTBOUNDINGBOX") == 0) {
                        int res;
                        res = sscanf(arg, "%d %d %d %d",
                                          &width, &height, &x, &y);
                        stride = (width + 7) >> 3;
-                       printf("box %d x %d\n", width, height);
+                       if (verbose) printf("box %d x %d\n", width, height);
                        if (stride > 2) {
-                               printf("no fonts wider than 16 work for now\n");
-                               exit(1);
+                               err(EXIT_FAILURE,
+                                   "no fonts wider than 16 work for now\n");
                        }
                        charsize = height * stride;
                        buflen = 256 * charsize;
                        buffer = calloc(1, buflen);
                        if (buffer == NULL) {
-                               printf("failed to allocate %dKB for glyphs\n",
+                               err(EXIT_FAILURE, 
+                                   "failed to allocate %dKB for glyphs\n",
                                    buflen);
-                               exit(1);
                        }
                } else if (strcmp(line, "CHARS") == 0) {
                        if (sscanf(arg, "%d", &num) == 1)
-                               printf("number of characters: %d\n", num);
+                               if (verbose) 
+                                   printf("number of characters: %d\n", num);
                } else if (strcmp(line, "STARTCHAR") == 0) {
                        in_char = 1;
                } else if (strcmp(line, "ENDCHAR") == 0) {
@@ -202,9 +204,11 @@
                        }
                }
        }
-       printf("range %d to %d\n", first, last);
-       printf("encoding: %s\n", encname[encoding]);
-       printf("actual box: %d %d %d %d\n", bl, bt, br, bb);
+       if (verbose) {
+               printf("range %d to %d\n", first, last);
+               printf("encoding: %s\n", encname[encoding]);
+               printf("actual box: %d %d %d %d\n", bl, bt, br, bb);
+       }
 
        /* now stuff it into a something wsfont understands */
        f.fontwidth = width /*(width + 3) & ~3*/;
@@ -266,7 +270,7 @@
 __dead void
 usage()
 {
-       fprintf(stderr, "usage: bdfload [-e encoding] [-o ofile.wsf] font.bdf\n");
+       fprintf(stderr, "usage: bdfload [-v] [-e encoding] [-o ofile.wsf] font.bdf\n");
        exit(EXIT_FAILURE);
 }
 
@@ -277,7 +281,7 @@
        const char *encname = NULL;
 
        int c;
-       while ((c = getopt(argc, argv, "e:o:")) != -1) {
+       while ((c = getopt(argc, argv, "e:o:v")) != -1) {
                switch (c) {
 
                /* font encoding */
@@ -294,6 +298,10 @@
                        ofile = optarg;
                        break;
 
+               case 'v':
+                       verbose = 1;
+                       break;
+
                case '?':       /* FALLTHROUGH */
                default:
                        usage();



Home | Main Index | Thread Index | Old Index