[khmer] Add trailing Coeng to syllable grammar

Fixes https://github.com/harfbuzz/harfbuzz/issues/1541
diff --git a/src/hb-ot-shape-complex-khmer-machine.hh b/src/hb-ot-shape-complex-khmer-machine.hh
index 2bc8ca6..65e0ffc 100644
--- a/src/hb-ot-shape-complex-khmer-machine.hh
+++ b/src/hb-ot-shape-complex-khmer-machine.hh
@@ -35,29 +35,27 @@
 #line 36 "hb-ot-shape-complex-khmer-machine.hh"
 static const unsigned char _khmer_syllable_machine_trans_keys[] = {
 	5u, 26u, 5u, 21u, 5u, 26u, 5u, 21u, 1u, 16u, 5u, 21u, 5u, 26u, 5u, 21u, 
-	5u, 26u, 5u, 21u, 1u, 16u, 5u, 21u, 5u, 26u, 5u, 21u, 1u, 16u, 5u, 21u, 
-	5u, 26u, 5u, 21u, 5u, 26u, 5u, 21u, 5u, 26u, 1u, 16u, 1u, 29u, 5u, 29u, 
-	5u, 29u, 5u, 29u, 22u, 22u, 5u, 22u, 5u, 29u, 5u, 29u, 5u, 29u, 5u, 26u, 
-	5u, 29u, 5u, 29u, 22u, 22u, 5u, 22u, 5u, 29u, 5u, 29u, 1u, 16u, 5u, 29u, 
-	5u, 29u, 0
+	5u, 26u, 5u, 21u, 5u, 21u, 5u, 26u, 5u, 21u, 1u, 16u, 5u, 21u, 5u, 26u, 
+	5u, 21u, 5u, 26u, 5u, 21u, 5u, 26u, 1u, 29u, 5u, 29u, 5u, 29u, 5u, 29u, 
+	22u, 22u, 5u, 22u, 5u, 29u, 5u, 29u, 5u, 29u, 1u, 16u, 5u, 26u, 5u, 29u, 
+	5u, 29u, 22u, 22u, 5u, 22u, 5u, 29u, 5u, 29u, 1u, 16u, 5u, 29u, 5u, 29u, 
+	0
 };
 
 static const char _khmer_syllable_machine_key_spans[] = {
 	22, 17, 22, 17, 16, 17, 22, 17, 
-	22, 17, 16, 17, 22, 17, 16, 17, 
-	22, 17, 22, 17, 22, 16, 29, 25, 
-	25, 25, 1, 18, 25, 25, 25, 22, 
-	25, 25, 1, 18, 25, 25, 16, 25, 
-	25
+	22, 17, 17, 22, 17, 16, 17, 22, 
+	17, 22, 17, 22, 29, 25, 25, 25, 
+	1, 18, 25, 25, 25, 16, 22, 25, 
+	25, 1, 18, 25, 25, 16, 25, 25
 };
 
 static const short _khmer_syllable_machine_index_offsets[] = {
 	0, 23, 41, 64, 82, 99, 117, 140, 
-	158, 181, 199, 216, 234, 257, 275, 292, 
-	310, 333, 351, 374, 392, 415, 432, 462, 
-	488, 514, 540, 542, 561, 587, 613, 639, 
-	662, 688, 714, 716, 735, 761, 787, 804, 
-	830
+	158, 181, 199, 217, 240, 258, 275, 293, 
+	316, 334, 357, 375, 398, 428, 454, 480, 
+	506, 508, 527, 553, 579, 605, 622, 645, 
+	671, 697, 699, 718, 744, 770, 787, 813
 };
 
 static const char _khmer_syllable_machine_indicies[] = {
@@ -85,142 +83,136 @@
 	0, 0, 0, 0, 0, 0, 12, 0, 
 	0, 0, 0, 4, 0, 11, 11, 0, 
 	0, 0, 0, 0, 0, 0, 0, 0, 
-	0, 0, 0, 0, 0, 12, 0, 13, 
-	13, 0, 0, 0, 0, 0, 0, 0, 
-	0, 0, 0, 0, 0, 0, 13, 0, 
-	15, 15, 14, 14, 14, 14, 14, 14, 
-	14, 14, 14, 14, 14, 14, 14, 14, 
-	16, 14, 15, 15, 17, 17, 17, 17, 
-	17, 17, 17, 17, 17, 17, 17, 17, 
-	17, 17, 16, 17, 17, 17, 17, 18, 
-	17, 19, 19, 17, 17, 17, 17, 17, 
-	17, 17, 17, 17, 17, 17, 17, 17, 
-	17, 18, 17, 20, 20, 17, 17, 17, 
-	17, 17, 17, 17, 17, 17, 17, 17, 
-	17, 17, 20, 17, 21, 21, 17, 17, 
-	17, 17, 17, 17, 17, 17, 17, 17, 
-	17, 17, 17, 17, 22, 17, 23, 23, 
-	17, 17, 17, 17, 17, 17, 17, 17, 
-	17, 17, 17, 17, 17, 17, 24, 17, 
-	17, 17, 17, 18, 17, 23, 23, 17, 
-	17, 17, 17, 17, 17, 17, 17, 17, 
-	17, 17, 17, 17, 17, 24, 17, 25, 
-	25, 17, 17, 17, 17, 17, 17, 17, 
-	17, 17, 17, 17, 17, 17, 17, 26, 
-	17, 17, 17, 17, 18, 17, 25, 25, 
-	17, 17, 17, 17, 17, 17, 17, 17, 
-	17, 17, 17, 17, 17, 17, 26, 17, 
-	15, 15, 17, 17, 17, 17, 17, 17, 
-	17, 17, 17, 17, 17, 17, 17, 27, 
-	16, 17, 17, 17, 17, 18, 17, 28, 
-	28, 17, 17, 17, 17, 17, 17, 17, 
-	17, 17, 17, 17, 17, 17, 28, 17, 
-	13, 13, 29, 29, 30, 30, 29, 29, 
-	29, 29, 2, 2, 29, 31, 29, 13, 
-	29, 29, 29, 29, 16, 20, 29, 29, 
-	29, 18, 24, 26, 22, 29, 33, 33, 
-	32, 32, 32, 32, 32, 32, 32, 34, 
-	32, 32, 32, 32, 32, 2, 3, 6, 
-	32, 32, 32, 4, 10, 12, 8, 32, 
-	35, 35, 32, 32, 32, 32, 32, 32, 
-	32, 36, 32, 32, 32, 32, 32, 32, 
-	3, 6, 32, 32, 32, 4, 10, 12, 
-	8, 32, 5, 5, 32, 32, 32, 32, 
-	32, 32, 32, 36, 32, 32, 32, 32, 
-	32, 32, 4, 6, 32, 32, 32, 32, 
-	32, 32, 8, 32, 6, 32, 7, 7, 
-	32, 32, 32, 32, 32, 32, 32, 36, 
-	32, 32, 32, 32, 32, 32, 8, 6, 
-	32, 37, 37, 32, 32, 32, 32, 32, 
-	32, 32, 36, 32, 32, 32, 32, 32, 
-	32, 10, 6, 32, 32, 32, 4, 32, 
-	32, 8, 32, 38, 38, 32, 32, 32, 
-	32, 32, 32, 32, 36, 32, 32, 32, 
-	32, 32, 32, 12, 6, 32, 32, 32, 
-	4, 10, 32, 8, 32, 35, 35, 32, 
-	32, 32, 32, 32, 32, 32, 34, 32, 
-	32, 32, 32, 32, 32, 3, 6, 32, 
-	32, 32, 4, 10, 12, 8, 32, 15, 
-	15, 39, 39, 39, 39, 39, 39, 39, 
-	39, 39, 39, 39, 39, 39, 39, 16, 
-	39, 39, 39, 39, 18, 39, 41, 41, 
-	40, 40, 40, 40, 40, 40, 40, 42, 
-	40, 40, 40, 40, 40, 40, 16, 20, 
-	40, 40, 40, 18, 24, 26, 22, 40, 
-	19, 19, 40, 40, 40, 40, 40, 40, 
-	40, 42, 40, 40, 40, 40, 40, 40, 
-	18, 20, 40, 40, 40, 40, 40, 40, 
-	22, 40, 20, 40, 21, 21, 40, 40, 
-	40, 40, 40, 40, 40, 42, 40, 40, 
-	40, 40, 40, 40, 22, 20, 40, 43, 
-	43, 40, 40, 40, 40, 40, 40, 40, 
-	42, 40, 40, 40, 40, 40, 40, 24, 
-	20, 40, 40, 40, 18, 40, 40, 22, 
-	40, 44, 44, 40, 40, 40, 40, 40, 
-	40, 40, 42, 40, 40, 40, 40, 40, 
-	40, 26, 20, 40, 40, 40, 18, 24, 
-	40, 22, 40, 28, 28, 39, 39, 39, 
+	0, 0, 0, 0, 0, 12, 0, 14, 
+	14, 13, 13, 13, 13, 13, 13, 13, 
+	13, 13, 13, 13, 13, 13, 13, 15, 
+	13, 14, 14, 16, 16, 16, 16, 16, 
+	16, 16, 16, 16, 16, 16, 16, 16, 
+	16, 15, 16, 16, 16, 16, 17, 16, 
+	18, 18, 16, 16, 16, 16, 16, 16, 
+	16, 16, 16, 16, 16, 16, 16, 16, 
+	17, 16, 19, 19, 16, 16, 16, 16, 
+	16, 16, 16, 16, 16, 16, 16, 16, 
+	16, 19, 16, 20, 20, 16, 16, 16, 
+	16, 16, 16, 16, 16, 16, 16, 16, 
+	16, 16, 16, 21, 16, 22, 22, 16, 
+	16, 16, 16, 16, 16, 16, 16, 16, 
+	16, 16, 16, 16, 16, 23, 16, 16, 
+	16, 16, 17, 16, 22, 22, 16, 16, 
+	16, 16, 16, 16, 16, 16, 16, 16, 
+	16, 16, 16, 16, 23, 16, 24, 24, 
+	16, 16, 16, 16, 16, 16, 16, 16, 
+	16, 16, 16, 16, 16, 16, 25, 16, 
+	16, 16, 16, 17, 16, 24, 24, 16, 
+	16, 16, 16, 16, 16, 16, 16, 16, 
+	16, 16, 16, 16, 16, 25, 16, 14, 
+	14, 16, 16, 16, 16, 16, 16, 16, 
+	16, 16, 16, 16, 16, 16, 26, 15, 
+	16, 16, 16, 16, 17, 16, 28, 28, 
+	27, 27, 29, 29, 27, 27, 27, 27, 
+	2, 2, 27, 30, 27, 28, 27, 27, 
+	27, 27, 15, 19, 27, 27, 27, 17, 
+	23, 25, 21, 27, 32, 32, 31, 31, 
+	31, 31, 31, 31, 31, 33, 31, 31, 
+	31, 31, 31, 2, 3, 6, 31, 31, 
+	31, 4, 10, 12, 8, 31, 34, 34, 
+	31, 31, 31, 31, 31, 31, 31, 35, 
+	31, 31, 31, 31, 31, 31, 3, 6, 
+	31, 31, 31, 4, 10, 12, 8, 31, 
+	5, 5, 31, 31, 31, 31, 31, 31, 
+	31, 35, 31, 31, 31, 31, 31, 31, 
+	4, 6, 31, 31, 31, 31, 31, 31, 
+	8, 31, 6, 31, 7, 7, 31, 31, 
+	31, 31, 31, 31, 31, 35, 31, 31, 
+	31, 31, 31, 31, 8, 6, 31, 36, 
+	36, 31, 31, 31, 31, 31, 31, 31, 
+	35, 31, 31, 31, 31, 31, 31, 10, 
+	6, 31, 31, 31, 4, 31, 31, 8, 
+	31, 37, 37, 31, 31, 31, 31, 31, 
+	31, 31, 35, 31, 31, 31, 31, 31, 
+	31, 12, 6, 31, 31, 31, 4, 10, 
+	31, 8, 31, 34, 34, 31, 31, 31, 
+	31, 31, 31, 31, 33, 31, 31, 31, 
+	31, 31, 31, 3, 6, 31, 31, 31, 
+	4, 10, 12, 8, 31, 28, 28, 31, 
+	31, 31, 31, 31, 31, 31, 31, 31, 
+	31, 31, 31, 31, 28, 31, 14, 14, 
+	38, 38, 38, 38, 38, 38, 38, 38, 
+	38, 38, 38, 38, 38, 38, 15, 38, 
+	38, 38, 38, 17, 38, 40, 40, 39, 
+	39, 39, 39, 39, 39, 39, 41, 39, 
+	39, 39, 39, 39, 39, 15, 19, 39, 
+	39, 39, 17, 23, 25, 21, 39, 18, 
+	18, 39, 39, 39, 39, 39, 39, 39, 
+	41, 39, 39, 39, 39, 39, 39, 17, 
+	19, 39, 39, 39, 39, 39, 39, 21, 
+	39, 19, 39, 20, 20, 39, 39, 39, 
+	39, 39, 39, 39, 41, 39, 39, 39, 
+	39, 39, 39, 21, 19, 39, 42, 42, 
+	39, 39, 39, 39, 39, 39, 39, 41, 
+	39, 39, 39, 39, 39, 39, 23, 19, 
+	39, 39, 39, 17, 39, 39, 21, 39, 
+	43, 43, 39, 39, 39, 39, 39, 39, 
+	39, 41, 39, 39, 39, 39, 39, 39, 
+	25, 19, 39, 39, 39, 17, 23, 39, 
+	21, 39, 44, 44, 39, 39, 39, 39, 
 	39, 39, 39, 39, 39, 39, 39, 39, 
-	39, 39, 28, 39, 45, 45, 40, 40, 
-	40, 40, 40, 40, 40, 46, 40, 40, 
-	40, 40, 40, 27, 16, 20, 40, 40, 
-	40, 18, 24, 26, 22, 40, 41, 41, 
-	40, 40, 40, 40, 40, 40, 40, 46, 
-	40, 40, 40, 40, 40, 40, 16, 20, 
-	40, 40, 40, 18, 24, 26, 22, 40, 
-	0
+	39, 44, 39, 45, 45, 39, 39, 39, 
+	39, 39, 39, 39, 30, 39, 39, 39, 
+	39, 39, 26, 15, 19, 39, 39, 39, 
+	17, 23, 25, 21, 39, 40, 40, 39, 
+	39, 39, 39, 39, 39, 39, 30, 39, 
+	39, 39, 39, 39, 39, 15, 19, 39, 
+	39, 39, 17, 23, 25, 21, 39, 0
 };
 
 static const char _khmer_syllable_machine_trans_targs[] = {
-	22, 1, 30, 24, 25, 3, 26, 5, 
-	27, 7, 28, 9, 29, 23, 22, 11, 
-	32, 22, 33, 13, 34, 15, 35, 17, 
-	36, 19, 37, 40, 39, 22, 31, 38, 
-	22, 0, 10, 2, 4, 6, 8, 22, 
-	22, 12, 14, 16, 18, 20, 21
+	20, 1, 28, 22, 23, 3, 24, 5, 
+	25, 7, 26, 9, 27, 20, 10, 31, 
+	20, 32, 12, 33, 14, 34, 16, 35, 
+	18, 36, 39, 20, 21, 30, 37, 20, 
+	0, 29, 2, 4, 6, 8, 20, 20, 
+	11, 13, 15, 17, 38, 19
 };
 
 static const char _khmer_syllable_machine_trans_actions[] = {
 	1, 0, 2, 2, 2, 0, 0, 0, 
-	2, 0, 2, 0, 2, 2, 3, 0, 
-	4, 5, 2, 0, 0, 0, 2, 0, 
-	2, 0, 2, 4, 4, 8, 9, 0, 
-	10, 0, 0, 0, 0, 0, 0, 11, 
-	12, 0, 0, 0, 0, 0, 0
+	2, 0, 2, 0, 2, 3, 0, 4, 
+	5, 2, 0, 0, 0, 2, 0, 2, 
+	0, 2, 4, 8, 2, 9, 0, 10, 
+	0, 0, 0, 0, 0, 0, 11, 12, 
+	0, 0, 0, 0, 4, 0
 };
 
 static const char _khmer_syllable_machine_to_state_actions[] = {
 	0, 0, 0, 0, 0, 0, 0, 0, 
 	0, 0, 0, 0, 0, 0, 0, 0, 
-	0, 0, 0, 0, 0, 0, 6, 0, 
+	0, 0, 0, 0, 6, 0, 0, 0, 
 	0, 0, 0, 0, 0, 0, 0, 0, 
-	0, 0, 0, 0, 0, 0, 0, 0, 
-	0
+	0, 0, 0, 0, 0, 0, 0, 0
 };
 
 static const char _khmer_syllable_machine_from_state_actions[] = {
 	0, 0, 0, 0, 0, 0, 0, 0, 
 	0, 0, 0, 0, 0, 0, 0, 0, 
-	0, 0, 0, 0, 0, 0, 7, 0, 
+	0, 0, 0, 0, 7, 0, 0, 0, 
 	0, 0, 0, 0, 0, 0, 0, 0, 
-	0, 0, 0, 0, 0, 0, 0, 0, 
-	0
+	0, 0, 0, 0, 0, 0, 0, 0
 };
 
 static const unsigned char _khmer_syllable_machine_eof_trans[] = {
 	1, 1, 1, 1, 1, 1, 1, 1, 
-	1, 1, 1, 15, 18, 18, 18, 18, 
-	18, 18, 18, 18, 18, 18, 0, 33, 
-	33, 33, 33, 33, 33, 33, 33, 40, 
-	41, 41, 41, 41, 41, 41, 40, 41, 
-	41
+	1, 1, 14, 17, 17, 17, 17, 17, 
+	17, 17, 17, 17, 0, 32, 32, 32, 
+	32, 32, 32, 32, 32, 32, 39, 40, 
+	40, 40, 40, 40, 40, 40, 40, 40
 };
 
