mirror of
https://github.com/rhasspy/espeak-ng.git
synced 2026-11-13 01:07:47 +00:00
dictionary: Fix failure to look back
Firstly, a ~ match is supposed to match even if there's nothing left. Also, when p doesn't match, we should not return immediately, but skip to the next group. Fixes #1507
This commit is contained in:
@@ -695,6 +695,10 @@ static int IsLetterGroup(Translator *tr, char *word, int group, int pre)
|
||||
return -1;
|
||||
|
||||
while (*p != RULE_GROUP_END) {
|
||||
// If '~' (no character) is allowed in group, return 0.
|
||||
if (*p == '~')
|
||||
return 0;
|
||||
|
||||
if (pre) {
|
||||
len = strlen(p);
|
||||
w = word;
|
||||
@@ -702,16 +706,12 @@ static int IsLetterGroup(Translator *tr, char *word, int group, int pre)
|
||||
{
|
||||
w--;
|
||||
if (*w == 0)
|
||||
// Not found
|
||||
return -1;
|
||||
// Not found, skip the rest of this group.
|
||||
goto skip;
|
||||
}
|
||||
} else
|
||||
w = word;
|
||||
|
||||
// If '~' (no character) is allowed in group, return 0.
|
||||
if (*p == '~')
|
||||
return 0;
|
||||
|
||||
// Check current group
|
||||
while ((*p == *w) && (*w != 0)) {
|
||||
w++;
|
||||
@@ -724,6 +724,7 @@ static int IsLetterGroup(Translator *tr, char *word, int group, int pre)
|
||||
}
|
||||
|
||||
// No match, so skip the rest of this group.
|
||||
skip:
|
||||
while (*p++ != 0)
|
||||
;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user