ref: 14fafdadb05a2ea128a8aa3ce43ac2010f77c5e0
parent: 3fb3f39df51a9ecc59b7c9c9c84fadc25522164f
author: Ali Gholami Rudi <ali@rudi.ir>
date: Sat Dec 19 15:25:05 EST 2020
font: buffers of size GNLEN for glyph names
--- a/dev.c
+++ b/dev.c
@@ -53,7 +53,7 @@
int dev_open(char *dir, char *dev)
{
char path[PATHLEN];
- char tok[ILNLEN];
+ char tok[128];
int i;
FILE *desc;
strcpy(dev_dir, dir);
@@ -62,7 +62,7 @@
desc = fopen(path, "r");
if (!desc)
return 1;
- while (fscanf(desc, "%s", tok) == 1) {
+ while (fscanf(desc, "%128s", tok) == 1) {
if (tok[0] == '#') {
skipline(desc);
continue;
@@ -75,7 +75,7 @@
continue;
}
if (!strcmp("sizes", tok)) {
- while (fscanf(desc, "%s", tok) == 1)
+ while (fscanf(desc, "%128s", tok) == 1)
if (!strcmp("0", tok))
break;
continue;
--- a/font.c
+++ b/font.c
@@ -64,16 +64,16 @@
static int font_readchar(struct font *fn, FILE *fin, int *n, int *gid)
{
struct glyph *g;
- char tok[ILNLEN];
- char name[ILNLEN];
- char id[ILNLEN];
+ char tok[128];
+ char name[GNLEN];
+ char id[GNLEN];
int type;
- if (fscanf(fin, "%s %s", name, tok) != 2)
+ if (fscanf(fin, GNFMT " %128s", name, tok) != 2)
return 1;
if (!strcmp("---", name))
sprintf(name, "c%04d", *n);
if (strcmp("\"", tok)) {
- if (fscanf(fin, "%d %s", &type, id) != 2)
+ if (fscanf(fin, "%d " GNFMT, &type, id) != 2)
return 1;
*gid = font_glyphput(fn, id, name, type);
g = &fn->gl[*gid];
@@ -102,7 +102,7 @@
struct font *fn;
int ch_g = -1; /* last glyph in the charset */
int ch_n = 0; /* number of glyphs in the charset */
- char tok[ILNLEN];
+ char tok[128];
FILE *fin;
fin = fopen(path, "r");
if (!fin)
@@ -117,7 +117,7 @@
fn->gl_dict = dict_make(-1, 1, 0);
fn->ch_dict = dict_make(-1, 1, 0);
fn->ch_map = dict_make(-1, 1, 0);
- while (fscanf(fin, "%s", tok) == 1) {
+ while (fscanf(fin, "%128s", tok) == 1) {
if (!strcmp("char", tok)) {
font_readchar(fn, fin, &ch_n, &ch_g);
} else if (!strcmp("spacewidth", tok)) {
--- a/post.c
+++ b/post.c
@@ -361,9 +361,9 @@
outinfo(kwd, spec);
}
if (!strcmp("set", cmd)) {
- char var[ILNLEN];
- char val[ILNLEN];
- if (sscanf(arg, "%s %s", var, val) == 2)
+ char var[128];
+ char val[128];
+ if (sscanf(arg, "%128s %128s", var, val) == 2)
outset(var, val);
}
if (!strcmp("BeginObject", cmd))
--- a/post.h
+++ b/post.h
@@ -3,8 +3,8 @@
#define NFONTS 1024 /* number of fonts */
#define FNLEN 64 /* font name length */
#define GNLEN 32 /* glyph name length */
+#define GNFMT "%32s" /* glyph name scanf format */
#define ILNLEN 1000 /* line limit of input files */
-#define LNLEN 4000 /* line buffer length (ren.c/out.c) */
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) < (b) ? (b) : (a))