From owner-svn-src-head@FreeBSD.ORG Mon Jun 9 20:49:13 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id B13CFFAB; Mon, 9 Jun 2014 20:49:13 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 911BD2108; Mon, 9 Jun 2014 20:49:13 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s59KnDBB025358; Mon, 9 Jun 2014 20:49:13 GMT (envelope-from emaste@svn.freebsd.org) Received: (from emaste@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s59KnDWR025357; Mon, 9 Jun 2014 20:49:13 GMT (envelope-from emaste@svn.freebsd.org) Message-Id: <201406092049.s59KnDWR025357@svn.freebsd.org> From: Ed Maste Date: Mon, 9 Jun 2014 20:49:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r267298 - head/tools/tools/vt/fontcvt X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Jun 2014 20:49:13 -0000 Author: emaste Date: Mon Jun 9 20:49:13 2014 New Revision: 267298 URL: http://svnweb.freebsd.org/changeset/base/267298 Log: vt fontcvt: Hide stats by default and improve error handling The font stats are interesting, but rather verbose. Modified: head/tools/tools/vt/fontcvt/fontcvt.c Modified: head/tools/tools/vt/fontcvt/fontcvt.c ============================================================================== --- head/tools/tools/vt/fontcvt/fontcvt.c Mon Jun 9 20:48:38 2014 (r267297) +++ head/tools/tools/vt/fontcvt/fontcvt.c Mon Jun 9 20:49:13 2014 (r267298) @@ -88,8 +88,8 @@ static void usage(void) { - fprintf(stderr, -"usage: fontcvt [-w width] [-h height] normal.bdf [bold.bdf] out.fnt\n"); + errx(1, +"usage: fontcvt [-w width] [-h height] [-v] normal.bdf [bold.bdf] out.fnt\n"); exit(1); } @@ -137,7 +137,7 @@ add_mapping(struct glyph *gl, unsigned i ml = &maps[map_idx]; if (TAILQ_LAST(ml, mapping_list) != NULL && TAILQ_LAST(ml, mapping_list)->m_char >= c) { - fprintf(stderr, "Bad ordering at character %u\n", c); + errx(1, "Bad ordering at character %u\n", c); return (1); } TAILQ_INSERT_TAIL(ml, mp, m_list); @@ -210,8 +210,8 @@ parse_bitmap_line(uint8_t *left, uint8_t unsigned int i, subline; if (dwidth != width && dwidth != width * 2) { - fprintf(stderr, - "Unsupported width %u!\n", dwidth); + errx(1, + "Bitmap with unsupported width %u!\n", dwidth); return (1); } @@ -230,7 +230,7 @@ parse_bitmap_line(uint8_t *left, uint8_t *p++ = subline >> 8; *p = subline; } else { - fprintf(stderr, + errx(1, "Unsupported wbytes %u!\n", wbytes); return (1); } @@ -264,7 +264,7 @@ parse_bdf(FILE *fp, unsigned int map_idx (ln[6] == ' ' || ln[6] == '\0')) { for (i = 0; i < height; i++) { if ((ln = fgetln(fp, &length)) == NULL) { - fprintf(stderr, "Unexpected EOF!\n"); + errx(1, "Unexpected EOF!\n"); return (1); } ln[length - 1] = '\0'; @@ -450,10 +450,47 @@ write_fnt(const char *filename) return (0); } +static void +print_font_info(void) +{ + printf( +"Statistics:\n" +"- glyph_total: %5u\n" +"- glyph_normal: %5u\n" +"- glyph_normal_right: %5u\n" +"- glyph_bold: %5u\n" +"- glyph_bold_right: %5u\n" +"- glyph_unique: %5u\n" +"- glyph_dupe: %5u\n" +"- mapping_total: %5u\n" +"- mapping_normal: %5u\n" +"- mapping_normal_folded: %5u\n" +"- mapping_normal_right: %5u\n" +"- mapping_normal_right_folded: %5u\n" +"- mapping_bold: %5u\n" +"- mapping_bold_folded: %5u\n" +"- mapping_bold_right: %5u\n" +"- mapping_bold_right_folded: %5u\n" +"- mapping_unique: %5u\n" +"- mapping_dupe: %5u\n", + glyph_total, + glyph_count[0], + glyph_count[1], + glyph_count[2], + glyph_count[3], + glyph_unique, glyph_dupe, + mapping_total, + map_count[0], map_folded_count[0], + map_count[1], map_folded_count[1], + map_count[2], map_folded_count[2], + map_count[3], map_folded_count[3], + mapping_unique, mapping_dupe); +} + int main(int argc, char *argv[]) { - int ch; + int ch, val, verbose = 0; assert(sizeof(struct file_header) == 32); assert(sizeof(struct file_mapping) == 8); @@ -461,10 +498,23 @@ main(int argc, char *argv[]) while ((ch = getopt(argc, argv, "h:w:")) != -1) { switch (ch) { case 'h': - height = atoi(optarg); + val = atoi(optarg); + if (val <= 0 || val > 128) { + errx(1, "Invalid height %d", val); + return (1); + } + height = val; + break; + case 'v': + verbose = 1; break; case 'w': - width = atoi(optarg); + val = atoi(optarg); + if (val <= 0 || val > 128) { + errx(1, "Invalid width %d", val); + return (1); + } + width = val; break; case '?': default: @@ -496,39 +546,9 @@ main(int argc, char *argv[]) fold_mappings(3); if (write_fnt(argv[0]) != 0) return (1); - - printf( -"Statistics:\n" -"- glyph_total: %5u\n" -"- glyph_normal: %5u\n" -"- glyph_normal_right: %5u\n" -"- glyph_bold: %5u\n" -"- glyph_bold_right: %5u\n" -"- glyph_unique: %5u\n" -"- glyph_dupe: %5u\n" -"- mapping_total: %5u\n" -"- mapping_normal: %5u\n" -"- mapping_normal_folded: %5u\n" -"- mapping_normal_right: %5u\n" -"- mapping_normal_right_folded: %5u\n" -"- mapping_bold: %5u\n" -"- mapping_bold_folded: %5u\n" -"- mapping_bold_right: %5u\n" -"- mapping_bold_right_folded: %5u\n" -"- mapping_unique: %5u\n" -"- mapping_dupe: %5u\n", - glyph_total, - glyph_count[0], - glyph_count[1], - glyph_count[2], - glyph_count[3], - glyph_unique, glyph_dupe, - mapping_total, - map_count[0], map_folded_count[0], - map_count[1], map_folded_count[1], - map_count[2], map_folded_count[2], - map_count[3], map_folded_count[3], - mapping_unique, mapping_dupe); - + + if (verbose) + print_font_info(); + return (0); }