From owner-svn-src-all@freebsd.org Tue Sep 3 16:17:02 2019 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1560EE1431; Tue, 3 Sep 2019 16:17:02 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46NBt56Y4kz3Jl5; Tue, 3 Sep 2019 16:17:01 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C49FA5812; Tue, 3 Sep 2019 16:17:01 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x83GH1DE034850; Tue, 3 Sep 2019 16:17:01 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x83GH1f5034849; Tue, 3 Sep 2019 16:17:01 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201909031617.x83GH1f5034849@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Tue, 3 Sep 2019 16:17:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r351750 - stable/11/usr.bin/vtfontcvt X-SVN-Group: stable-11 X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: stable/11/usr.bin/vtfontcvt X-SVN-Commit-Revision: 351750 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Sep 2019 16:17:02 -0000 Author: emaste Date: Tue Sep 3 16:17:01 2019 New Revision: 351750 URL: https://svnweb.freebsd.org/changeset/base/351750 Log: MFC r351425: vtfontcvt: simplify rshift_row We don't need to specify the buffer size in both bytes and bits. Sponsored by: The FreeBSD Foundation Modified: stable/11/usr.bin/vtfontcvt/vtfontcvt.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/vtfontcvt/vtfontcvt.c ============================================================================== --- stable/11/usr.bin/vtfontcvt/vtfontcvt.c Tue Sep 3 16:15:57 2019 (r351749) +++ stable/11/usr.bin/vtfontcvt/vtfontcvt.c Tue Sep 3 16:17:01 2019 (r351750) @@ -224,38 +224,19 @@ add_char(unsigned curchar, unsigned map_idx, uint8_t * } /* - * Right-shift glyph row by _shift_ bits. Row _len_ bits wide, _size_ bytes. + * Right-shift glyph row. */ -static int -rshift_row(uint8_t *line, size_t size, size_t len, size_t shift) +static void +rshift_row(uint8_t *buf, size_t len, size_t shift) { - size_t d, s, i; - uint16_t t; + ssize_t i, off_byte = shift / 8; + size_t off_bit = shift % 8; - assert(size > 0 && len > 0); - assert(size * 8 >= len); - if (shift == 0) - return (0); - - d = shift / 8; - s = 8 - shift % 8; - i = howmany(len, 8); - - while (i > 0) { - i--; - - t = *(line + i); - *(line + i) = 0; - - t <<= s; - - if (i + d + 1 < size) - *(line + i + d + 1) |= (uint8_t)t; - if (i + d < size) - *(line + i + d) = t >> 8; - } - return (0); + return; + for (i = len - 1; i >= 0; i--) + buf[i] = (i >= off_byte ? buf[i - off_byte] >> off_bit : 0) | + (i > off_byte ? buf[i - off_byte - 1] << (8 - off_bit) : 0); } /* @@ -426,11 +407,7 @@ parse_bdf(FILE *fp, unsigned int map_idx) *(line + j) = (uint8_t)val; } - rv = rshift_row(line, wbytes * 2, bbw, - bbox - fbbox); - if (rv != 0) - goto out; - + rshift_row(line, wbytes * 2, bbox - fbbox); rv = split_row(bytes + i * wbytes, bytes_r + i * wbytes, line, dwidth); if (rv != 0)