shithub: neatroff

Download patch

ref: cb39077a4a8e2be1b11b02c0f3f93730f8de4658
parent: e76edc13b0c4d5841efb5c04b5fdf3dfbbc144cc
author: Ali Gholami Rudi <ali@rudi.ir>
date: Wed Sep 25 16:51:25 EDT 2013

wb: remove long character names for the string passed to hyphenate()

--- a/font.c
+++ b/font.c
@@ -65,6 +65,16 @@
 	return 0;
 }
 
+/* return nonzero if s is a ligature */
+int font_islig(struct font *fn, char *s)
+{
+	int i;
+	for (i = 0; i < fn->nlig; i++)
+		if (!strcmp(s, fn->lig[i]))
+			return 1;
+	return 0;
+}
+
 /* return pairwise kerning value between c1 and c2 */
 int font_kern(struct font *fn, char *c1, char *c2)
 {
--- a/roff.h
+++ b/roff.h
@@ -141,6 +141,7 @@
 struct glyph *font_find(struct font *fn, char *name);
 int font_lig(struct font *fn, char **c, int n);
 int font_kern(struct font *fn, char *c1, char *c2);
+int font_islig(struct font *fn, char *s);
 
 /* glyph handling functions */
 struct glyph *dev_glyph(char *c, int fn);
--- a/wb.c
+++ b/wb.c
@@ -416,6 +416,9 @@
 		if (c == 0) {
 			iw[n] = wp;
 			is[n] = prev_s;
+			/* ignore multi-char aliases except for ligatures */
+			if (!utf8one(d) && !font_islig(dev_font(R_F(w1)), d))
+				strcpy(d, ".");
 			strcpy(wp, d);
 			wp = strchr(wp, '\0');
 			n++;
@@ -422,10 +425,10 @@
 		}
 		prev_s = s;
 	}
-	if (n < 4)
+	if (n < 3)
 		return NULL;
 	hyphenate(hyph, word, flg);
-	for (i = 2; i < n - 1; i++)
+	for (i = 1; i < n - 1; i++)
 		if (hyph[iw[i] - word] && (fits[i] || ((flg & HY_ANY) && !r)))
 			r = is[i];
 	return r;