Index: vtfontcvt.c =================================================================== --- vtfontcvt.c (revision 292831) +++ vtfontcvt.c (working copy) @@ -250,31 +254,48 @@ char *ln; size_t length; uint8_t bytes[wbytes * height], bytes_r[wbytes * height]; - unsigned int curchar = 0, dwidth = 0, i, line; + unsigned int curchar = 0, dwidth = 0, i, line, linenum = 0; while ((ln = fgetln(fp, &length)) != NULL) { + linenum++; ln[length - 1] = '\0'; if (strncmp(ln, "ENCODING ", 9) == 0) { curchar = atoi(ln + 9); + continue; } if (strncmp(ln, "DWIDTH ", 7) == 0) { dwidth = atoi(ln + 7); + continue; } if (strncmp(ln, "BITMAP", 6) == 0 && (ln[6] == ' ' || ln[6] == '\0')) { - for (i = 0; i < height; i++) { + for (i = 0;; i++) { if ((ln = fgetln(fp, &length)) == NULL) - errx(1, "Unexpected EOF!\n"); + err(1, "Unexpected error at line %u", + linenum); + linenum++; ln[length - 1] = '\0'; - sscanf(ln, "%x", &line); + if (strncmp(ln, "ENDCHAR", 7) == 0) + break; + if (i == height) { + warnx("Bitmap for character %u does " + "not end at line %u -- too tall?", + curchar, linenum); + break; + } + if (sscanf(ln, "%x", &line) != 1) + errx(1, "Can not parse ``%s'' on line %u", ln, linenum); if (parse_bitmap_line(bytes + i * wbytes, bytes_r + i * wbytes, line, dwidth) != 0) return (1); } + bzero(bytes + wbytes * i, (height - i) * wbytes); + bzero(bytes_r + wbytes * i, (height - i) * wbytes); + if (add_char(curchar, map_idx, bytes, dwidth == width * 2 ? bytes_r : NULL) != 0) return (1);