[liblouis-liblouisxml] [liblouisutdml] push by john.bo...@xxxxxxxxxxxxxxxxx - fixing indexing bug on 2012-05-12 19:01 GMT

  • From: liblouisutdml@xxxxxxxxxxxxxx
  • To: liblouis-liblouisxml@xxxxxxxxxxxxx
  • Date: Sat, 12 May 2012 19:01:55 +0000

Revision: bd83abe4ed50
Author:   John Boyer <john.boyer@xxxxxxxxxxxxxxxxx>
Date:     Sat May 12 12:00:07 2012
Log:      fixing indexing bug
http://code.google.com/p/liblouisutdml/source/detail?r=bd83abe4ed50

Added:
 /tests/tripleTrans.c
Modified:
 /liblouisutdml/transcriber.c

=======================================
--- /dev/null
+++ /tests/tripleTrans.c        Sat May 12 12:00:07 2012
@@ -0,0 +1,17 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "liblouisutdml.h"
+
+int
+main (int argc, char **argv)
+{
+  lbu_translateFile ("preferences.cfg", argv[1], "trans1", NULL, NULL,
+  0);
+  lbu_translateFile ("preferences.cfg", argv[1], "trans2", NULL, NULL,
+  0);
+  lbu_translateFile ("preferences.cfg", argv[1], "trans3", NULL, NULL,
+  0);
+  lbu_free ();
+  return 0;
+}
=======================================
--- /liblouisutdml/transcriber.c        Sun Apr 22 21:11:39 2012
+++ /liblouisutdml/transcriber.c        Sat May 12 12:00:07 2012
@@ -4227,7 +4227,7 @@
 static int
 assignIndices ()
 {
-  int prevSegment = 0;
+  int nextSegment = 0;
   int curPos = 0;
   xmlNode *curBrlNode;
   if (indices == NULL)
@@ -4235,16 +4235,17 @@
   if (firstBrlNode == NULL)
     return 0;
   curBrlNode = firstBrlNode;
-  while (curPos < translatedLength && curBrlNode != NULL)
+  while (curPos < translatedLength && curBrlNode != NULL  &&
+    nextSegment < translatedLength)
     {
       if (hasAttrValue (curBrlNode, "modifiers", "noindex"))
        {
          curBrlNode = curBrlNode->_private;
          continue;
        }
-      if (translatedBuffer[curPos] == ENDSEGMENT || prevSegment == 0)
-       {
-         int indexPos = prevSegment;
+      if (translatedBuffer[curPos] == ENDSEGMENT || nextSegment == 0)
+       {
+         int indexPos = nextSegment;
          int firstIndex = indices[indexPos];
          int kk = 0;
          while (translatedBuffer[indexPos] != ENDSEGMENT && indexPos <
@@ -4262,10 +4263,9 @@
                      utilStringBuf);
          if (curBrlNode && curBrlNode->_private != NULL)
            curBrlNode = curBrlNode->_private;
-         curPos += indexPos;
-       }
-      curPos++;
-      prevSegment = curPos;
+         curPos = indexPos;
+       }
+      nextSegment = curPos + 1;
     }
   return 1;
 }
@@ -4382,6 +4382,7 @@
     default:
       break;
     }
+  ud->old_text_length = ud->text_length;
   wcLength = insert_utf8 (node->content);
   ud->text_buffer[ud->text_length++] = ENDSEGMENT;
   switch (ud->stack[ud->top])
For a description of the software, to download it and links to
project pages go to http://www.abilitiessoft.com

Other related posts:

  • » [liblouis-liblouisxml] [liblouisutdml] push by john.bo...@xxxxxxxxxxxxxxxxx - fixing indexing bug on 2012-05-12 19:01 GMT - liblouisutdml