shithub: neatroff

Download patch

ref: 399a4936bad90998d119f25431889b25a3b03f5f
parent: 78c8c41519032385bda232d10bf1043600de98ed
author: Ali Gholami Rudi <[email protected]>
date: Mon Feb 17 11:58:50 EST 2014

wb: zero-width break point (\:)

--- a/out.c
+++ b/out.c
@@ -152,7 +152,8 @@
 				c[0] = c[1];
 				c[1] = '\0';
 			}
-			if (c[0] == '\t' || c[0] == '' || !strcmp(c_hc, c))
+			if (c[0] == '\t' || c[0] == '' ||
+					!strcmp(c_hc, c) || !strcmp(c_bp, c))
 				continue;
 			outc(cmap_map(c));
 			continue;
--- a/roff.h
+++ b/roff.h
@@ -71,6 +71,7 @@
 #define c_mc	env_mc()/* margin character (.mc) */
 #define c_tc	env_tc()
 #define c_lc	env_lc()
+#define c_bp	"\\:"	/* zero-width word break point */
 
 /* number registers */
 int num_get(int id, int inc);
--- a/wb.c
+++ b/wb.c
@@ -157,7 +157,7 @@
 		else
 			sbuf_printf(&wb->sbuf, "%cC'%s'", c_ec, c);
 	}
-	if (strcmp(c_hc, c)) {
+	if (strcmp(c_hc, c) && strcmp(c_bp, c)) {
 		wb_prevput(wb, c, ll);
 		wb->h += charwid(R_F(wb), R_S(wb), g ? g->wid : SC_DW);
 		wb->ct |= g ? g->type : 0;
@@ -366,7 +366,8 @@
 	return 0;
 }
 
-static char *dashpos(char *s, int w, struct wb *w1, int flg)
+/* the position marked with hyphens or \: */
+static char *bp_pos(char *s, int w, struct wb *w1, int flg)
 {
 	char d[ILNLEN];
 	char *r = NULL;
@@ -376,7 +377,8 @@
 		wb_putc(w1, c, d);
 		if (wb_wid(w1) > w && (!(flg & HY_ANY) || r))
 			continue;
-		if (!c && (!strcmp("-", d) || (!strcmp("em", d) || !strcmp("hy", d))))
+		if (!c && (!strcmp("-", d) || (!strcmp("em", d) ||
+					!strcmp("hy", d)) || !strcmp(c_bp, d)))
 			r = s;
 	}
 	return r;
@@ -388,7 +390,8 @@
 	return charwid(R_F(wb), R_S(wb), g ? g->wid : SC_DW);
 }
 
-static char *indicatorpos(char *s, int w, struct wb *w1, int flg)
+/* the position marked with \% */
+static char *hc_pos(char *s, int w, struct wb *w1, int flg)
 {
 	char d[ILNLEN];
 	char *r = NULL;
@@ -466,8 +469,8 @@
 	char *dp, *hp, *p;
 	if (skipreqs(&s, w1))
 		return 1;
-	dp = dashpos(sbuf_buf(&wb->sbuf), w, w1, flg);
-	hp = indicatorpos(sbuf_buf(&wb->sbuf), w, w1, flg);
+	dp = bp_pos(sbuf_buf(&wb->sbuf), w, w1, flg);
+	hp = hc_pos(sbuf_buf(&wb->sbuf), w, w1, flg);
 	if (hp && dp)
 		p = flg & HY_ANY ? MIN(dp, hp) : MAX(dp, hp);
 	else