Skip to content

Commit

Permalink
code cleanup: use ReadNumbers() for language options "dictrules", "st…
Browse files Browse the repository at this point in the history
…ressopt"

language option "numbers" could be changed to use the same function, but
it needs tests.
  • Loading branch information
jaacoppi committed Jul 27, 2021
1 parent fdc1afd commit a6abb1e
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions src/libespeak-ng/voices.c
Expand Up @@ -528,7 +528,6 @@ voice_t *LoadVoice(const char *vname, int control)
int tone_only = control & 2;
bool language_set = false;
bool phonemes_set = false;
int conditional_rules = 0;

char voicename[40];
char language_name[40];
Expand Down Expand Up @@ -766,9 +765,21 @@ voice_t *LoadVoice(const char *vname, int control)
translator->langopts.tunes[ix] = value;
}
break;

case V_DICTRULES: // conditional dictionary rules and list entries
case V_NUMBERS:
if (CheckTranslator(translator, keyword_tab, key) != 0)
break;

ReadNumbers(p, &translator->dict_condition, 32, keyword_tab, key);
break;
case V_STRESSOPT:
if (CheckTranslator(translator, keyword_tab, key) != 0)
break;

ReadNumbers(p, &translator->langopts.stress_flags, 32, keyword_tab, key);
break;

case V_NUMBERS:
if (CheckTranslator(translator, keyword_tab, key) != 0)
break;

Expand All @@ -778,18 +789,12 @@ voice_t *LoadVoice(const char *vname, int control)
if ((n = atoi(p)) > 0) {
p++;
if (n < 32) {
if (key == V_DICTRULES)
conditional_rules |= (1 << n);
else if (key == V_NUMBERS)
translator->langopts.numbers |= (1 << n);
else if (key == V_STRESSOPT)
translator->langopts.stress_flags |= (1 << n);
} else {
if ((key == V_NUMBERS) && (n < 64))
if (n < 64)
translator->langopts.numbers2 |= (1 << (n-32));
else
fprintf(stderr, "Bad option number %d\n", n);
}
fprintf(stderr, "numbers: Bad option number %d\n", n); }
}
while (isalnum(*p)) p++;
}
Expand Down Expand Up @@ -949,8 +954,6 @@ voice_t *LoadVoice(const char *vname, int control)
}
}

translator->dict_condition = conditional_rules;

voice_languages[langix] = 0;
}

Expand Down

0 comments on commit a6abb1e

Please sign in to comment.