aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2011-06-20 17:04:02 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2011-06-20 17:04:02 +0300
commit554d5663361e1506a757e7639524ce4d461d043c (patch)
tree95f824950975f52e5316739b6d9f7b205b309f9a
parent2bf7460851d3d03274d1b5f979b943cb00f1813e (diff)
downloadellinika-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.c1
-rw-r--r--src/ellinika/syllabificator.c23
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);
}
}

Return to:

Send suggestions and report system problems to the System administrator.