-static const int khmer_syllable_machine_start = 22;
-static const int khmer_syllable_machine_first_final = 22;
+static const int khmer_syllable_machine_start = 20;
+static const int khmer_syllable_machine_first_final = 20;
 static const int khmer_syllable_machine_error = -1;
 
-static const int khmer_syllable_machine_en_main = 22;
+static const int khmer_syllable_machine_en_main = 20;
 
 
 #line 36 "hb-ot-shape-complex-khmer-machine.rl"
@@ -246,7 +238,7 @@
   int cs;
   hb_glyph_info_t *info = buffer->info;
   
-#line 250 "hb-ot-shape-complex-khmer-machine.hh"
+#line 242 "hb-ot-shape-complex-khmer-machine.hh"
 	{
 	cs = khmer_syllable_machine_start;
 	ts = 0;
@@ -262,7 +254,7 @@
 
   unsigned int syllable_serial = 1;
   
-#line 266 "hb-ot-shape-complex-khmer-machine.hh"
+#line 258 "hb-ot-shape-complex-khmer-machine.hh"
 	{
 	int _slen;
 	int _trans;
@@ -276,7 +268,7 @@
 #line 1 "NONE"
 	{ts = p;}
 	break;
-#line 280 "hb-ot-shape-complex-khmer-machine.hh"
+#line 272 "hb-ot-shape-complex-khmer-machine.hh"
 	}
 
 	_keys = _khmer_syllable_machine_trans_keys + (cs<<1);
@@ -346,7 +338,7 @@
 #line 76 "hb-ot-shape-complex-khmer-machine.rl"
 	{act = 3;}
 	break;
-#line 350 "hb-ot-shape-complex-khmer-machine.hh"
+#line 342 "hb-ot-shape-complex-khmer-machine.hh"
 	}
 
 _again:
