From 50a2d8e291803e1d466b6fa713884863e3ecba73 Mon Sep 17 00:00:00 2001 From: "Reece H. Dunn" Date: Sat, 4 Nov 2017 08:14:59 +0000 Subject: [PATCH] Revert "Use strcpy instead of memcpy+strlen." This reverts commit 119c200e00a46248bbaa149e8d0c3b1f19f86135. --- .gitignore | 1 - Makefile.am | 1 - src/libespeak-ng/dictionary.c | 4 ++-- src/libespeak-ng/translate.c | 12 ++++++------ tests/phoneme-output.test | 21 --------------------- 5 files changed, 8 insertions(+), 31 deletions(-) delete mode 100755 tests/phoneme-output.test diff --git a/.gitignore b/.gitignore index 36d797e3..ab5fcdf8 100644 --- a/.gitignore +++ b/.gitignore @@ -98,7 +98,6 @@ src/speak-ng tests/*.test !tests/languages.test -!tests/phoneme-output.test espeak-ng.pc diff --git a/Makefile.am b/Makefile.am index 427083de..0ae0c326 100644 --- a/Makefile.am +++ b/Makefile.am @@ -250,7 +250,6 @@ tests_api_test_SOURCES = tests/api.c check: tests/encoding.check \ tests/readclause.check \ tests/api.check \ - tests/phoneme-output.check \ tests/languages.check ##### phoneme data: diff --git a/src/libespeak-ng/dictionary.c b/src/libespeak-ng/dictionary.c index 5a504fb7..1b43acea 100644 --- a/src/libespeak-ng/dictionary.c +++ b/src/libespeak-ng/dictionary.c @@ -2392,7 +2392,7 @@ int TranslateRules(Translator *tr, char *p_start, char *phonemes, int ph_size, c match1.end_type |= p - p_start; } strcpy(end_phonemes, match1.phonemes); - strcpy(p_start, word_copy); + memcpy(p_start, word_copy, strlen(word_copy)); return match1.end_type; } } @@ -2402,7 +2402,7 @@ int TranslateRules(Translator *tr, char *p_start, char *phonemes, int ph_size, c } } - strcpy(p_start, word_copy); + memcpy(p_start, word_copy, strlen(word_copy)); return 0; } diff --git a/src/libespeak-ng/translate.c b/src/libespeak-ng/translate.c index 62610133..14bbf3ec 100644 --- a/src/libespeak-ng/translate.c +++ b/src/libespeak-ng/translate.c @@ -827,7 +827,7 @@ static int TranslateWord3(Translator *tr, char *word_start, WORD_TAB *wtab, char if (end2) { RemoveEnding(tr, wordx, end2, word_copy); end_type = TranslateRules(tr, wordx, phonemes, N_WORD_PHONEMES, end_phonemes, wflags|FLAG_NO_TRACE, dictionary_flags); - strcpy(wordx, word_copy); + memcpy(wordx, word_copy, strlen(word_copy)); if ((end_type & SUFX_P) == 0) { // after removing the suffix, the prefix is no longer recognised. // Keep the suffix, but don't use the prefix @@ -934,7 +934,7 @@ static int TranslateWord3(Translator *tr, char *word_start, WORD_TAB *wtab, char wordx[-1] = ' '; if (phonemes[0] == phonSWITCH) { // change to another language in order to translate this word - strcpy(wordx, word_copy); + memcpy(wordx, word_copy, strlen(word_copy)); strcpy(word_phonemes, phonemes); return 0; } @@ -952,7 +952,7 @@ static int TranslateWord3(Translator *tr, char *word_start, WORD_TAB *wtab, char found = LookupDictList(tr, &wordx, phonemes, dictionary_flags2, end_flags, wtab); // without prefix and suffix if (phonemes[0] == phonSWITCH) { // change to another language in order to translate this word - strcpy(wordx, word_copy); + memcpy(wordx, word_copy, strlen(word_copy)); strcpy(word_phonemes, phonemes); return 0; } @@ -992,7 +992,7 @@ static int TranslateWord3(Translator *tr, char *word_start, WORD_TAB *wtab, char if (phonemes[0] == phonSWITCH) { // change to another language in order to translate this word strcpy(word_phonemes, phonemes); - strcpy(wordx, word_copy); + memcpy(wordx, word_copy, strlen(word_copy)); wordx[-1] = c_temp; return 0; } @@ -1006,7 +1006,7 @@ static int TranslateWord3(Translator *tr, char *word_start, WORD_TAB *wtab, char AppendPhonemes(tr, phonemes, N_WORD_PHONEMES, end_phonemes); end_phonemes[0] = 0; } - strcpy(wordx, word_copy); + memcpy(wordx, word_copy, strlen(word_copy)); } wordx[-1] = c_temp; @@ -1171,7 +1171,7 @@ int TranslateWord(Translator *tr, char *word_start, WORD_TAB *wtab, char *word_o char word[N_WORD_BYTES+1]; word[0] = 0; word[1] = ' '; - strcpy(word+2, word_out); + memcpy(word+2, word_out, strlen(word_out)); word_out = word+2; while (*word_out && available > 1) { diff --git a/tests/phoneme-output.test b/tests/phoneme-output.test deleted file mode 100755 index 1468bec3..00000000 --- a/tests/phoneme-output.test +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh - -test_phonemes() { - TEST_LANG=$1 - EXPECTED=$2 - TEST_TEXT=$3 - - echo "testing ${TEST_LANG} \"${TEST_TEXT}\"" - ESPEAK_DATA_PATH=`pwd` LD_LIBRARY_PATH=src:${LD_LIBRARY_PATH} \ - src/espeak-ng -xq -v ${TEST_LANG} "${TEST_TEXT}" > actual.txt - echo "${EXPECTED}" > expected.txt - diff expected.txt actual.txt || exit 1 -} - -test_phonemes en " h@l'oU" "hello" - -# Emoji - -# ED-3 - emoji_character [http://www.unicode.org/reports/tr51/tr51-12.html#def_emoji_character] -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" "⁉ 🌈"