shithub: neatroff

Download patch

ref: 5fe72af94daf3c0fbea06fcb8140b5b8cd675928
parent: 3325081e41360a5dfc98ee155456d89c1e34822a
author: Ali Gholami Rudi <ali@rudi.ir>
date: Sat Sep 7 18:58:06 EDT 2013

dev: exit with an error if output device cannot be opened

--- a/dev.c
+++ b/dev.c
@@ -58,6 +58,8 @@
 	strcpy(dev_dev, dev);
 	sprintf(path, "%s/dev%s/DESC", dir, dev);
 	desc = fopen(path, "r");
+	if (!desc)
+		return 1;
 	while (fscanf(desc, "%s", tok) == 1) {
 		if (tok[0] == '#') {
 			skipline(desc);
--- a/roff.c
+++ b/roff.c
@@ -68,7 +68,10 @@
 			return 0;
 		}
 	}
-	dev_open(fontdir, dev);
+	if (dev_open(fontdir, dev)) {
+		fprintf(stderr, "neatroff: cannot open device %s\n", dev);
+		return 1;
+	}
 	env_init();
 	tr_init();
 	g_init();