shithub: neatroff

Download patch

ref: d89240a6c8f92e31ec473c8dc9370947aa368aa2
parent: 1471e7fb9163c70e5dbd2239fec85894315bb6b8
author: Ali Gholami Rudi <ali@rudi.ir>
date: Wed May 15 17:17:29 EDT 2013

hyph: let words match the largest prefix .hw exceptions

--- a/hyph.c
+++ b/hyph.c
@@ -26,14 +26,12 @@
 static void hyexcept_add(char *s)
 {
 	char *d = hyexcept + nhyexcept;
-	char *prev_d = d;
 	*d++ = ' ';
 	while (*s) {
 		if (*s == '-') {
-			hyexcept_hyph[prev_d - hyexcept] = 1;
+			hyexcept_hyph[d - hyexcept - 1] = 1;
 			s++;
 		} else {
-			prev_d = d;
 			d += utf8read(&s, d);
 		}
 	}
@@ -55,10 +53,17 @@
 {
 	char word[ILNLEN];
 	char *r;
+	int len, i;
 	word[0] = ' ';
 	strcpy_lower(word + 1, s);
-	r = strstr(hyexcept, word);
-	return r ? hyexcept_hyph + (r - hyexcept) : NULL;
+	len = strlen(word);
+	for (i = len; i >= 4; i--) {
+		word[i] = ' ';
+		word[i + 1] = '\0';
+		if ((r = strstr(hyexcept, word)))
+			return hyexcept_hyph + (r - hyexcept);
+	}
+	return NULL;
 }
 
 void hyphenate(char *hyph, char *word)