texinfo-commits
[Top][All Lists]
Advanced

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

[6337] parsetexi retrieve @documentencoding


From: Gavin D. Smith
Subject: [6337] parsetexi retrieve @documentencoding
Date: Mon, 15 Jun 2015 13:11:55 +0000

Revision: 6337
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=6337
Author:   gavin
Date:     2015-06-15 13:11:54 +0000 (Mon, 15 Jun 2015)
Log Message:
-----------
parsetexi retrieve @documentencoding

Modified Paths:
--------------
    trunk/parsetexi/ChangeLog
    trunk/parsetexi/Parsetexi/Parsetexi.xs
    trunk/parsetexi/Parsetexi/lib/Parsetexi.pm
    trunk/parsetexi/api.c
    trunk/parsetexi/api.h
    trunk/parsetexi/end_line.c
    trunk/parsetexi/parser.c
    trunk/parsetexi/parser.h

Modified: trunk/parsetexi/ChangeLog
===================================================================
--- trunk/parsetexi/ChangeLog   2015-06-15 11:18:02 UTC (rev 6336)
+++ trunk/parsetexi/ChangeLog   2015-06-15 13:11:54 UTC (rev 6337)
@@ -1,3 +1,14 @@
+2015-06-15  Gavin Smith  <address@hidden>
+
+       * Parsetexi/Parsetexi.xs,
+       * api.c (build_global_info): New function.
+       * Parsetexi/lib/Parsetexi.pm (parse_texi_file): Fetch the 
+       "global information," including the @documentencoding.
+
+       * parser.c (global_info): New struct variable.
+       * end_line.c (end_line_misc_line) <@documentencoding> Save 
+       document encoding.
+
 2015-04-10  Gavin Smith  <address@hidden>
 
        * end_line.c (end_line_starting_block): Call 

Modified: trunk/parsetexi/Parsetexi/Parsetexi.xs
===================================================================
--- trunk/parsetexi/Parsetexi/Parsetexi.xs      2015-06-15 11:18:02 UTC (rev 
6336)
+++ trunk/parsetexi/Parsetexi/Parsetexi.xs      2015-06-15 13:11:54 UTC (rev 
6337)
@@ -11,10 +11,10 @@
 #include "../errors.h"
 #include "../macro.h"
 
-
 HV *build_texinfo_tree (void);
 HV *build_label_list (void);
 HV *build_index_data (void);
+HV *build_global_info (void);
 
 MODULE = Parsetexi             PACKAGE = Parsetexi             
 
@@ -92,3 +92,6 @@
 HV *
 build_index_data ()
 
+HV *
+build_global_info ()
+

Modified: trunk/parsetexi/Parsetexi/lib/Parsetexi.pm
===================================================================
--- trunk/parsetexi/Parsetexi/lib/Parsetexi.pm  2015-06-15 11:18:02 UTC (rev 
6336)
+++ trunk/parsetexi/Parsetexi/lib/Parsetexi.pm  2015-06-15 13:11:54 UTC (rev 
6337)
@@ -254,7 +254,7 @@
 
   #print "Getting tree...\n";
 
-  my ($TREE, $LABELS, $INDEX_NAMES, $ERRORS);
+  my ($TREE, $LABELS, $INDEX_NAMES, $ERRORS, $GLOBAL_INFO);
   if (1) {
     # This is our third way of passing the data: construct it using
     # Perl api directly.
@@ -269,6 +269,10 @@
 
     $INDEX_NAMES = build_index_data ();
 
+    # Commenting out this line changes the run time of makeinfo elisp.texi
+    # from about 17.0 sec to 13.0 sec.  documentencoding is utf-8.
+    $GLOBAL_INFO = build_global_info ();
+
   } elsif (0) {
     # $| = 1; # Flush after each print
     print "Parsing file...\n";
@@ -306,10 +310,21 @@
   }
 
   print "Adjusting tree...\n";
-  _add_parents ($TREE);
+  #_add_parents ($TREE);
   _complete_node_list ($self, $TREE);
   print "Adjusted tree.\n";
 
+  $self->{'info'} = $GLOBAL_INFO;
+  print "!!! ENCODING IS ", $self->{'info'}->{'input_encoding_name'} , "\n";
+
+  if (defined($self->{'info'}->{'input_encoding_name'})) {
+    my ($texinfo_encoding, $perl_encoding, $input_encoding)
+      = Texinfo::Encoding::encoding_alias(
+            $self->{'info'}->{'input_encoding_name'});
+    $self->{'info'}->{'input_encoding_name'} = $input_encoding;
+    #print "!!! ENCODING IS ", $self->{'info'}->{'input_encoding_name'} , "\n";
+
+  }
   $self->{'info'}->{'input_file_name'} = $file_name;
 
   $self->{'labels'} = $LABELS;

Modified: trunk/parsetexi/api.c
===================================================================
--- trunk/parsetexi/api.c       2015-06-15 11:18:02 UTC (rev 6336)
+++ trunk/parsetexi/api.c       2015-06-15 13:11:54 UTC (rev 6337)
@@ -31,6 +31,7 @@
 #include "input.h"
 #include "labels.h"
 #include "indices.h"
