texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[6838] parsetexi update


From: Gavin D. Smith
Subject: [6838] parsetexi update
Date: Mon, 07 Dec 2015 14:13:37 +0000

Revision: 6838
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=6838
Author:   gavin
Date:     2015-12-07 14:13:35 +0000 (Mon, 07 Dec 2015)
Log Message:
-----------
parsetexi update

Modified Paths:
--------------
    trunk/parsetexi/Parsetexi/lib/Parsetexi.pm
    trunk/parsetexi/api.c
    trunk/parsetexi/convert.c
    trunk/parsetexi/end_line.c
    trunk/parsetexi/extra.c
    trunk/parsetexi/labels.c
    trunk/parsetexi/labels.h
    trunk/parsetexi/separator.c

Modified: trunk/parsetexi/Parsetexi/lib/Parsetexi.pm
===================================================================
--- trunk/parsetexi/Parsetexi/lib/Parsetexi.pm  2015-12-06 22:41:01 UTC (rev 
6837)
+++ trunk/parsetexi/Parsetexi/lib/Parsetexi.pm  2015-12-07 14:13:35 UTC (rev 
6838)
@@ -332,10 +332,10 @@
     print "Read tree.\n";
   }
 
-  print "Adjusting tree...\n";
+  #print "Adjusting tree...\n";
   _add_parents ($TREE);
   _complete_node_list ($self, $TREE);
-  print "Adjusted tree.\n";
+  #print "Adjusted tree.\n";
 
 
   # line 899

Modified: trunk/parsetexi/api.c
===================================================================
--- trunk/parsetexi/api.c       2015-12-06 22:41:01 UTC (rev 6837)
+++ trunk/parsetexi/api.c       2015-12-07 14:13:35 UTC (rev 6838)
@@ -228,6 +228,7 @@
   if (e->contents.number > 0
       || e->type == ET_text_root // FIXME special case
       || e->cmd == CM_image // why image?
+      || e->cmd == CM_anchor
       || e->cmd == CM_node) // FIXME special case
     {
       AV *av;

Modified: trunk/parsetexi/convert.c
===================================================================
--- trunk/parsetexi/convert.c   2015-12-06 22:41:01 UTC (rev 6837)
+++ trunk/parsetexi/convert.c   2015-12-07 14:13:35 UTC (rev 6838)
@@ -15,10 +15,10 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>. */
 
 #include <stdlib.h>
+#include <ctype.h>
+#include <string.h>
 
-#include "tree_types.h"
-#include "tree.h"
-#include "commands.h"
+#include "parser.h"
 #include "text.h"
 
 /* Stub for Texinfo::Convert::Text::convert */
@@ -38,7 +38,8 @@
   return "AAAAAAAAA";
 }
 
-/* IN_UC is non-zero if we are converting to upper case. */
+/* Produce normalized node name recursively.  IN_UC is non-zero if we are 
+   converting to upper case.  */
 static void
 convert_to_normalized_internal (ELEMENT *root, TEXT *result, int in_uc)
 {
@@ -49,7 +50,26 @@
 
   if (root->text.end > 0)
     {
-      text_append_n (result, root->text.text, root->text.end);
+      char *p = root->text.text, *q;
+      while (*p)
+        {
+          q = p;
+          while (isalnum (*q))
+            q++;
+          text_append_n (result, p, q - p);
+          p = q;
+          if (isspace (*p))
+            {
+              text_append (result, "-");
+              p += strspn (p, whitespace_chars);
+            }
+          else if (*p != '\0')
+            {
+              // FIXME: This is completely wrong as far as Unicode is concerned
+              text_printf (result, "_00%02x", *p);
+              p++;
+            }
+        }
     }
 
   if (root->cmd != CM_NONE) // 228 NodeNameNormalization.pm
@@ -272,6 +292,15 @@
     return "";
   text_init (&result);
   convert_to_normalized_internal (label, &result, 0);
-
-  return result.text;
+  
+  if (result.end > 0 && isdigit (result.text[0]))
+    {
+      /* prefix "g_t" if starts with a digit */
+      char *s;
+      asprintf (&s, "g_t%s", result.text);
+      free (result.text);
+      return s;
+    }
+  else
+    return result.text;
 }

