shithub: neatroff

Download patch

ref: d6a2897ca2b39a839c3fd45d0b7eb73367ffd26b
parent: 7a335e6d95e877ab0c3a91e3efd9cabcc61e020b
author: Ali Gholami Rudi <[email protected]>
date: Tue Apr 22 12:20:11 EDT 2014

dev: introduce \[GID=xyz] as an alias for \N'xyz'

--- a/dev.c
+++ b/dev.c
@@ -154,16 +154,15 @@
 
 struct glyph *dev_glyph(char *c, int fn)
 {
+	struct glyph *g;
 	if ((c[0] == c_ec || c[0] == c_ni) && c[1] == c_ec)
 		c++;
 	if (c[0] == c_ec && c[1] == '(')
 		c += 2;
-	return dev_find(cmap_map(c), fn, 0);
-}
-
-struct glyph *dev_glyph_byid(char *c, int fn)
-{
-	return dev_find(c, fn, 1);
+	c = cmap_map(c);
+	if ((g = dev_find(c, fn, 0)))
+		return g;
+	return !strncmp("GID=", c, 4) ? dev_find(c + 4, fn, 1) : NULL;
 }
 
 int dev_kernpair(char *c1, char *c2)
--- a/ren.c
+++ b/ren.c
@@ -683,7 +683,6 @@
 static void ren_put(struct wb *wb, char *c, int (*next)(void), void (*back)(int))
 {
 	char arg[ILNLEN];
-	struct glyph *g;
 	char *s;
 	int w, n;
 	if (c[0] == ' ' || c[0] == '\n') {
@@ -726,8 +725,7 @@
 				ren_cmd(wb, c[1], arg);
 				return;
 			}
-			g = dev_glyph_byid(arg, n_f);
-			strcpy(c, g ? g->name : "cnull");
+			snprintf(c, GNLEN, "GID=%s", arg);
 		}
 	}
 	if (!ren_div && cdef_map(c, n_f)) {		/* .char characters */
--- a/roff.h
+++ b/roff.h
@@ -177,7 +177,6 @@
 
 /* glyph handling functions */
 struct glyph *dev_glyph(char *c, int fn);
-struct glyph *dev_glyph_byid(char *id, int fn);
 int charwid(int fn, int sz, int wid);
 int spacewid(int fn, int sz);