groff-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[groff] 01/02: troff: Fix hyphenation (#48904).


From: Werner LEMBERG
Subject: [groff] 01/02: troff: Fix hyphenation (#48904).
Date: Fri, 9 Sep 2016 06:47:35 +0000 (UTC)

wl pushed a commit to branch master
in repository groff.

commit 9ccdebab1133a62a719ec5e65c1e6aeef972636c
Author: Werner Lemberg <address@hidden>
Date:   Fri Sep 9 08:42:56 2016 +0200

    troff: Fix hyphenation (#48904).
    
    This commit fixes two bugs present from the very beginning: troff
    (a) didn't allow to hyphenate words shorter than 4 characters
    (ignoring `.hy' settings), and (b) never tried to hyphenate after
    the first character due to wrong handling of the `.hy' settings.
    
    * src/roff/troff/env.cpp (environment::hyphenate_line): Use
    hyphenation flags to determine the minimum word length considered
    for hyphenation.
    (hyphenate): Fix handling of `HYPHEN_FIRST_CHARS'.
---
 ChangeLog              |   14 ++++++++++++++
 src/roff/troff/env.cpp |    7 ++++---
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 156d23a..ff2ab4d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2016-09-09  Werner LEMBERG  <address@hidden>
+
+       troff: Fix hyphenation (#48904).
+
+       This commit fixes two bugs present from the very beginning: troff
+       (a) didn't allow to hyphenate words shorter than 4 characters
+       (ignoring `.hy' settings), and (b) never tried to hyphenate after
+       the first character due to wrong handling of the `.hy' settings.
+
+       * src/roff/troff/env.cpp (environment::hyphenate_line): Use
+       hyphenation flags to determine the minimum word length considered
+       for hyphenation.
+       (hyphenate): Fix handling of `HYPHEN_FIRST_CHARS'.
+
 2016-07-29  Colin Watson  <address@hidden>
 
        Implement `SOURCE_DATE_EPOCH' for reproducible builds.
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index 40e994e..2c82c56 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -2023,7 +2023,9 @@ void environment::hyphenate_line(int start_here)
       && !((hyphenation_flags & HYPHEN_LAST_LINE)
           && (curdiv->distance_to_next_trap()
               <= vertical_spacing + total_post_vertical_spacing()))
-      && i >= 4)
+      && i >= (2
+              + (hyphenation_flags & HYPHEN_FIRST_CHARS ? 1 : 0)
+              + (hyphenation_flags & HYPHEN_LAST_CHARS ? 1 : 0)))
     hyphenate(sl, hyphenation_flags);
   while (forward != 0) {
     node *tem1 = forward;
@@ -3963,9 +3965,8 @@ void hyphenate(hyphen_list *h, unsigned flags)
        int num[WORD_MAX + 3];
        current_language->patterns.hyphenate(hbuf, len + 2, num);
        int i;
-       num[2] = 0;
        if (flags & HYPHEN_FIRST_CHARS)
-         num[3] = 0;
+         num[2] = 0;
        if (flags & HYPHEN_LAST_CHARS)
          --len;
        for (i = 2, tem = h; i < len && tem; tem = tem->next, i++)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]