[pango/more-log-attr-things: 4/6] break: Fix up word fixups




commit 6556d11c4319c71e054c44efa568f2ff160f00f9
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Aug 26 01:14:07 2021 -0400

    break: Fix up word fixups

 pango/break.c                | 18 ++++++++++++------
 tests/breaks/twelve.expected | 14 +++++++-------
 2 files changed, 19 insertions(+), 13 deletions(-)
---
diff --git a/pango/break.c b/pango/break.c
index 5d901ec6..c6ee6da6 100644
--- a/pango/break.c
+++ b/pango/break.c
@@ -1867,11 +1867,14 @@ handle_words (const char    *text,
       if (start >= offset)
         {
           gboolean in_word = FALSE;
-          for (pos = start_pos - 1; pos >= 0; pos--)
+          for (pos = start_pos; pos >= 0; pos--)
             {
               if (log_attrs[pos].is_word_end)
-                break;
-              if (log_attrs[pos].is_word_start)
+                {
+                  in_word = pos == start_pos;
+                  break;
+                }
+              if (pos < start_pos && log_attrs[pos].is_word_start)
                 {
                   in_word = TRUE;
                   break;
@@ -1890,11 +1893,14 @@ handle_words (const char    *text,
       if (end < offset + length)
         {
           gboolean in_word = FALSE;
-          for (pos = end_pos + 1; pos < log_attrs_len; pos++)
+          for (pos = end_pos; pos < log_attrs_len; pos++)
             {
               if (log_attrs[pos].is_word_start)
-                break;
-              if (log_attrs[pos].is_word_end)
+                {
+                  in_word = pos == end_pos;
+                  break;
+                }
+              if (pos > end_pos && log_attrs[pos].is_word_end)
                 {
                   in_word = TRUE;
                   break;
diff --git a/tests/breaks/twelve.expected b/tests/breaks/twelve.expected
index 0fb7655e..cfb8e625 100644
--- a/tests/breaks/twelve.expected
+++ b/tests/breaks/twelve.expected
@@ -1,7 +1,7 @@
-Text:         ⁦t⁩ ⁦h⁩ ⁦e⁩  [ ]  ⁦f⁩ ⁦i⁩ ⁦l⁩ ⁦e⁩  [ ]  ⁦/⁩ ⁦p⁩ ⁦a⁩ ⁦t⁩ ⁦h⁩ ⁦/⁩   ⁦t⁩ ⁦o⁩ ⁦/⁩  ⁦m⁩ ⁦y⁩ ⁦/⁩   
⁦h⁩ ⁦o⁩ ⁦m⁩ ⁦e⁩  [ ]  ⁦i⁩ ⁦s⁩  [ ]  ⁦c⁩ ⁦u⁩ ⁦r⁩ ⁦s⁩ ⁦e⁩ ⁦d⁩  ⁦.⁩ [0x0a]  
-Breaks:     c  c c c    lc c c c c    lc c c c c c lc  c c lc c c lc  c c c c    lc c c    lc c c c c c c  c 
     lc
-Whitespace:        x             x                                          x         x                    w 
     w 
-Sentences:  bs                                                                                             e 
     b 
-Words:      bs     be   bs       be   bs           bse     bs     bse       be   bs   be   bs           be b 
     b 
-Graphemes:  b  b b b    b  b b b b    b  b b b b b b   b b b  b b b   b b b b    b  b b    b  b b b b b b  b 
     b 
-Hyphens:       i i         i i i           i i i       i      i       i i i         i         i i i i i      
       
+Text:         ⁦t⁩ ⁦h⁩ ⁦e⁩  [ ]  ⁦f⁩ ⁦i⁩ ⁦l⁩ ⁦e⁩  [ ]  ⁦/⁩ ⁦p⁩ ⁦a⁩ ⁦t⁩ ⁦h⁩ ⁦/⁩   ⁦t⁩ ⁦o⁩ ⁦/⁩   ⁦m⁩ ⁦y⁩ ⁦/⁩   
⁦h⁩ ⁦o⁩ ⁦m⁩ ⁦e⁩  [ ]  ⁦i⁩ ⁦s⁩  [ ]  ⁦c⁩ ⁦u⁩ ⁦r⁩ ⁦s⁩ ⁦e⁩ ⁦d⁩  ⁦.⁩ [0x0a]  
+Breaks:     c  c c c    lc c c c c    lc c c c c c lc  c c lc  c c lc  c c c c    lc c c    lc c c c c c c  
c      Lc
+Whitespace:        x             x                                           x         x                    
w      w 
+Sentences:  bs                                                                                              
e      b 
+Words:      bs     be   bs       be   bs           bse     bse     bse       be   bs   be   bs           be 
b      b 
+Graphemes:  b  b b b    b  b b b b    b  b b b b b b   b b b   b b b   b b b b    b  b b    b  b b b b b b  
b      b 
+Hyphens:       i i         i i i           i i i       i       i       i i i         i         i i i i i     
        


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