shithub: neatroff

Download patch

ref: fd0bf8b3a9e7b8fd046f88e93ada58fad7334b2e
parent: d695b4788fac2810f69a92aacdf08d6e4af21d3f
author: Ali Gholami Rudi <[email protected]>
date: Tue Jul 26 18:53:06 EDT 2022

font: leave room of the terminating new line in fscanf()

--- a/dev.c
+++ b/dev.c
@@ -86,7 +86,7 @@
 	desc = fopen(path, "r");
 	if (!desc)
 		return 1;
-	while (fscanf(desc, "%128s", tok) == 1) {
+	while (fscanf(desc, "%127s", tok) == 1) {
 		if (tok[0] == '#') {
 			skipline(desc);
 			continue;
--- a/font.c
+++ b/font.c
@@ -331,7 +331,7 @@
 	char name[GNLEN];
 	char id[GNLEN];
 	int type;
-	if (fscanf(fin, GNFMT " %128s", name, tok) != 2)
+	if (fscanf(fin, GNFMT " %127s", name, tok) != 2)
 		return 1;
 	if (!strcmp("---", name))
 		sprintf(name, "c%04d", *n);
@@ -624,7 +624,7 @@
 	fn->ch_dict = dict_make(-1, 1, 0);
 	fn->ch_map = dict_make(-1, 1, 0);
 	fn->ggrp = iset_make();
-	while (fscanf(fin, "%128s", tok) == 1) {
+	while (fscanf(fin, "%127s", tok) == 1) {
 		if (!strcmp("char", tok)) {
 			font_readchar(fn, fin, &ch_n, &ch_g);
 		} else if (!strcmp("kern", tok)) {
--- a/roff.h
+++ b/roff.h
@@ -28,7 +28,7 @@
 #define NFONTS		32	/* number of fonts */
 #define FNLEN		32	/* font name length */
 #define GNLEN		32	/* glyph name length */
-#define GNFMT		"%32s"	/* glyph name scanf format */
+#define GNFMT		"%31s"	/* glyph name scanf format */
 #define NMLEN		128	/* macro/register/environment name length */
 #define RNLEN		NMLEN	/* register/macro name */
 #define NREGS		8192	/* number of mapped names */