Imported Upstream version 0.19.7
[platform/upstream/fribidi.git] / lib / fribidi-bidi.c
index 42a5fab..89d6546 100644 (file)
@@ -463,6 +463,13 @@ fribidi_get_par_embedding_levels (
          move_node_before (pp, explicits_list);
          pp = &temp_link;
        }
+      else if (this_type == FRIBIDI_TYPE_BS)
+       {
+         /* X8. All explicit directional embeddings and overrides are
+            completely terminated at the end of each paragraph. Paragraph
+            separators are not included in the embedding. */
+         break;
+       }
       else
        {
          /* X6. For all types besides RLE, LRE, RLO, LRO, and PDF:
@@ -475,11 +482,6 @@ fribidi_get_par_embedding_levels (
          if (!FRIBIDI_IS_NEUTRAL (override))
            RL_TYPE (pp) = override;
        }
-      /* X8. All explicit directional embeddings and overrides are
-         completely terminated at the end of each paragraph. Paragraph
-         separators are not included in the embedding. */
-      /* This function is running on a single paragraph, so we can do
-         X8 after all the input is processed. */
     }
 
     /* Implementing X8. It has no effect on a single paragraph! */
@@ -546,6 +548,10 @@ fribidi_get_par_embedding_levels (
            pp = merge_with_prev (pp);
          else
            RL_TYPE (pp) = prev_type;
+         if (prev_type == next_type && RL_LEVEL (pp) == RL_LEVEL (pp->next))
+           {
+             pp = merge_with_prev (pp->next);
+           }
          continue;             /* As we know the next condition cannot be true. */
        }
 
@@ -564,7 +570,7 @@ fribidi_get_par_embedding_levels (
 
     last_strong = base_dir;
     /* Resolving dependency of loops for rules W4 and W5, W5 may
-       want to prevent W4 to take effect in the next turn, do this 
+       want to prevent W4 to take effect in the next turn, do this
        through "w4". */
     w4 = true;
     /* Resolving dependency of loops for rules W4 and W5 with W7,