aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/vtfontcvt
diff options
context:
space:
mode:
authorEd Maste <emaste@FreeBSD.org>2019-09-03 16:15:57 +0000
committerEd Maste <emaste@FreeBSD.org>2019-09-03 16:15:57 +0000
commit4d24d726e06f66287a10c17e9ea38d42785ac64b (patch)
tree0c95eb50508c8d2e3c6a0660f4729d9d0ddf0533 /usr.bin/vtfontcvt
parentda908f1a36f942a5310b6535e21fba397a579eac (diff)
downloadsrc-4d24d726e06f66287a10c17e9ea38d42785ac64b.tar.gz
src-4d24d726e06f66287a10c17e9ea38d42785ac64b.zip
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
Notes
Notes: svn path=/stable/12/; revision=351749
Diffstat (limited to 'usr.bin/vtfontcvt')
-rw-r--r--usr.bin/vtfontcvt/vtfontcvt.c43
1 files changed, 10 insertions, 33 deletions
diff --git a/usr.bin/vtfontcvt/vtfontcvt.c b/usr.bin/vtfontcvt/vtfontcvt.c
index e34308d5d365..7553d66d99d2 100644
--- a/usr.bin/vtfontcvt/vtfontcvt.c
+++ b/usr.bin/vtfontcvt/vtfontcvt.c
@@ -224,38 +224,19 @@ add_char(unsigned curchar, unsigned map_idx, uint8_t *bytes, uint8_t *bytes_r)
}
/*
- * 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;
-
- assert(size > 0 && len > 0);
- assert(size * 8 >= len);
+ ssize_t i, off_byte = shift / 8;
+ size_t off_bit = shift % 8;
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)