+#include "api.h"
 
 ELEMENT *Root;
 
@@ -222,6 +223,7 @@
     {
       sv = newSVpv (e->text.text, e->text.end);
       hv_store (e->hv, "text", strlen ("text"), sv, 0);
+      SvUTF8_on (sv);
     }
 
   if (e->extra_number > 0)
@@ -610,5 +612,19 @@
   return hv;
 }
 
+
+/* Return object to be used as $self->{'info'} in the Perl code, retrievable
+   with the 'global_informations' function. */
+HV *
+build_global_info (void)
+{
+  HV *hv;
 
+  dTHX;
 
+  hv = newHV ();
+  if (global_info.input_encoding_name)
+    hv_store (hv, "input_encoding_name", strlen ("input_encoding_name"),
+              newSVpv (global_info.input_encoding_name, 0), 0);
+  return hv;
+}

Modified: trunk/parsetexi/api.h
===================================================================
--- trunk/parsetexi/api.h       2015-06-15 11:18:02 UTC (rev 6336)
+++ trunk/parsetexi/api.h       2015-06-15 13:11:54 UTC (rev 6337)
@@ -7,6 +7,8 @@
 int num_contents_children (ELEMENT *e);
 int num_args_children (ELEMENT *e);
 
+//HV *build_global_info (void);
+
 /* Defined in dump_perl.c */
 char *dump_tree_to_string_1 (void);
 char *dump_tree_to_string_2 (void);

Modified: trunk/parsetexi/end_line.c
===================================================================
--- trunk/parsetexi/end_line.c  2015-06-15 11:18:02 UTC (rev 6336)
+++ trunk/parsetexi/end_line.c  2015-06-15 13:11:54 UTC (rev 6337)
@@ -935,8 +935,7 @@
 
       if (!text || !strcmp (text, ""))
         {
-          // 3123
-          line_warnf ("@%s missing argument", command_name(cmd));
+          line_warnf ("@%s missing argument", command_name(cmd)); // 3123
         }
       else
         {
@@ -951,7 +950,6 @@
               end_id = lookup_command (end_command);
               if (end_id == 0 || !(command_data(end_id).flags & CF_block))
                 {
-                  /* error - unknown @end */
                   command_warnf ("unknown @end %s", end_command);
                   free (end_command); end_command = 0;
                 }
@@ -978,17 +976,29 @@
                     }
                 }
             }
-          else if (current->cmd == CM_include) /* 3166 */
+          else if (current->cmd == CM_include) // 3166
             {
               debug ("Include %s", text);
               input_push_file (text);
             }
-          else if (current->cmd == CM_documentencoding)
-            /* 3190 */
+          else if (current->cmd == CM_documentencoding) // 3190
             {
+              // TODO: ignore_global_commands
+              /* See tp/Texinfo/Encoding.pm (whole file) */
+              // TODO: Canonicalize encoding
+
+              /* 'us-ascii', 'utf-8', 'iso-8859-1',
+                 'iso-8859-15','iso-8859-2','koi8-r', 'koi8-u' */
+
+              add_extra_string (current, "input_encoding_name",
+                                text); // 3199
+
+              global_info.input_encoding_name = text; // 3210
+
+              // TODO: Need to convert input in input.c from this encoding.
+              // (INPUT_PERL_ENCODING in Perl version)
             }
-          else if (current->cmd == CM_documentlanguage)
-            /* 3223 */
+          else if (current->cmd == CM_documentlanguage) // 3223
             {
             }
         }

Modified: trunk/parsetexi/parser.c
===================================================================
--- trunk/parsetexi/parser.c    2015-06-15 11:18:02 UTC (rev 6336)
+++ trunk/parsetexi/parser.c    2015-06-15 13:11:54 UTC (rev 6337)
@@ -112,6 +112,11 @@
 COUNTER count_cells;
 
 
+/* Information that is not local to where it is set in the Texinfo input,
+   for example document language and encoding. */
+GLOBAL_INFO global_info;
+
+
 /* 835 */
 void
 parse_texi_file (const char *filename_in)
@@ -905,7 +910,7 @@
                   /* TODO: The Perl code has cases for the value being
                      an array or hash - check when this can happen. */
                   /* This happens when the values are set by the "gdt" 
function 
-                     in Structuring.pm.  */
+                     in Report.pm.  */
 
                   line++; /* past '}' */
                   input_push_text (strdup (line));

Modified: trunk/parsetexi/parser.h
===================================================================
--- trunk/parsetexi/parser.h    2015-06-15 11:18:02 UTC (rev 6336)
+++ trunk/parsetexi/parser.h    2015-06-15 13:11:54 UTC (rev 6337)
@@ -53,6 +53,8 @@
 extern ELEMENT *current_node;
 extern ELEMENT *current_section;
 
+extern GLOBAL_INFO global_info;
+
 #include "macro.h"
 
 /* In multitable.c */




reply via email to

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