shithub: neatroff

Download patch

ref: df74a1043087d2ee385d393d4d3afebe987f7e07
parent: 2325263eb0da12d2ff37b58bbe2f70428237229b
author: Ali Gholami Rudi <ali@rudi.ir>
date: Mon Dec 15 11:34:11 EST 2014

tr: check for c_bp and c_hc in c_hymark()

--- a/out.c
+++ b/out.c
@@ -159,8 +159,7 @@
 				c[0] = c[1];
 				c[1] = '\0';
 			}
-			if (c[0] == '\t' || c[0] == '' ||
-					!strcmp(c_hc, c) || !strcmp(c_bp, c))
+			if (c[0] == '\t' || c[0] == '' || c_hymark(c))
 				continue;
 			outc(cmap_map(c));
 			continue;
--- a/roff.h
+++ b/roff.h
@@ -273,6 +273,7 @@
 int c_eostran(char *s);
 int c_hydash(char *s);
 int c_hystop(char *s);
+int c_hymark(char *s);
 
 /* character translation (.tr) */
 void cmap_add(char *c1, char *c2);
--- a/tr.c
+++ b/tr.c
@@ -444,10 +444,10 @@
 }
 
 /* hyphenation dashes and hyphenation inhibiting character */
-static char hy_dash[NCHARS][GNLEN] = { c_bp, "-", "em", "en", "\\-", "--", "hy", };
+static char hy_dash[NCHARS][GNLEN] = { "\\:", "-", "em", "en", "\\-", "--", "hy", };
 static int hy_dashcnt = 7;
-static char hy_stop[NCHARS][GNLEN];
-static int hy_stopcnt = 0;
+static char hy_stop[NCHARS][GNLEN] = { "\\%", };
+static int hy_stopcnt = 1;
 
 static void tr_nh(char **args)
 {
@@ -468,7 +468,7 @@
 
 static void tr_hydash(char **args)
 {
-	hy_dashcnt = 1;		/* c_bp should always be present */
+	hy_dashcnt = 0;
 	if (args[1]) {
 		char *s = args[1];
 		while (s && charread(&s, hy_dash[hy_dashcnt]) >= 0)
@@ -504,6 +504,11 @@
 		if (!strcmp(hy_stop[i], s))
 			return 1;
 	return 0;
+}
+
+int c_hymark(char *s)
+{
+	return !strcmp(c_bp, s) || !strcmp(c_hc, s);
 }
 
 static void tr_pmll(char **args)
--- a/wb.c
+++ b/wb.c
@@ -128,7 +128,7 @@
 		return;
 	}
 	g = dev_glyph(c, wb->f);
-	zerowidth = !strcmp(c_hc, c) || !strcmp(c_bp, c);
+	zerowidth = c_hymark(c);
 	if (!g && c[0] == c_ec && !zerowidth) {	/* unknown escape */
 		memmove(c, c + 1, strlen(c));
 		g = dev_glyph(c, wb->f);
@@ -174,7 +174,7 @@
 		smap[i] = d - word;
 		if (c_hystop(s))
 			return 1;
-		if (!strcmp(c_bp, s))
+		if (c_hymark(s))
 			continue;
 		if (!utf8one(s))
 			strcpy(d, ".");