[fix] transliteration case where a context no match comes at the end of the string

This commit is contained in:
Al
2018-02-06 15:08:11 -05:00
parent 156c8bed40
commit 2290b0991e
2 changed files with 3 additions and 0 deletions

View File

@@ -938,6 +938,7 @@ char *transliterate(char *trans_name, char *str, size_t len) {
if (context_no_match && !prev_state.empty_transition && prev_state.phrase_len > 0) { if (context_no_match && !prev_state.empty_transition && prev_state.phrase_len > 0) {
log_debug("Previous phrase stays as is %.*s\n", (int)prev_state.phrase_len, str+prev_state.phrase_start); log_debug("Previous phrase stays as is %.*s\n", (int)prev_state.phrase_len, str+prev_state.phrase_start);
char_array_cat_len(new_str, str + prev_state.phrase_start, prev_state.phrase_len); char_array_cat_len(new_str, str + prev_state.phrase_start, prev_state.phrase_len);
state = start_state;
} }
if (state.state == TRANS_STATE_BEGIN && !prev_state.empty_transition) { if (state.state == TRANS_STATE_BEGIN && !prev_state.empty_transition) {

View File

@@ -28,6 +28,8 @@ TEST test_transliterators(void) {
CHECK_CALL(test_transliteration("han-latin", "街𠀀abcdef", "jiēhēabcdef")); CHECK_CALL(test_transliteration("han-latin", "街𠀀abcdef", "jiēhēabcdef"));
CHECK_CALL(test_transliteration("katakana-latin", "ドウ", "dou")); CHECK_CALL(test_transliteration("katakana-latin", "ドウ", "dou"));
CHECK_CALL(test_transliteration("hiragana-latin", "どう", "dou")); CHECK_CALL(test_transliteration("hiragana-latin", "どう", "dou"));
CHECK_CALL(test_transliteration("latin-ascii-simple", "at&t", "at&t"));
CHECK_CALL(test_transliteration("latin-ascii-simple", "at&t", "at&t"));
PASS(); PASS();
} }