Skip to content

Commit

Permalink
Ignore missing base character problem in backwards compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
egli committed May 23, 2024
1 parent df4c05c commit b8d236a
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions src/translator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit b8d236a

Please sign in to comment.