Modified: trunk/parsetexi/end_line.c
===================================================================
--- trunk/parsetexi/end_line.c  2015-12-06 22:41:01 UTC (rev 6837)
+++ trunk/parsetexi/end_line.c  2015-12-07 14:13:35 UTC (rev 6838)
@@ -1155,6 +1155,8 @@
 
       /* Also set 'normalized' here.  The normalized labels are actually 
          the keys of "labels_information($parser)". */
+      //nodes_manuals[0]->normalized
+       // = convert_to_normalized (nodes_manuals[0]->node_content);
 
       /*Check that the node name doesn't have a filename element for 
         referring to an external manual (_check_internal_node), and that it 
@@ -1167,7 +1169,7 @@
       /* This sets 'node_content' and 'normalized' on the node, among
          other things (which were already set in parse_node_manual).
          Are we normalizing the name twice? */
-      register_label (current, nodes_manuals[0]->node_content);
+      register_label (current, nodes_manuals[0]);
 
       current_node = current;
     }

Modified: trunk/parsetexi/extra.c
===================================================================
--- trunk/parsetexi/extra.c     2015-12-06 22:41:01 UTC (rev 6837)
+++ trunk/parsetexi/extra.c     2015-12-07 14:13:35 UTC (rev 6838)
@@ -51,6 +51,7 @@
   e->extra[e->extra_number - 1].type = extra_element_contents;
 }
 
+/* An array of content arrays. */
 void
 add_extra_key_contents_array (ELEMENT *e, char *key, ELEMENT *value)
 {

Modified: trunk/parsetexi/labels.c
===================================================================
--- trunk/parsetexi/labels.c    2015-12-06 22:41:01 UTC (rev 6837)
+++ trunk/parsetexi/labels.c    2015-12-07 14:13:35 UTC (rev 6838)
@@ -26,11 +26,16 @@
 size_t labels_space = 0;
 
 /* Register a label, that is something that may be the target of a reference
-   and must be unique in the document.  Corresponds to @node, @anchor and 
-   @float second arg. */
-void register_label (ELEMENT *current, ELEMENT *label)
+   and must be unique in the document.  Corresponds to @node, @anchor, and 
+   second arg of @float. */
+void
+//register_label (ELEMENT *current, ELEMENT *label)
+register_label (ELEMENT *current, NODE_SPEC_EXTRA *label)
 {
-  char *normalized;
+  char *normalized = label->normalized;
+
+  // 2494 TODO: check whether previously defined
+
   if (labels_number == labels_space)
     {
       labels_space += 1;
@@ -39,11 +44,10 @@
       if (!labels_list)
         abort ();
     }
-
-  normalized = convert_to_normalized (label);
   labels_list[labels_number].label = normalized;
   labels_list[labels_number++].target = current;
 
   // 2504
   add_extra_string (current, "normalized", normalized);
+  add_extra_key_contents (current, "node_content", label->node_content);
 }

Modified: trunk/parsetexi/labels.h
===================================================================
--- trunk/parsetexi/labels.h    2015-12-06 22:41:01 UTC (rev 6837)
+++ trunk/parsetexi/labels.h    2015-12-07 14:13:35 UTC (rev 6838)
@@ -30,4 +30,4 @@
 
 extern LABEL *labels_list;
 extern size_t labels_number;
-void register_label (ELEMENT *current, ELEMENT *label);
+void register_label (ELEMENT *current, NODE_SPEC_EXTRA *label);

Modified: trunk/parsetexi/separator.c
===================================================================
--- trunk/parsetexi/separator.c 2015-12-06 22:41:01 UTC (rev 6837)
+++ trunk/parsetexi/separator.c 2015-12-07 14:13:35 UTC (rev 6838)
@@ -22,6 +22,7 @@
 #include "text.h"
 #include "errors.h"
 #include "convert.h"
+#include "input.h"
 
 // 3600
 /* Add the contents of CURRENT as an element to the extra value with
@@ -236,6 +237,13 @@
 
       if (closed_command == CM_anchor) // 5051
         {
+          NODE_SPEC_EXTRA *parsed_anchor;
+          current->parent->line_nr = line_nr;
+          parsed_anchor = parse_node_manual (current);
+          if (1) // check_node_label ()
+            {
+              register_label (current->parent, parsed_anchor);
+            }
         }
       else if (command_data(closed_command).flags & CF_ref) // 5062
         {




reply via email to

[Prev in Thread] Current Thread [Next in Thread]