ref: d2f835e905fcbe8fba2d08b80eca0a360be677fa
parent: ea02f33e211dd71a435d3c008cb102244110f5e1
author: Ali Gholami Rudi <[email protected]>
date: Tue Jul 30 12:01:15 EDT 2013
font: ignore nonexistent fonts
--- a/dev.c
+++ b/dev.c
@@ -182,7 +182,8 @@
void dev_setcs(int fn, int cs)
{
- dev_font(fn)->cs = cs;
+ if (fn >= 0)
+ dev_font(fn)->cs = cs;
}
int dev_getbd(int fn)
@@ -192,5 +193,6 @@
void dev_setbd(int fn, int bd)
{
- dev_font(fn)->bd = bd;
+ if (fn >= 0)
+ dev_font(fn)->bd = bd;
}
--- a/font.c
+++ b/font.c
@@ -161,11 +161,14 @@
struct font *font_open(char *path)
{
- struct font *fn = malloc(sizeof(*fn));
+ struct font *fn;
char tok[ILNLEN];
FILE *fin;
int i;
fin = fopen(path, "r");
+ if (!fin)
+ return NULL;
+ fn = malloc(sizeof(*fn));
memset(fn, 0, sizeof(*fn));
for (i = 0; i < LEN(fn->head); i++)
fn->head[i] = -1;
--- a/ren.c
+++ b/ren.c
@@ -519,7 +519,9 @@
static void ren_ft(char *s)
{
int fn = !s || !*s || !strcmp("P", s) ? n_f0 : dev_pos(s);
- if (fn >= 0) {
+ if (fn < 0) {
+ errmsg("neatroff: failed to mount <%s>\n", s);
+ } else {
n_f0 = n_f;
n_f = fn;
}
@@ -535,7 +537,7 @@
if (!args[2])
return;
if (dev_mnt(atoi(args[1]), args[2], args[3] ? args[3] : args[2]) < 0)
- errmsg("troff: failed to mount %s\n", args[2]);
+ errmsg("neatroff: failed to mount <%s>\n", args[2]);
}
void tr_nf(char **args)