diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-06-20 17:04:02 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-06-20 17:04:02 +0300 |
commit | 554d5663361e1506a757e7639524ce4d461d043c (patch) | |
tree | 95f824950975f52e5316739b6d9f7b205b309f9a | |
parent | 2bf7460851d3d03274d1b5f979b943cb00f1813e (diff) | |
download | ellinika-554d5663361e1506a757e7639524ce4d461d043c.tar.gz ellinika-554d5663361e1506a757e7639524ce4d461d043c.tar.bz2 |
libelmorph: Bugfixes.
* src/ellinika/elmorph.c (elstr->phonetic-map): Remove invalid free
* src/ellinika/syllabificator.c (NEXT_PHONEME): New macro.
(next_syllable): Now static. Uses NEXT_PHONEME to iterate over
phonemes.
-rw-r--r-- | src/ellinika/elmorph.c | 1 | ||||
-rw-r--r-- | src/ellinika/syllabificator.c | 23 |
2 files changed, 12 insertions, 12 deletions
diff --git a/src/ellinika/elmorph.c b/src/ellinika/elmorph.c index 90a156d..a06d43b 100644 --- a/src/ellinika/elmorph.c +++ b/src/ellinika/elmorph.c @@ -977,13 +977,12 @@ SCM_DEFINE_PUBLIC(scm_elstr__phonetic_map, "elstr->phonetic-map", head = tail = elt; else { SCM_SETCDR(tail, elt); tail = elt; } } - free(phmap); return head; } #undef FUNC_NAME void scm_init_ellinika_elmorph_module() diff --git a/src/ellinika/syllabificator.c b/src/ellinika/syllabificator.c index 97d3ce7..0e7b6c6 100644 --- a/src/ellinika/syllabificator.c +++ b/src/ellinika/syllabificator.c @@ -35,13 +35,19 @@ struct syllabificator { #define SYL_FLAG_MASK (CHF_ACCENT_MASK|CHF_DIPHTHONG|CHF_IOTA) #define ISIOTA(ph) \ ((ph).code == PHON_I && (ph).count == 1 && \ !((ph).flags & (CHF_ACCENT_MASK|CHF_TREMA))) -int +#define NEXT_PHONEME(sp) do { \ + (sp)->phon_cur++; \ + if ((sp)->phon_cur == (sp)->phon_max) \ + return 0; \ + } while (0) + +static int next_syllable(struct syllabificator *sp) { struct syllable *syl; if (sp->phon_cur == sp->phon_max) return 1; @@ -62,14 +68,14 @@ next_syllable(struct syllabificator *sp) syl = sp->syl + sp->syl_count++; syl->char_start = sp->phon[sp->phon_cur].start; syl->char_count = sp->phon[sp->phon_cur].count; syl->phoneme_start = sp->phon_cur; syl->phoneme_count = 1; syl->flags = sp->phon[sp->phon_cur].flags; - - sp->phon_cur++; + + NEXT_PHONEME(sp); /* A diphthong forms a single syllable. */ if ((syl->flags & CHF_DIPHTHONG) && !(syl->flags & CHF_CONSONANT)) return 0; /* If the syllable begins with a consonant, it includes all @@ -90,38 +96,33 @@ next_syllable(struct syllabificator *sp) return 0; if (ISIOTA(sp->phon[sp->phon_cur])) { /* incorporate iota */; syl->char_count += sp->phon[sp->phon_cur].count; syl->phoneme_count++; - sp->phon_cur++; - if (sp->phon_cur == sp->phon_max) - return 0; + NEXT_PHONEME(sp); if (sp->phon[sp->phon_cur].flags & CHF_VOWEL) syl->flags |= CHF_DIPHTHONG|CHF_IOTA; } if (sp->phon[sp->phon_cur].flags & CHF_VOWEL) syl->flags |= sp->phon[sp->phon_cur].flags & CHF_ACCENT_MASK; syl->char_count += sp->phon[sp->phon_cur].count; syl->phoneme_count++; - sp->phon_cur++; - - if (sp->phon_cur == sp->phon_max) - return 0; + NEXT_PHONEME(sp); if (sp->phon[sp->phon_cur - 1].flags & CHF_VOWEL) { /* If next phoneme is a consonant, incorporate it into the current syllable */ if ((sp->phon[sp->phon_cur].flags & CHF_CONSONANT) && (sp->phon_cur + 1 == sp->phon_max || (sp->phon[sp->phon_cur + 1].flags & CHF_CONSONANT))) { syl->char_count += sp->phon[sp->phon_cur].count; syl->phoneme_count++; - sp->phon_cur++; + NEXT_PHONEME(sp); } } return 0; } |