From 824477cf6b15ebc0023793e293a158a00c8bddfb Mon Sep 17 00:00:00 2001
From: Behdad Esfahbod <behdad@behdad.org>
Date: Fri, 4 Jan 2013 19:56:08 -0600
Subject: [PATCH] Fix rule X8 when paragraph-separator is present

As discovered by:
https://github.com/behdad/fribidi-vs-unicode

All passing now.
---
 lib/fribidi-bidi.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/lib/fribidi-bidi.c b/lib/fribidi-bidi.c
index 6e67d57..89d6546 100644
--- a/lib/fribidi-bidi.c
+++ b/lib/fribidi-bidi.c
@@ -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! */
-- 
2.40.0