Browse Source

translate: Don't crash translating root words that map to another list entry.

If the list file contains a text replacement to another
entry in the list file, e.g.:

	ripost     riposte $text
	riposte    rI#p0st

calling it from a prefix or suffix rule such as 'riposted'
causes word_out[0] to be NULL, as TranslateWord3 has the
information needed to perform the mapping. In this case,
no phonemes have been written in this loop and the phonemes
have been calculated, so don't override them.
master
Reece H. Dunn 7 years ago
parent
commit
eaa08a2bc3
2 changed files with 25 additions and 3 deletions
  1. 13
    1
      src/libespeak-ng/translate.c
  2. 12
    2
      tests/translate.test

+ 13
- 1
src/libespeak-ng/translate.c View File

@@ -1207,7 +1207,19 @@ int TranslateWord(Translator *tr, char *word_start, WORD_TAB *wtab, char *word_o
while (!isspace(*word_out)) ++word_out;
while (isspace(*word_out)) ++word_out;
}
snprintf(word_phonemes, sizeof(word_phonemes), "%s", words_phonemes);

// If the list file contains a text replacement to another
// entry in the list file, e.g.:
// ripost riposte $text
// riposte rI#p0st
// calling it from a prefix or suffix rule such as 'riposted'
// causes word_out[0] to be NULL, as TranslateWord3 has the
// information needed to perform the mapping. In this case,
// no phonemes have been written in this loop and the phonemes
// have been calculated, so don't override them.
if (phonemes != words_phonemes) {
snprintf(word_phonemes, sizeof(word_phonemes), "%s", words_phonemes);
}
}
return flags;
}

+ 12
- 2
tests/translate.test View File

@@ -23,8 +23,18 @@ test_phonemes hi " r'UcI" "रुचि"
test_phonemes hi " dUk'a:n" "दुकान"
test_phonemes hi " ka:n'u:n" "कानून"

# Emoji
#----- Emoji [http://www.unicode.org/reports/tr51/tr51-12.html] -----

# ED-3 - emoji_character [http://www.unicode.org/reports/tr51/tr51-12.html#def_emoji_character]
# ED-3 - emoji_character
# TODO: Fix adjacent emoji without whitespace so the pronunciation is separated by a space.
test_phonemes en " 'e@ri:z" "♈"
test_phonemes en " 'e@ri:zr'eInboU" "♈🌈"
test_phonemes en " 'e@ri:z r'eInboU" "♈ 🌈"

# multi-word
# TODO: Add support for multi-word emoji.
test_phonemes en " Ekskla#m'eIS@N kw'EstS@n m'A@k" "⁉"
test_phonemes en " Ekskla#m'eIS@N kw'EstS@n m'A@k r'eInboU" "⁉ 🌈"
# A list entry that uses '$text' to map to another list entry crashes 1.49.2 multi-word support:
test_phonemes en " d'eIbju:tI2d" "débuted"
test_phonemes en-US " d'eIbju:t#I#d" "débuted"

Loading…
Cancel
Save