@@ -355,7 +347,7 @@
 #line 1 "NONE"
 	{ts = 0;}
 	break;
-#line 359 "hb-ot-shape-complex-khmer-machine.hh"
+#line 351 "hb-ot-shape-complex-khmer-machine.hh"
 	}
 
 	if ( ++p != pe )
diff --git a/src/hb-ot-shape-complex-khmer-machine.rl b/src/hb-ot-shape-complex-khmer-machine.rl
index 4c596ab..1076a08 100644
--- a/src/hb-ot-shape-complex-khmer-machine.rl
+++ b/src/hb-ot-shape-complex-khmer-machine.rl
@@ -66,7 +66,7 @@
 syllable_tail = xgroup matra_group xgroup (Coeng.c)? ygroup;
 
 
-broken_cluster =	(Coeng.cn)* syllable_tail;
+broken_cluster =	(Coeng.cn)* (Coeng | syllable_tail);
 consonant_syllable =	(cn|PLACEHOLDER|DOTTEDCIRCLE) broken_cluster;
 other =			any;
 
diff --git a/test/shaping/data/in-house/fonts/ad01ab2ea1cb1a4d3a2783e2675112ef11ae6404.ttf b/test/shaping/data/in-house/fonts/ad01ab2ea1cb1a4d3a2783e2675112ef11ae6404.ttf
new file mode 100644
index 0000000..8cc4bb0
--- /dev/null
+++ b/test/shaping/data/in-house/fonts/ad01ab2ea1cb1a4d3a2783e2675112ef11ae6404.ttf
Binary files differ
diff --git a/test/shaping/data/in-house/tests/khmer-misc.tests b/test/shaping/data/in-house/tests/khmer-misc.tests
index a7a1c6d..1ea7609 100644
--- a/test/shaping/data/in-house/tests/khmer-misc.tests
+++ b/test/shaping/data/in-house/tests/khmer-misc.tests
@@ -87,3 +87,4 @@
 ../fonts/3998336402905b8be8301ef7f47cf7e050cbb1bd.ttf::U+17A0,U+17D2,U+1782,U+17D2,U+179F,U+17CA,U+17C0:[uni17C1=0+288|uni17A0=0+928|uni17D21782=0@20,-26+0|uni17D2179F.low=0+302|uni17CA=0@-4,30+0|uni17C0.right1.high=0+288]
 ../fonts/3998336402905b8be8301ef7f47cf7e050cbb1bd.ttf::U+17A0,U+17D2,U+179A,U+17D2,U+179C,U+1784,U+17D2,U+1780:[uni17D2179A=0+287|uni17A0=0+928|uni17D2179C=0@20,-26+0|uni1784=5+635|uni17D21780=5@0,-26+0]
 ../fonts/3998336402905b8be8301ef7f47cf7e050cbb1bd.ttf::U+17A0,U+17D2,U+179A,U+17D2,U+179C,U+17B6,U+17C6,U+1784:[uni17D2179A=0+287|uni17A017B6=0+1216|uni17D2179C=0@-268,-26+0|uni17C6=0@47,-29+0|uni1784=7+635]
+../fonts/ad01ab2ea1cb1a4d3a2783e2675112ef11ae6404.ttf::U+17D2,U+17D2:[uni25CC=0+635|uni17D2=0+0|uni25CC=0+635|uni17D2=0+0]