Browse Source

code cleanup: refactor checking phoneme_mode into a function

master
Juho Hiltunen 2 years ago
parent
commit
0e07d929fd
1 changed files with 14 additions and 8 deletions
  1. 14
    8
      src/libespeak-ng/readclause.c

+ 14
- 8
src/libespeak-ng/readclause.c View File

return false; return false;
} }


static int CheckPhonemeMode(int option_phoneme_input, int phoneme_mode, int c1, int c2) {
if (option_phoneme_input) {
if (phoneme_mode > 0)
phoneme_mode--;
else if ((c1 == '[') && (c2 == '['))
phoneme_mode = -1; // input is phoneme mnemonics, so don't look for punctuation
else if ((c1 == ']') && (c2 == ']'))
phoneme_mode = 2; // set phoneme_mode to zero after the next two characters

}
return phoneme_mode;
}

int ReadClause(Translator *tr, char *buf, short *charix, int *charix_top, int n_buf, int *tone_type, char *voice_change) int ReadClause(Translator *tr, char *buf, short *charix, int *charix_top, int n_buf, int *tone_type, char *voice_change)
{ {
/* Find the end of the current clause. /* Find the end of the current clause.
} else if (iswalpha(c1)) } else if (iswalpha(c1))
tr->clause_lower_count++; tr->clause_lower_count++;


if (option_phoneme_input) {
if (phoneme_mode > 0)
phoneme_mode--;
else if ((c1 == '[') && (c2 == '['))
phoneme_mode = -1; // input is phoneme mnemonics, so don't look for punctuation
else if ((c1 == ']') && (c2 == ']'))
phoneme_mode = 2; // set phoneme_mode to zero after the next two characters
}
phoneme_mode = CheckPhonemeMode(option_phoneme_input, phoneme_mode, c1, c2);


if (c1 == '\n') { if (c1 == '\n') {
parag = 0; parag = 0;

Loading…
Cancel
Save