Browse Source

Use snprintf on all platforms (it is C99 conformant in Visual Studio 2015 and can be supported in the compatibility layer for older versions as needed).

master
Reece H. Dunn 9 years ago
parent
commit
2a8c4461bd
2 changed files with 1 additions and 22 deletions
  1. 1
    6
      src/libespeak-ng/error.c
  2. 0
    16
      src/libespeak-ng/translate.c

+ 1
- 6
src/libespeak-ng/error.c View File

#else #else
strerror_r(status, buffer, length); strerror_r(status, buffer, length);
#endif #endif
} else {
#ifdef PLATFORM_WINDOWS
sprintf(buffer, "Unspecified error 0x%x", status);
#else
} else
snprintf(buffer, length, "Unspecified error 0x%x", status); snprintf(buffer, length, "Unspecified error 0x%x", status);
#endif
}
break; break;
} }
} }

+ 0
- 16
src/libespeak-ng/translate.c View File

ALPHABET *current_alphabet; ALPHABET *current_alphabet;


// these were previously in translator class // these were previously in translator class
#ifdef PLATFORM_WINDOWS
char word_phonemes[N_WORD_PHONEMES*2]; // longer, because snprint() is not available
#else
char word_phonemes[N_WORD_PHONEMES]; // a word translated into phoneme codes char word_phonemes[N_WORD_PHONEMES]; // a word translated into phoneme codes
#endif
int n_ph_list2; int n_ph_list2;
PHONEME_LIST2 ph_list2[N_PHONEME_LIST]; // first stage of text->phonemes PHONEME_LIST2 ph_list2[N_PHONEME_LIST]; // first stage of text->phonemes


*p = phonSTRESS_3; *p = phonSTRESS_3;
} }
} }
#ifdef PLATFORM_WINDOWS
sprintf(word_phonemes, "%s%s%s", unpron_phonemes, prefix_phonemes, phonemes);
#else
snprintf(word_phonemes, sizeof(word_phonemes), "%s%s%s", unpron_phonemes, prefix_phonemes, phonemes); snprintf(word_phonemes, sizeof(word_phonemes), "%s%s%s", unpron_phonemes, prefix_phonemes, phonemes);
#endif
word_phonemes[N_WORD_PHONEMES-1] = 0; word_phonemes[N_WORD_PHONEMES-1] = 0;
SetWordStress(tr, word_phonemes, dictionary_flags, -1, 0); SetWordStress(tr, word_phonemes, dictionary_flags, -1, 0);
} else { } else {
// stress position affects the whole word, including prefix // stress position affects the whole word, including prefix
#ifdef PLATFORM_WINDOWS
sprintf(word_phonemes, "%s%s%s", unpron_phonemes, prefix_phonemes, phonemes);
#else
snprintf(word_phonemes, sizeof(word_phonemes), "%s%s%s", unpron_phonemes, prefix_phonemes, phonemes); snprintf(word_phonemes, sizeof(word_phonemes), "%s%s%s", unpron_phonemes, prefix_phonemes, phonemes);
#endif
word_phonemes[N_WORD_PHONEMES-1] = 0; word_phonemes[N_WORD_PHONEMES-1] = 0;
SetWordStress(tr, word_phonemes, dictionary_flags, -1, 0); SetWordStress(tr, word_phonemes, dictionary_flags, -1, 0);
} }
} else { } else {
SetWordStress(tr, phonemes, dictionary_flags, -1, add_suffix_phonemes); SetWordStress(tr, phonemes, dictionary_flags, -1, add_suffix_phonemes);
#ifdef PLATFORM_WINDOWS
sprintf(word_phonemes, "%s%s%s", unpron_phonemes, prefix_phonemes, phonemes);
#else
snprintf(word_phonemes, sizeof(word_phonemes), "%s%s%s", unpron_phonemes, prefix_phonemes, phonemes); snprintf(word_phonemes, sizeof(word_phonemes), "%s%s%s", unpron_phonemes, prefix_phonemes, phonemes);
#endif
word_phonemes[N_WORD_PHONEMES-1] = 0; word_phonemes[N_WORD_PHONEMES-1] = 0;
} }



Loading…
Cancel
Save