From 4f9fe856a25ab29345b90e7725509e9ee38a37be Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:41 +0200 Subject: Adding upstream version 1.69.0+dfsg1. Signed-off-by: Daniel Baumann --- vendor/unicode-bidi/src/explicit.rs | 44 ++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 15 deletions(-) (limited to 'vendor/unicode-bidi/src/explicit.rs') diff --git a/vendor/unicode-bidi/src/explicit.rs b/vendor/unicode-bidi/src/explicit.rs index e9d579fd6..a9b13e89c 100644 --- a/vendor/unicode-bidi/src/explicit.rs +++ b/vendor/unicode-bidi/src/explicit.rs @@ -47,13 +47,17 @@ pub fn compute( RLE | LRE | RLO | LRO | RLI | LRI | FSI => { let last_level = stack.last().level; + // + levels[i] = last_level; + // X5a-X5c: Isolate initiators get the level of the last entry on the stack. let is_isolate = match original_classes[i] { RLI | LRI | FSI => true, _ => false, }; if is_isolate { - levels[i] = last_level; + // Redundant due to "Retaining explicit formatting characters" step. + // levels[i] = last_level; match stack.last().status { OverrideStatus::RTL => processing_classes[i] = R, OverrideStatus::LTR => processing_classes[i] = L, @@ -90,6 +94,13 @@ pub fn compute( } else if overflow_isolate_count == 0 { overflow_embedding_count += 1; } + + if !is_isolate { + // X9 + + // + // (PDF handled below) + processing_classes[i] = BN; + } } // @@ -123,31 +134,34 @@ pub fn compute( // PDF => { if overflow_isolate_count > 0 { - continue; - } - if overflow_embedding_count > 0 { + // do nothing + } else if overflow_embedding_count > 0 { overflow_embedding_count -= 1; - continue; - } - if stack.last().status != OverrideStatus::Isolate && stack.vec.len() >= 2 { + } else if stack.last().status != OverrideStatus::Isolate && stack.vec.len() >= 2 { stack.vec.pop(); } - // The spec doesn't explicitly mention this step, but it is necessary. - // See the reference implementations for comparison. + // levels[i] = stack.last().level; + // X9 part of retaining explicit formatting characters. + processing_classes[i] = BN; } - // Nothing - B | BN => {} + // Nothing. + // BN case moved down to X6, see + B => {} // _ => { let last = stack.last(); levels[i] = last.level; - match last.status { - OverrideStatus::RTL => processing_classes[i] = R, - OverrideStatus::LTR => processing_classes[i] = L, - _ => {} + // This condition is not in the spec, but I am pretty sure that is a spec bug. + // https://www.unicode.org/L2/L2023/23014-amd-to-uax9.pdf + if original_classes[i] != BN { + match last.status { + OverrideStatus::RTL => processing_classes[i] = R, + OverrideStatus::LTR => processing_classes[i] = L, + _ => {} + } } } } -- cgit v1.2.3