From 92eae4f322862bb3ffe9052edf46c39a8420c36c Mon Sep 17 00:00:00 2001 From: Valdis Vitolins Date: Mon, 5 Sep 2016 22:05:55 +0300 Subject: [PATCH] Updates for issue #103 Maximum group number which works is actually 62 --- src/libespeak-ng/compiledict.c | 2 ++ src/libespeak-ng/dictionary.c | 10 +++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/libespeak-ng/compiledict.c b/src/libespeak-ng/compiledict.c index 4634846e..b7055fa8 100644 --- a/src/libespeak-ng/compiledict.c +++ b/src/libespeak-ng/compiledict.c @@ -321,6 +321,8 @@ char *DecodeRule(const char *group_chars, int group_length, char *rule, int cont c = symbols_lg[*rule++ - 'A']; else if (rb == RULE_LETTERGP2) { value = *rule++ - 'A'; + if (value < 0) + value += 256; p[0] = 'L'; p[1] = (value / 10) + '0'; c = (value % 10) + '0'; diff --git a/src/libespeak-ng/dictionary.c b/src/libespeak-ng/dictionary.c index f1146fc6..330c28c7 100644 --- a/src/libespeak-ng/dictionary.c +++ b/src/libespeak-ng/dictionary.c @@ -164,7 +164,7 @@ static void InitGroups(Translator *tr) if (p[0] == RULE_LETTERGP2) { ix = p[1] - 'A'; - if (ix < 0) // Issue #103, if gets negative, fix it + if (ix < 0) ix += 256; p += 2; if ((ix >= 0) && (ix < N_LETTER_GROUPS)) @@ -1708,8 +1708,6 @@ static void MatchRule(Translator *tr, char *word[], char *word_start, int group_ { case RULE_LETTERGP: letter_group = *rule++ - 'A'; - if (letter_group < 0) // Issue #103, if gets negative, fix it - letter_group += 256; if (IsLetter(tr, letter_w, letter_group)) { lg_pts = 20; if (letter_group == 2) @@ -1721,7 +1719,7 @@ static void MatchRule(Translator *tr, char *word[], char *word_start, int group_ break; case RULE_LETTERGP2: // match against a list of utf-8 strings letter_group = *rule++ - 'A'; - if (letter_group < 0) // Issue #103, if gets negative, fix it + if (letter_group < 0) letter_group += 256; if ((n_bytes = IsLetterGroup(tr, post_ptr-1, letter_group, 0)) > 0) { add_points = (20-distance_right); @@ -1927,7 +1925,9 @@ static void MatchRule(Translator *tr, char *word[], char *word_start, int group_ failed = 1; break; case RULE_LETTERGP2: // match against a list of utf-8 strings - letter_group = *rule++ - 'A'; + letter_group = *rule++ - 'A'; // substracting 'A' makes letter_group equal to number in .Lxx definition + if(letter_group<0) + letter_group += 256; if ((n_bytes = IsLetterGroup(tr, pre_ptr, letter_group, 1)) > 0) { add_points = (20-distance_right); pre_ptr -= (n_bytes-1);