Index: indic-ot-class-tables.c
===================================================================
RCS file: /cvs/gnome/pango/modules/indic/indic-ot-class-tables.c,v
retrieving revision 1.2
diff -u -p -r1.2 indic-ot-class-tables.c
--- indic-ot-class-tables.c	28 Aug 2002 22:27:02 -0000	1.2
+++ indic-ot-class-tables.c	15 Sep 2003 11:42:06 -0000
@@ -387,7 +387,7 @@ static const gint8 stateTable[][CC_COUNT
     {-1,  6,  1, -1, -1, -1, -1,  5,  4, -1},
     {-1,  6,  1, -1, -1, -1,  2,  5,  4, -1},
     {-1, -1, -1, -1,  3,  2, -1, -1, -1,  8},
-    {-1,  6,  1, -1, -1, -1, -1, -1, -1, -1},
+    {-1,  6,  1, -1, -1, -1, -1,  5, -1, -1},
     {-1,  7,  1, -1, -1, -1, -1, -1, -1, -1},
     {-1, -1,  1, -1, -1, -1, -1, -1, -1, -1},
     {-1, -1, -1, -1,  3,  2, -1, -1, -1, -1}
Index: indic-ot.c
===================================================================
RCS file: /cvs/gnome/pango/modules/indic/indic-ot.c,v
retrieving revision 1.5
diff -u -p -r1.5 indic-ot.c
--- indic-ot.c	27 Jul 2003 02:13:22 -0000	1.5
+++ indic-ot.c	15 Sep 2003 11:42:06 -0000
@@ -8,6 +8,16 @@
 
 #include "indic-ot.h"
 #include "mprefixups.h"
+
+struct _Matra
+{
+    gunichar fMatra;
+    gulong   fIndex;
+    gulong   fTags;
+};
+
+typedef struct _Matra Matra;
+
 /*
  * FIXME: should the IndicOutput stuff be moved
  * to a spereate .h and .c file just to keep the
@@ -24,13 +34,11 @@ struct _Output
     glong   *fCharIndices;
     gulong  *fCharTags;
 
-    gunichar fMpre;
-    gunichar fMbelow;
-    gunichar fMabove;
-    gunichar fMpost;
-    gunichar fLengthMark;
-    glong    fMatraIndex;
-    gulong   fMatraTags;
+    Matra    fMpre;
+    Matra    fMbelow;
+    Matra    fMabove;
+    Matra    fMpost;
+    Matra    fLengthMark;
     glong    fMPreOutIndex;
 
     MPreFixups *fMPreFixups;
@@ -47,38 +55,46 @@ static void initOutput(Output *output, c
     output->fCharTags    = charTags;
 
     output->fOutIndex    = 0;
-    output->fMatraTags   = 0;
 
-    output->fMpre = output->fMbelow = output->fMabove = output->fMpost = output->fLengthMark = 0;
+    output->fMpre.fMatra = output->fMbelow.fMatra = output->fMabove.fMatra = output->fMpost.fMatra = output->fLengthMark.fMatra = 0;
 
     output->fMPreOutIndex = -1;
     output->fMPreFixups = mpreFixups;
 }
 
-static void saveMatra(Output *output, gunichar matra, IndicOTCharClass matraClass)
+static void saveMatra(Output *output, gunichar matra, IndicOTCharClass matraClass, guint32 matraIndex, gulong matraTags)
 {
+    Matra *store = NULL;	/* Quiet gcc */
+    
     /* FIXME: check if already set, or if not a matra... */
     if (IS_M_PRE(matraClass)) {
-        output->fMpre = matra;
+        store = &output->fMpre;
     } else if (IS_M_BELOW(matraClass)) {
-        output->fMbelow = matra;
+        store = &output->fMbelow;
     } else if (IS_M_ABOVE(matraClass)) {
-        output->fMabove = matra;
+        store = &output->fMabove;
     } else if (IS_M_POST(matraClass)) {
-        output->fMpost = matra;
+        store = &output->fMpost;
     } else if (IS_LENGTH_MARK(matraClass)) {
-        output->fLengthMark = matra;
-    }
+        store = &output->fLengthMark;
+    } else
+      g_assert_not_reached ();
+
+    store->fMatra = matra;
+    store->fIndex = matraIndex;
+    store->fTags = matraTags;
 }
 
