Browse Source

cleanup: reduce variable scopes in readclause.c

Contributes to #9.
master
Juho Hiltunen 2 years ago
parent
commit
185c93e702
1 changed files with 8 additions and 9 deletions
  1. 8
    9
      src/libespeak-ng/readclause.c

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

{ {
unsigned int flags[2]; unsigned int flags[2];
char phonemes[55]; char phonemes[55];
char phonemes2[55];
char *string1 = (char *)string; char *string1 = (char *)string;


flags[0] = flags[1] = 0; flags[0] = flags[1] = 0;
if (LookupDictList(tr, &string1, phonemes, flags, 0, NULL)) { if (LookupDictList(tr, &string1, phonemes, flags, 0, NULL)) {
char phonemes2[55];
SetWordStress(tr, phonemes, flags, -1, 0); SetWordStress(tr, phonemes, flags, -1, 0);
DecodePhonemes(phonemes, phonemes2); DecodePhonemes(phonemes, phonemes2);
sprintf(text_out, "[\002%s]]", phonemes2); sprintf(text_out, "[\002%s]]", phonemes2);
unsigned int flags[2]; unsigned int flags[2];
char single_letter[24]; char single_letter[24];
char phonemes[60]; char phonemes[60];
char phonemes2[60];
const char *lang_name = NULL; const char *lang_name = NULL;
char *string; char *string;
static char buf[60]; static char buf[60];
} }


if (phonemes[0]) { if (phonemes[0]) {
char phonemes2[60];
if (lang_name) { if (lang_name) {
SetWordStress(translator2, phonemes, flags, -1, 0); SetWordStress(translator2, phonemes, flags, -1, 0);
DecodePhonemes(phonemes, phonemes2); DecodePhonemes(phonemes, phonemes2);
// c1: the punctuation character // c1: the punctuation character
// c2: the following character // c2: the following character


int punct_count;
const char *punctname = NULL; const char *punctname = NULL;
int soundicon; int soundicon;
int attributes; int attributes;
int len; int len;
int bufix1; int bufix1;
char buf[200]; char buf[200];
char buf2[80];
char ph_buf[30]; char ph_buf[30];


c2 = *c2_ptr; c2 = *c2_ptr;
if (punctname == NULL) if (punctname == NULL)
return -1; return -1;



if ((*bufix == 0) || (end_clause == 0) || (tr->langopts.param[LOPT_ANNOUNCE_PUNCT] & 2)) { if ((*bufix == 0) || (end_clause == 0) || (tr->langopts.param[LOPT_ANNOUNCE_PUNCT] & 2)) {
punct_count = 1;
int punct_count = 1;
while (!Eof() && (c2 == c1) && (c1 != '<')) { // don't eat extra '<', it can miss XML tags while (!Eof() && (c2 == c1) && (c1 != '<')) { // don't eat extra '<', it can miss XML tags
punct_count++; punct_count++;
c2 = GetC(); c2 = GetC();
if (embedded_value[EMBED_S] < 300) if (embedded_value[EMBED_S] < 300)
sprintf(buf, "\001+10S"); // Speak punctuation name faster, unless we are already speaking fast. It would upset Sonic SpeedUp sprintf(buf, "\001+10S"); // Speak punctuation name faster, unless we are already speaking fast. It would upset Sonic SpeedUp


char buf2[80];
while (punct_count-- > 0) { while (punct_count-- > 0) {
sprintf(buf2, " %s", punctname); sprintf(buf2, " %s", punctname);
strcat(buf, buf2); strcat(buf, buf2);


int ix; int ix;
int len; int len;
void *vp;


if (wide) { if (wide) {
len = (wcslen((const wchar_t *)name)+1)*sizeof(wchar_t); len = (wcslen((const wchar_t *)name)+1)*sizeof(wchar_t);


if (namedata_ix+len >= n_namedata) { if (namedata_ix+len >= n_namedata) {
// allocate more space for marker names // allocate more space for marker names
void *vp;
if ((vp = realloc(namedata, namedata_ix+len + 1000)) == NULL) if ((vp = realloc(namedata, namedata_ix+len + 1000)) == NULL)
return -1; // failed to allocate, original data is unchanged but ignore this new name return -1; // failed to allocate, original data is unchanged but ignore this new name
// !!! Bug?? If the allocated data shifts position, then pointers given to user application will be invalid // !!! Bug?? If the allocated data shifts position, then pointers given to user application will be invalid
int c1 = ' '; // current character int c1 = ' '; // current character
int c2; // next character int c2; // next character
int cprev = ' '; // previous character int cprev = ' '; // previous character
int cprev2 = ' ';
int c_next; int c_next;
int parag; int parag;
int ix = 0; int ix = 0;
return CLAUSE_NONE; return CLAUSE_NONE;
} }
} }

cprev2 = cprev;
int cprev2 = cprev;
cprev = c1; cprev = c1;
c1 = c2; c1 = c2;



Loading…
Cancel
Save