ref: 2d8b842d526ee909146577cc5a3557f09ec66e46
parent: 3cecf018179e6240cd1d1266fcb4bd0bb601dcec
author: Ali Gholami Rudi <ali@rudi.ir>
date: Sat Jul 19 11:38:28 EDT 2014
roff: prefer macro.tmac to tmac.macro for -mmacro
--- a/roff.c
+++ b/roff.c
@@ -33,6 +33,14 @@
return m;
}
+static int xopens(char *path)
+{
+ FILE *filp = fopen(path, "r");
+ if (filp)
+ fclose(filp);
+ return filp != NULL;
+}
+
static char *usage =
"Usage: neatroff [options] input\n\n"
"Options:\n"
@@ -58,7 +66,9 @@
n_cp = 1;
break;
case 'm':
- sprintf(path, "%s/tmac.%s", macrodir, argv[i] + 2);
+ sprintf(path, "%s/%s.tmac", macrodir, argv[i] + 2);
+ if (!xopens(path))
+ sprintf(path, "%s/tmac.%s", macrodir, argv[i] + 2);
in_queue(path);
break;
case 'F':