-static void noteMatra(Output *output, const IndicOTClassTable *classTable, gunichar matra, guint32 matraIndex, gulong matraTags)
+static void initMatra(Output *output)
 {
-    IndicOTCharClass matraClass = indic_ot_get_char_class(classTable, matra);
+  output->fMpre.fMatra = output->fMbelow.fMatra = output->fMabove.fMatra = output->fMpost.fMatra = output->fLengthMark.fMatra = 0;
 
-    output->fMpre = output->fMbelow = output->fMabove = output->fMpost = output->fLengthMark = 0;
-    output->fMPreOutIndex = -1;
-    output->fMatraIndex = matraIndex;
-    output->fMatraTags = matraTags;
+  output->fMPreOutIndex = -1;
+}
+
+static gboolean noteMatra(Output *output, const IndicOTClassTable *classTable, gunichar matra, guint32 matraIndex, gulong matraTags)
+{
+    IndicOTCharClass matraClass = indic_ot_get_char_class(classTable, matra);
 
     if (IS_MATRA(matraClass)) {
         if (IS_SPLIT_MATRA(matraClass)) {
@@ -89,12 +105,16 @@ static void noteMatra(Output *output, co
                 gunichar piece = (*splitMatra)[i];
                 IndicOTCharClass pieceClass = indic_ot_get_char_class(classTable, piece);
 
-                saveMatra(output, piece, pieceClass);
+                saveMatra(output, piece, pieceClass, matraIndex, matraTags);
             }
         } else {
-            saveMatra(output, matra, matraClass);
+            saveMatra(output, matra, matraClass, matraIndex, matraTags);
         }
+
+	return TRUE;
     }
+    else
+	return FALSE;
 }
 
 static void noteBaseConsonant(Output *output)
@@ -114,40 +134,38 @@ static void writeChar(Output *output, gu
     output->fOutIndex += 1;
 }
 
+static void writeMatra(Output *output, Matra *matra)
+{
+    if (matra->fMatra != 0)
+        writeChar(output, matra->fMatra, matra->fIndex, matra->fTags);
+}
+
 static void writeMpre(Output *output)
 {
-    if (output->fMpre != 0) {
+    if (output->fMpre.fMatra != 0) {
         output->fMPreOutIndex = output->fOutIndex;
-        writeChar(output, output->fMpre, output->fMatraIndex, output->fMatraTags);
+	writeMatra (output, &output->fMpre);
     }
 }
 
 static void writeMbelow(Output *output)
 {
-    if (output->fMbelow != 0) {
-        writeChar(output, output->fMbelow, output->fMatraIndex, output->fMatraTags);
-    }
+    writeMatra (output, &output->fMbelow);
 }
 
 static void writeMabove(Output *output)
 {
-    if (output->fMabove != 0) {
-        writeChar(output, output->fMabove, output->fMatraIndex, output->fMatraTags);
-    }
+    writeMatra (output, &output->fMabove);
 }
 
 static void writeMpost(Output *output)
 {
-    if (output->fMpost != 0) {
-        writeChar(output, output->fMpost, output->fMatraIndex, output->fMatraTags);
-    }
+    writeMatra (output, &output->fMpost);
 }
 
 static void writeLengthMark(Output *output)
 {
-    if (output->fLengthMark != 0) {
-        writeChar(output, output->fLengthMark, output->fMatraIndex, output->fMatraTags);
-    }
+    writeMatra (output, &output->fLengthMark);
 }
 
 static glong getOutputIndex(Output *output)
@@ -184,7 +202,14 @@ glong indic_ot_reorder(const gunichar *c
         }
 
         matra = vmabove - 1;
-        noteMatra(&output, class_table, chars[matra], /*matra*/ prev, blwf_p);
+	initMatra(&output);
+	while (TRUE) {
+	    if (!noteMatra(&output, class_table, chars[matra], /*matra*/ prev, blwf_p))
+		break;
+	    if (matra == prev)
+		break;
+	    matra--;
+	}
 
         switch (indic_ot_get_char_class(class_table, chars[prev]) & CF_CLASS_MASK) {
         case CC_RESERVED:
