Browse Source

Fix #1660 (#1662)

Before the PR, espeak-ng -v it "0 items" caused a segmentation fault.

- test for #1660
- Revert "cleanup: fix code smell knownConditionTrueFalse for strlen()
>= 0"
master
Juho Hiltunen 2 years ago
parent
commit
dd029a7bff
No account linked to committer's email address
2 changed files with 8 additions and 6 deletions
  1. 7
    6
      src/libespeak-ng/numbers.c
  2. 1
    0
      tests/language-numbers-cardinal.test

+ 7
- 6
src/libespeak-ng/numbers.c View File

sprintf(ph_out, "%s%s%s%s", ph_tens, ph_and, ph_digits, ph_ordinal); sprintf(ph_out, "%s%s%s%s", ph_tens, ph_and, ph_digits, ph_ordinal);
used_and = 1; used_and = 1;
} else { } else {
if ((tr->langopts.numbers & NUM_SINGLE_VOWEL) && ph_digits[0] != 0) {
if (tr->langopts.numbers & NUM_SINGLE_VOWEL) {
// remove vowel from the end of tens if units starts with a vowel (LANG=Italian) // remove vowel from the end of tens if units starts with a vowel (LANG=Italian)
ix = strlen(ph_tens) - 1;
if ((next_phtype = phoneme_tab[(unsigned int)(ph_digits[0])]->type) == phSTRESS)
next_phtype = phoneme_tab[(unsigned int)(ph_digits[1])]->type;
if (((ix = strlen(ph_tens)-1) >= 0) && (ph_digits[0] != 0)) {
if ((next_phtype = phoneme_tab[(unsigned int)(ph_digits[0])]->type) == phSTRESS)
next_phtype = phoneme_tab[(unsigned int)(ph_digits[1])]->type;


if ((phoneme_tab[(unsigned int)(ph_tens[ix])]->type == phVOWEL) && (next_phtype == phVOWEL))
ph_tens[ix] = 0;
if ((phoneme_tab[(unsigned int)(ph_tens[ix])]->type == phVOWEL) && (next_phtype == phVOWEL))
ph_tens[ix] = 0;
}
} }


if ((tr->langopts.numbers2 & NUM2_ORDINAL_DROP_VOWEL) && (ph_ordinal[0] != 0)) { if ((tr->langopts.numbers2 & NUM2_ORDINAL_DROP_VOWEL) && (ph_ordinal[0] != 0)) {

+ 1
- 0
tests/language-numbers-cardinal.test View File

test_phon lv "s'imts s'imts v'iens d'ivi s'imti d'ivi tR'i:s s'imti s'eSdesmit p'ietsi" "100 101 202 365" "hundreds" test_phon lv "s'imts s'imts v'iens d'ivi s'imti d'ivi tR'i:s s'imti s'eSdesmit p'ietsi" "100 101 202 365" "hundreds"
test_phon lv "s'imts t'u:kstuo:tis m'iljo:ns m'iljaRds tR'iljons kv'adRiljo:ns kv'intiljo:ns s'ekstiljo:ns s'eptiljo:ns 'oktiljo:ns n'oniljo:ns" "100 1000 1000000 1000000000 1000000000000 1000000000000000 1000000000000000000 1000000000000000000000 1000000000000000000000000 1000000000000000000000000000 1000000000000000000000000000000" "large" # 10^2 10^3 10^6 10^9 10^12 10^15 10^18 10^21 10^24 10^27 10^30 test_phon lv "s'imts t'u:kstuo:tis m'iljo:ns m'iljaRds tR'iljons kv'adRiljo:ns kv'intiljo:ns s'ekstiljo:ns s'eptiljo:ns 'oktiljo:ns n'oniljo:ns" "100 1000 1000000 1000000000 1000000000000 1000000000000000 1000000000000000000 1000000000000000000000 1000000000000000000000000 1000000000000000000000000000 1000000000000000000000000000000" "large" # 10^2 10^3 10^6 10^9 10^12 10^15 10^18 10^21 10^24 10^27 10^30
test_phon lv "p'ietsi s'eSdesmit tS'etRi s'imts d'ivdesmit tR'i:s tS'etRi t'u:kstuo:Si tR'i:s s'imti p'ietsd,esmit s'eptin^i tS'etRpadsmit t'u:kstuo:Si_! s'eSi s'imti_ 'astuon^desmit tR'i:s s'eptin^i s'imti tS'etRdesmit d'ivi t'u:kstuo:Si_! tR'i:s s'imti p'ietsd,esmit d'evin^i s'eSi m'iljo:ni_! tS'etRi s'imti s'eptin^desmit p'ietsi t'u:kstuo:Si_! tR'i:s s'imti d'ivdesmit 'astuon^i" "5 64 123 4357 14683 742359 6475328" "mixed" test_phon lv "p'ietsi s'eSdesmit tS'etRi s'imts d'ivdesmit tR'i:s tS'etRi t'u:kstuo:Si tR'i:s s'imti p'ietsd,esmit s'eptin^i tS'etRpadsmit t'u:kstuo:Si_! s'eSi s'imti_ 'astuon^desmit tR'i:s s'eptin^i s'imti tS'etRdesmit d'ivi t'u:kstuo:Si_! tR'i:s s'imti p'ietsd,esmit d'evin^i s'eSi m'iljo:ni_! tS'etRi s'imti s'eptin^desmit p'ietsi t'u:kstuo:Si_! tR'i:s s'imti d'ivdesmit 'astuon^i" "5 64 123 4357 14683 742359 6475328" "mixed"
test_phon it "dz'E*o_| 'items" "0 items" "NUM_SINGLE_VOWEL"

Loading…
Cancel
Save