From 554d5663361e1506a757e7639524ce4d461d043c Mon Sep 17 00:00:00 2001 From: Sergey Poznyakoff Date: Mon, 20 Jun 2011 17:04:02 +0300 Subject: 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. --- src/ellinika/elmorph.c | 1 - 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 @@ -980,7 +980,6 @@ SCM_DEFINE_PUBLIC(scm_elstr__phonetic_map, "elstr->phonetic-map", tail = elt; } } - free(phmap); return head; } #undef FUNC_NAME 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 @@ -38,7 +38,13 @@ struct syllabificator { ((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; @@ -65,8 +71,8 @@ next_syllable(struct syllabificator *sp) 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)) @@ -93,9 +99,7 @@ next_syllable(struct syllabificator *sp) /* 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; } @@ -105,10 +109,7 @@ next_syllable(struct syllabificator *sp) 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 @@ -118,7 +119,7 @@ next_syllable(struct syllabificator *sp) (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); } } -- cgit v1.2.1