]> Savannah Git Hosting - gnulib.git/commitdiff
unigbrk, uniwbrk: No-op tweaks.
authorBruno Haible <bruno@clisp.org>
Mon, 27 Dec 2021 12:01:50 +0000 (13:01 +0100)
committerBruno Haible <bruno@clisp.org>
Tue, 28 Dec 2021 11:44:01 +0000 (12:44 +0100)
* lib/unigbrk/u-grapheme-breaks.h: Comment tweaks.
* lib/uniwbrk/u-wordbreaks.h: Coding style and comment tweaks.
* lib/uniwbrk/wbrktable.c: Comment tweaks.

ChangeLog
lib/unigbrk/u-grapheme-breaks.h
lib/uniwbrk/u-wordbreaks.h
lib/uniwbrk/wbrktable.c

index 44f69d394a337e51e1764c94c58a9fb714d7abd1..2af9c36cc1998f5e355fcfc40b53373135cec4b4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2021-12-28  Bruno Haible  <bruno@clisp.org>
+
+       unigbrk, uniwbrk: No-op tweaks.
+       * lib/unigbrk/u-grapheme-breaks.h: Comment tweaks.
+       * lib/uniwbrk/u-wordbreaks.h: Coding style and comment tweaks.
+       * lib/uniwbrk/wbrktable.c: Comment tweaks.
+
 2021-12-28  Paul Eggert  <eggert@cs.ucla.edu>
 
        perl: let caller see whether perl was found
index 6c1a6aeb898ba05482d8f7714cc95c3bef6aae26..2b4ae0e60da503a44d2c32ff7ee8a53bdb29d16f 100644 (file)
@@ -23,6 +23,9 @@
    License and of the GNU General Public License along with this
    program.  If not, see <https://www.gnu.org/licenses/>.  */
 
+/* This file implements section 3 "Grapheme Cluster Boundaries"
+   of Unicode Standard Annex #29 <https://www.unicode.org/reports/tr29/>.  */
+
 void
 FUNC (const UNIT *s, size_t n, char *p)
 {
@@ -38,6 +41,8 @@ FUNC (const UNIT *s, size_t n, char *p)
          -1 at the very beginning of the string.  */
       int last_compchar_prop = -1;
 
+      /* Number of consecutive regional indicator (RI) characters seen
+         immediately before the current point.  */
       size_t ri_count = 0;
 
       /* Don't break inside multibyte characters.  */
@@ -106,7 +111,7 @@ FUNC (const UNIT *s, size_t n, char *p)
                     *p = 1;
                   /* else *p = 0; */
                 }
-              /* Break everywhere (GBP999).  */
+              /* Break everywhere (GB999).  */
               else
                 *p = 1;
             }
index 1be288067111a3e7f752446357e76096991f2b05..8ac5cd06cc26a29062e6e4c055408d09ee9dcd3e 100644 (file)
@@ -23,6 +23,9 @@
    License and of the GNU General Public License along with this
    program.  If not, see <https://www.gnu.org/licenses/>.  */
 
+/* This file implements section 4 "Word Boundaries"
+   of Unicode Standard Annex #29 <https://www.unicode.org/reports/tr29/>.  */
+
 void
 FUNC (const UNIT *s, size_t n, char *p)
 {
@@ -47,6 +50,8 @@ FUNC (const UNIT *s, size_t n, char *p)
          -1 at the very beginning of the string.  */
       int secondlast_compchar_prop = -1;
 
+      /* Number of consecutive regional indicator (RI) characters seen
+         immediately before the current point.  */
       size_t ri_count = 0;
 
       /* Don't break inside multibyte characters.  */
@@ -73,11 +78,15 @@ FUNC (const UNIT *s, size_t n, char *p)
                            || prop == WBP_NEWLINE))
                 *p = 1;
               /* No break within emoji zwj sequence (WB3c).  */
-              else if (last_char_prop == WBP_ZWJ &&
-                       (prop == WBP_GAZ || prop == WBP_EBG))
+              else if (last_char_prop == WBP_ZWJ
+                       && (prop == WBP_GAZ || prop == WBP_EBG))
+                /* *p = 0 */;
+              /* Ignore Format and Extend characters (WB4).  */
+              else if (prop == WBP_EXTEND
+                       || prop == WBP_FORMAT
+                       || prop == WBP_ZWJ)
                 /* *p = 0 */;
-              /* Ignore Format and Extend characters.  */
-              else if (!(prop == WBP_EXTEND || prop == WBP_FORMAT || prop == WBP_ZWJ))
+              else
                 {
                   /* No break in these situations (see UAX #29):
 
@@ -146,7 +155,7 @@ FUNC (const UNIT *s, size_t n, char *p)
           last_char_prop = prop;
 
           /* Ignore Format and Extend characters, except at the
-             start of the line.  */
+             start of the line (WB4).  */
           if (last_compchar_prop < 0
               || last_compchar_prop == WBP_CR
               || last_compchar_prop == WBP_LF
index 9af65ffb661d320de3394dea1337addc1182dd48..59d94c688efa7d1da45ee61a4e8f2e9d64e34ce9 100644 (file)
@@ -58,16 +58,16 @@ const int uniwbrk_prop_index[22] =
 
                            last         current
 
-                     (ALetter | HL) × (ALetter | HL)                  (WB5)
-                     (ALetter | HL) × Numeric                         (WB9)
-                                 HL × SQ                              (WB7a)
-                            Numeric × (ALetter | HL)                  (WB10)
-                            Numeric × Numeric                         (WB8)
-                           Katakana × Katakana                        (WB13)
-(ALetter | HL | Numeric | Katakana) × ExtendNumLet                    (WB13a)
-                       ExtendNumLet × ExtendNumLet                    (WB13a)
-                   ExtendNumLet × (ALetter | HL | Numeric | Katakana) (WB13b)
-                     (E_Base | EBG) × E_Modifier                      (WB14)
+                     (ALetter | HL) × (ALetter | HL)                       (WB5)
+                     (ALetter | HL) × Numeric                              (WB9)
+                                 HL × SQ                                   (WB7a)
+                            Numeric × (ALetter | HL)                       (WB10)
+                            Numeric × Numeric                              (WB8)
+                           Katakana × Katakana                             (WB13)
+(ALetter | HL | Numeric | Katakana) × ExtendNumLet                         (WB13a)
+                       ExtendNumLet × ExtendNumLet                         (WB13a)
+                       ExtendNumLet × (ALetter | HL | Numeric | Katakana)  (WB13b)
+                     (E_Base | EBG) × E_Modifier                           (WB14)
 
    Note that the following rules are not handled here but in the loop in u-wordbreaks.h:
    - The rules need to look back or look ahead the second character (WB6, WB7, WB7b, WB7c, WB11, WB12)