From b8d236ad102ec3f565742d606908295c71a662a8 Mon Sep 17 00:00:00 2001 From: Christian Egli Date: Thu, 23 May 2024 17:46:09 +0200 Subject: [PATCH] Ignore missing base character problem in backwards compatibility --- src/translator.rs | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/src/translator.rs b/src/translator.rs index bb947e8..89db384 100644 --- a/src/translator.rs +++ b/src/translator.rs @@ -246,21 +246,28 @@ impl TranslationTable { for rule in rules { match rule.rule { Rule::Base { derived, base, .. } => { - let translation = character_definitions.get(&base).ok_or( - TranslationError::BaseCharacterNotDefined { - base, - derived, - direction, - }, - )?; - character_definitions.insert( - derived, - Translation { - input: derived.to_string(), - ..translation.clone() - }, - ); - } + if let Some(translation) = character_definitions.get(&base) { + character_definitions.insert( + derived, + Translation { + input: derived.to_string(), + ..translation.clone() + }, + ); + } else { + // hm, there is no character definition for the base character + if cfg!(feature = "backwards_compatibility") { + // ignore this problem + } else { + // trow an error + return Err(TranslationError::BaseCharacterNotDefined { + base, + derived, + direction, + }); + } + } + } Rule::Comp6 { chars, dots: Braille::Implicit,