View | Details | Raw Unified | Return to bug 205707 | Differences between
and this patch

Collapse All | Expand All

(-)vtfontcvt.c (-4 / +21 lines)
Lines 250-280 Link Here
250
	char *ln;
254
	char *ln;
251
	size_t length;
255
	size_t length;
252
	uint8_t bytes[wbytes * height], bytes_r[wbytes * height];
256
	uint8_t bytes[wbytes * height], bytes_r[wbytes * height];
253
	unsigned int curchar = 0, dwidth = 0, i, line;
257
	unsigned int curchar = 0, dwidth = 0, i, line, linenum = 0;
254
258
255
	while ((ln = fgetln(fp, &length)) != NULL) {
259
	while ((ln = fgetln(fp, &length)) != NULL) {
260
		linenum++;
256
		ln[length - 1] = '\0';
261
		ln[length - 1] = '\0';
257
262
258
		if (strncmp(ln, "ENCODING ", 9) == 0) {
263
		if (strncmp(ln, "ENCODING ", 9) == 0) {
259
			curchar = atoi(ln + 9);
264
			curchar = atoi(ln + 9);
265
			continue;
260
		}
266
		}
261
267
262
		if (strncmp(ln, "DWIDTH ", 7) == 0) {
268
		if (strncmp(ln, "DWIDTH ", 7) == 0) {
263
			dwidth = atoi(ln + 7);
269
			dwidth = atoi(ln + 7);
270
			continue;
264
		}
271
		}
265
272
266
		if (strncmp(ln, "BITMAP", 6) == 0 &&
273
		if (strncmp(ln, "BITMAP", 6) == 0 &&
267
		    (ln[6] == ' ' || ln[6] == '\0')) {
274
		    (ln[6] == ' ' || ln[6] == '\0')) {
268
			for (i = 0; i < height; i++) {
275
			for (i = 0;; i++) {
269
				if ((ln = fgetln(fp, &length)) == NULL)
276
				if ((ln = fgetln(fp, &length)) == NULL)
270
					errx(1, "Unexpected EOF!\n");
277
					err(1, "Unexpected error at line %u",
278
					    linenum);
279
				linenum++;
271
				ln[length - 1] = '\0';
280
				ln[length - 1] = '\0';
272
				sscanf(ln, "%x", &line);
281
				if (strncmp(ln, "ENDCHAR", 7) == 0)
282
					break;
283
				if (i == height) {
284
					warnx("Bitmap for character %u does "
285
					    "not end at line %u -- too tall?",
286
					    curchar, linenum);
287
					break;
288
				}
289
				if (sscanf(ln, "%x", &line) != 1)
290
					errx(1, "Can not parse ``%s'' on line %u", ln, linenum);
273
				if (parse_bitmap_line(bytes + i * wbytes,
291
				if (parse_bitmap_line(bytes + i * wbytes,
274
				     bytes_r + i * wbytes, line, dwidth) != 0)
292
				     bytes_r + i * wbytes, line, dwidth) != 0)
275
					return (1);
293
					return (1);
276
			}
294
			}
277
295
296
			bzero(bytes + wbytes * i, (height - i) * wbytes);
297
			bzero(bytes_r + wbytes * i, (height - i) * wbytes);
298
278
			if (add_char(curchar, map_idx, bytes,
299
			if (add_char(curchar, map_idx, bytes,
279
			    dwidth == width * 2 ? bytes_r : NULL) != 0)
300
			    dwidth == width * 2 ? bytes_r : NULL) != 0)
280
				return (1);
301
				return (1);

Return to bug 205707