From 4be46bade26faf13f7b4d447e9cc608e183955dc Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 11 May 2012 14:39:01 +0200 Subject: [PATCH] [Indic] Fix state machine to backtrack --- src/hb-ot-shape-complex-indic-machine.rl | 42 +++++++++++++++----------------- src/hb-private.hh | 2 ++ 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/src/hb-ot-shape-complex-indic-machine.rl b/src/hb-ot-shape-complex-indic-machine.rl index c53bd78..ddecfcc 100644 --- a/src/hb-ot-shape-complex-indic-machine.rl +++ b/src/hb-ot-shape-complex-indic-machine.rl @@ -59,39 +59,35 @@ z = ZWJ|ZWNJ; matra_group = M N? H?; syllable_tail = SM? (VD VD?)?; -action found_consonant_syllable { initial_reordering_consonant_syllable (map, buffer, mask_array, last, p); } -action found_vowel_syllable { initial_reordering_vowel_syllable (map, buffer, mask_array, last, p); } -action found_standalone_cluster { initial_reordering_standalone_cluster (map, buffer, mask_array, last, p); } -action found_non_indic { initial_reordering_non_indic (map, buffer, mask_array, last, p); } - -action next_syllable { - for (unsigned int i = last; i < p; i++) - info[i].syllable() = syllable_serial; - last = p; - syllable_serial++; -} -consonant_syllable = (c.N? (H.z?|z.H))* c.N? A? (H.z? | matra_group*)? syllable_tail %(found_consonant_syllable); -vowel_syllable = (Ra H)? V N? (z?.H.c | ZWJ.c)? matra_group* syllable_tail %(found_vowel_syllable); -standalone_cluster = (Ra H)? NBSP N? (z? H c)? matra_group* syllable_tail %(found_standalone_cluster); -other = /./ %(found_non_indic); +consonant_syllable = (c.N? (H.z?|z.H))* c.N? A? (H.z? | matra_group*)? syllable_tail; +vowel_syllable = (Ra H)? V N? (z?.H.c | ZWJ.c)? matra_group* syllable_tail; +standalone_cluster = (Ra H)? NBSP N? (z? H c)? matra_group* syllable_tail; +other = any; -syllable = - consonant_syllable - | vowel_syllable - | standalone_cluster - | other - ; +main := |* + consonant_syllable => { process_syllable (consonant_syllable); }; + vowel_syllable => { process_syllable (vowel_syllable); }; + standalone_cluster => { process_syllable (standalone_cluster); }; + other => { process_syllable (non_indic); }; +*|; -main := (syllable %(next_syllable))**; }%% +#define process_syllable(func) \ + HB_STMT_START { \ + for (unsigned int i = last; i < p+1; i++) \ + info[i].syllable() = syllable_serial; \ + PASTE (initial_reordering_, func) (map, buffer, mask_array, last, p+1); \ + last = p+1; \ + syllable_serial++; \ + } HB_STMT_END static void find_syllables (const hb_ot_map_t *map, hb_buffer_t *buffer, hb_mask_t *mask_array) { - unsigned int p, pe, eof; + unsigned int p, pe, eof, ts, te, act; int cs; hb_glyph_info_t *info = buffer->info; %%{ diff --git a/src/hb-private.hh b/src/hb-private.hh index 4bedcb2..0423dd4 100644 --- a/src/hb-private.hh +++ b/src/hb-private.hh @@ -91,6 +91,8 @@ template static inline Type MAX (const Type &a, const Type &b) { #define ASSERT_STATIC_EXPR(_cond) ((void) sizeof (char[(_cond) ? 1 : -1])) #define ASSERT_STATIC_EXPR_ZERO(_cond) (0 * sizeof (char[(_cond) ? 1 : -1])) +#define _PASTE1(a,b) a##b +#define PASTE(a,b) _PASTE1(a,b) /* Lets assert int types. Saves trouble down the road. */ -- 2.7.4