[liblouis-liblouisxml] [liblouisutdml] push by john.bo...@xxxxxxxxxxxxxxxxx - Better handling of semantic stack and non-leaf nodes on 2013-08-24 18:58 GMT

  • From: liblouisutdml@xxxxxxxxxxxxxx
  • To: liblouis-liblouisxml@xxxxxxxxxxxxx
  • Date: Sat, 24 Aug 2013 18:58:39 +0000

Revision: 218c6dbd498f
Branch:   default
Author:   John Boyer <john.boyer@xxxxxxxxxxxxxxxxx>
Date:     Sat Aug 24 18:57:54 2013 UTC
Log:      Better handling of semantic stack and non-leaf nodes
http://code.google.com/p/liblouisutdml/source/detail?r=218c6dbd498f

Modified:
 /liblouisutdml/semantics.c
 /liblouisutdml/transcribe_paragraph.c

=======================================
--- /liblouisutdml/semantics.c  Thu Aug  8 13:33:02 2013 UTC
+++ /liblouisutdml/semantics.c  Sat Aug 24 18:57:54 2013 UTC
@@ -1294,20 +1294,34 @@
   attrName[k] = 0;
   return xmlGetProp (node, attrName);
 }
+
+void
+shortenStack ()
+{
+  int k;
+  int kk = 0;
+  for (k = ud->top / 2; k <= ud->top; k++)
+    ud->stack[kk++] = ud->stack[k];
+  ud->top = kk - 1;
+}

 sem_act
 push_sem_stack (xmlNode * node)
 {
-  if (ud->top > (STACKSIZE - 2) || ud->top < -1)
-    ud->top = 1;
+  if (ud->top < -1)
+    ud->top = -1;
+  if (ud->top > (STACKSIZE - 3))
+    shortenStack ();
   return (ud->stack[++ud->top] = get_sem_attr (node));
 }

 sem_act
 push_action (sem_act action)
 {
-  if (ud->top > (STACKSIZE - 2) || ud->top < -1)
-    ud->top = 1;
+  if (ud->top < -1)
+    ud->top = -1;
+  if (ud->top > (STACKSIZE - 3))
+    shortenStack ();
   return (ud->stack[++ud->top] = action);
 }

@@ -1316,8 +1330,8 @@
 {
   if (ud->top < 0)
     {
-      ud->top = 1;
-      ud->stack[ud->top] = no;
+      ud->top = -1;
+      ud->stack[++ud->top] = no;
       return no;
     }
   ud->top--;
@@ -1325,7 +1339,6 @@
     return ud->stack[ud->top];
   return no;
 }
-

 static void
 addNewEntries (const xmlChar * newEntry)
=======================================
--- /liblouisutdml/transcribe_paragraph.c       Fri Aug 23 03:17:35 2013 UTC
+++ /liblouisutdml/transcribe_paragraph.c       Sat Aug 24 18:57:54 2013 UTC
@@ -202,7 +202,7 @@
     case skip:
       if (action != 0)
        pop_sem_stack ();
-      return 0;
+      return 1;
     case markhead:
       ud->head_node = node;
       pop_sem_stack ();
@@ -215,9 +215,9 @@
          lou_logPrint ("Cannot open main table %s", ud->main_braille_table);
          return 0;
        }
-      if (action != 0)
-       pop_sem_stack ();
+    if (node->children == NULL)
       return 1;
+    break;
     case htmllink:
       if (ud->format_for != browser)
        break;
@@ -234,49 +234,39 @@
       return 1;
     case boxline:
       do_boxline (node);
-      if (action != 0)
-       pop_sem_stack ();
     if (node->children == NULL)
       return 1;
     break;
     case pagebreak:
       do_pagebreak (node);
-      if (action != 0)
-       pop_sem_stack ();
       return 1;
     case attrtotext:
       do_attrtotext (node);
-      if (action != 0)
-       pop_sem_stack ();
+    if (node->children == NULL)
       return 1;
+    break;
     case blankline:
       do_blankline ();
-      if (action != 0)
-       pop_sem_stack ();
+    if (node->children == NULL)
       return 1;
+    break;
     case linespacing:
       do_linespacing (node);
-      if (action != 0)
-       pop_sem_stack ();
+    if (node->children == NULL)
       return 1;
+    break;
     case softreturn:
       do_softreturn ();
-      if (action != 0)
-       pop_sem_stack ();
     if (node->children == NULL)
       return 1;
     break;
     case newpage:
       do_newpage ();
-      if (action != 0)
-       pop_sem_stack ();
     if (node->children == NULL)
       return 1;
     break;
     case righthandpage:
       do_righthandpage ();
-      if (action != 0)
-       pop_sem_stack ();
     if (node->children == NULL)
       return 1;
     break;
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 - Better handling of semantic stack and non-leaf nodes on 2013-08-24 18:58 GMT - liblouisutdml