shithub: neatroff

Download patch

ref: c85fa7e796eb6041f4a9d3341226452d15ff1f0f
parent: 31846b170584720ff92cb53cbba3db259059041a
author: Ali Gholami Rudi <ali@rudi.ir>
date: Sat Jun 22 15:05:14 EDT 2013

wb: add \C'cname'

--- a/out.c
+++ b/out.c
@@ -176,12 +176,12 @@
 	if (d[0] == c_ec) {
 		utf8read(s, d + 1);
 		if (d[1] == '(') {
-			utf8read(s, d + 2);
+			utf8read(s, d);
 			utf8read(s, d + strlen(d));
-		} else if (strchr("DfhsvXx", d[1])) {
+		} else if (strchr("CDfhsvXx", d[1])) {
 			int c = d[1];
 			escarg(s, d, d[1]);
-			return c;
+			return c == 'C' ? 0 : c;
 		}
 	}
 	if (d[0] == c_ni)
--- a/ren.c
+++ b/ren.c
@@ -656,10 +656,13 @@
 				ren_transparent(arg);
 			}
 			return;
-		} else if (strchr(" bcDdfhkLloprsuvXxz0^|{}&", c[1])) {
+		} else if (strchr(" bCcDdfhkLloprsuvXxz0^|{}&", c[1])) {
 			escarg_ren(arg, c[1], next, back);
-			ren_cmd(wb, c[1], arg);
-			return;
+			if (c[1] != 'C') {
+				ren_cmd(wb, c[1], arg);
+				return;
+			}
+			strcpy(c, arg);
 		}
 	}
 	if (c[0] == c_ni)
--- a/wb.c
+++ b/wb.c
@@ -87,7 +87,15 @@
 	}
 	g = dev_glyph(c, R_F(wb));
 	wb_font(wb);
-	sbuf_append(&wb->sbuf, c);
+	if (!c[1] || c[0] == c_ec || c[0] == c_ni ||
+			utf8len((unsigned char) c[0]) == strlen(c)) {
+		sbuf_append(&wb->sbuf, c);
+	} else {
+		if (c[1] && !c[2])
+			sbuf_printf(&wb->sbuf, "%c(%s", c_ec, c);
+		else
+			sbuf_printf(&wb->sbuf, "%cC'%s'", c_ec, c);
+	}
 	if (strcmp(c_hc, c)) {
 		wb->h += charwid(g ? g->wid : SC_DW, R_S(wb));
 		wb->ct |= g ? g->type : 0;
@@ -166,6 +174,7 @@
 {
 	switch (t) {
 	case 0:
+	case 'C':
 		wb_put(wb, s);
 		break;
 	case 'D':
@@ -250,8 +259,7 @@
 		wb_putc(w1, c, d);
 		if (wb_wid(w1) > w && (!any || r))
 			break;
-		if (!strcmp("-", d) || (d[0] == c_ec && (!strcmp("(em", d + 1) ||
-							!strcmp("(hy", d + 1))))
+		if (!strcmp("-", d) || (!strcmp("em", d) || !strcmp("hy", d)))
 			r = s;
 	}
 	return r;
@@ -313,7 +321,6 @@
 static void dohyph(char *s, char *pos, int dash, struct wb *w1, struct wb *w2)
 {
 	char d[ILNLEN];
-	char hy[GNLEN] = {c_ec, '(', 'h', 'y'};
 	int c = -1;
 	wb_reset(w1);
 	wb_reset(w2);
@@ -320,7 +327,7 @@
 	while (s != pos && (c = out_readc(&s, d)) >= 0)
 		wb_putc(w1, c, d);
 	if (dash)
-		wb_putc(w1, 0, hy);
+		wb_putc(w1, 0, "hy");
 	w2->r_s = w1->r_s;
 	w2->r_f = w1->r_f;
 	while ((c = out_readc(&s, d)) >= 0)