]> Savannah Git Hosting - gnulib.git/commitdiff
unilbrk: Fix conflicts between rules.
authorBruno Haible <bruno@clisp.org>
Sun, 15 Sep 2024 13:06:01 +0000 (15:06 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 15 Sep 2024 13:06:01 +0000 (15:06 +0200)
* lib/unilbrk/u8-possible-linebreaks.c (u8_possible_linebreaks_loop):
Avoid side effect of (LB18) on (LB14) and (LB15a). Avoid side effect
of (LB19a) on (LB18).
* lib/unilbrk/u16-possible-linebreaks.c (u16_possible_linebreaks_loop):
Likewise.
* lib/unilbrk/u32-possible-linebreaks.c (u32_possible_linebreaks_loop):
Likewise.

ChangeLog
lib/unilbrk/u16-possible-linebreaks.c
lib/unilbrk/u32-possible-linebreaks.c
lib/unilbrk/u8-possible-linebreaks.c

index c8db2a3230a31f0e46e6d35c586afe53adda0a7f..d8396afb00697ff5b45cf14f275b95f2ac13d444 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2024-09-15  Bruno Haible  <bruno@clisp.org>
+
+       unilbrk: Fix conflicts between rules.
+       * lib/unilbrk/u8-possible-linebreaks.c (u8_possible_linebreaks_loop):
+       Avoid side effect of (LB18) on (LB14) and (LB15a). Avoid side effect
+       of (LB19a) on (LB18).
+       * lib/unilbrk/u16-possible-linebreaks.c (u16_possible_linebreaks_loop):
+       Likewise.
+       * lib/unilbrk/u32-possible-linebreaks.c (u32_possible_linebreaks_loop):
+       Likewise.
+
 2024-09-15  Bruno Haible  <bruno@clisp.org>
 
        unilbrk: Enable most cases of Unicode rule (LB29).
index bf0f31057f9048e9f812e1d4ec8c8cae7f686862..96780416062af6f3ad0c6d8892a6a7c55c411274 100644 (file)
@@ -190,7 +190,12 @@ u16_possible_linebreaks_loop (const uint16_t *s, size_t n, const char *encoding,
                       last_prop = LBP_AL1;
                       seen_space = NULL;
                     }
-                  else if (last_prop == LBP_ZW || seen_space != NULL)
+                  else if (last_prop == LBP_ZW
+                           || (seen_space != NULL
+                               /* (LB14) has higher priority than (LB18).  */
+                               && !(last_prop == LBP_OP1 || last_prop == LBP_OP2)
+                               /* (LB15a) has higher priority than (LB18).  */
+                               && !(last_prop == LBP_QU2)))
                     {
                       /* (LB8) Break after zero-width space.  */
                       /* (LB18) Break after spaces.
@@ -236,7 +241,9 @@ u16_possible_linebreaks_loop (const uint16_t *s, size_t n, const char *encoding,
                       *p = UC_BREAK_POSSIBLE;
                     }
                   else if (((prop == LBP_QU1 || prop == LBP_QU2 || prop == LBP_QU3)
-                            && (! prev_ea || ! EA (lookahead1_prop_ea)))
+                            && (! prev_ea || ! EA (lookahead1_prop_ea))
+                            /* (LB18) has higher priority than (LB19a).  */
+                            && prev_prop != LBP_SP)
                            || ((prev_prop == LBP_QU1 || prev_prop == LBP_QU2 || prev_prop == LBP_QU3)
                                && (! prev2_ea || ! ea)))
                     {
index a7630467a6a643fa04c80b3d8a3e63ffd79b9bf2..c12ca3abbbd47ab75c6224aa764e09643ecc524f 100644 (file)
@@ -183,7 +183,12 @@ u32_possible_linebreaks_loop (const uint32_t *s, size_t n, const char *encoding,
                       last_prop = LBP_AL1;
                       seen_space = NULL;
                     }
-                  else if (last_prop == LBP_ZW || seen_space != NULL)
+                  else if (last_prop == LBP_ZW
+                           || (seen_space != NULL
+                               /* (LB14) has higher priority than (LB18).  */
+                               && !(last_prop == LBP_OP1 || last_prop == LBP_OP2)
+                               /* (LB15a) has higher priority than (LB18).  */
+                               && !(last_prop == LBP_QU2)))
                     {
                       /* (LB8) Break after zero-width space.  */
                       /* (LB18) Break after spaces.
@@ -229,7 +234,9 @@ u32_possible_linebreaks_loop (const uint32_t *s, size_t n, const char *encoding,
                       *p = UC_BREAK_POSSIBLE;
                     }
                   else if (((prop == LBP_QU1 || prop == LBP_QU2 || prop == LBP_QU3)
-                            && (! prev_ea || ! EA (lookahead1_prop_ea)))
+                            && (! prev_ea || ! EA (lookahead1_prop_ea))
+                            /* (LB18) has higher priority than (LB19a).  */
+                            && prev_prop != LBP_SP)
                            || ((prev_prop == LBP_QU1 || prev_prop == LBP_QU2 || prev_prop == LBP_QU3)
                                && (! prev2_ea || ! ea)))
                     {
index 7abf20beed438f43ee6312593de2c9dcc2503732..3f32ee628918f5f79d9858502106bc9ebff53b50 100644 (file)
@@ -190,7 +190,12 @@ u8_possible_linebreaks_loop (const uint8_t *s, size_t n, const char *encoding,
                       last_prop = LBP_AL1;
                       seen_space = NULL;
                     }
-                  else if (last_prop == LBP_ZW || seen_space != NULL)
+                  else if (last_prop == LBP_ZW
+                           || (seen_space != NULL
+                               /* (LB14) has higher priority than (LB18).  */
+                               && !(last_prop == LBP_OP1 || last_prop == LBP_OP2)
+                               /* (LB15a) has higher priority than (LB18).  */
+                               && !(last_prop == LBP_QU2)))
                     {
                       /* (LB8) Break after zero-width space.  */
                       /* (LB18) Break after spaces.
@@ -236,7 +241,9 @@ u8_possible_linebreaks_loop (const uint8_t *s, size_t n, const char *encoding,
                       *p = UC_BREAK_POSSIBLE;
                     }
                   else if (((prop == LBP_QU1 || prop == LBP_QU2 || prop == LBP_QU3)
-                            && (! prev_ea || ! EA (lookahead1_prop_ea)))
+                            && (! prev_ea || ! EA (lookahead1_prop_ea))
+                            /* (LB18) has higher priority than (LB19a).  */
+                            && prev_prop != LBP_SP)
                            || ((prev_prop == LBP_QU1 || prev_prop == LBP_QU2 || prev_prop == LBP_QU3)
                                && (! prev2_ea || ! ea)))
                     {