texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/Texinfo/XS/main/convert_to_text.c (copy_opti


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/XS/main/convert_to_text.c (copy_options_for_convert_text) (brace_no_arg_command, convert_to_text_internal), tp/Texinfo/XS/main/convert_to_text.h (TEXT_OPTIONS): add converter to text options, use it for untranslated text, translated commands without arguments, verbatiminclude errors. Use options for definition_category_tree.
Date: Wed, 13 Dec 2023 11:40:54 -0500

This is an automated email from the git hooks/post-receive script.

pertusus pushed a commit to branch master
in repository texinfo.

The following commit(s) were added to refs/heads/master by this push:
     new 8ecfaf6e4f * tp/Texinfo/XS/main/convert_to_text.c 
(copy_options_for_convert_text) (brace_no_arg_command, 
convert_to_text_internal), tp/Texinfo/XS/main/convert_to_text.h (TEXT_OPTIONS): 
add converter to text options, use it for untranslated text, translated 
commands without arguments, verbatiminclude errors.  Use options for 
definition_category_tree.
8ecfaf6e4f is described below

commit 8ecfaf6e4f41fb06329ec8818c26426c02d66f38
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Wed Dec 13 17:40:48 2023 +0100

    * tp/Texinfo/XS/main/convert_to_text.c (copy_options_for_convert_text)
    (brace_no_arg_command, convert_to_text_internal),
    tp/Texinfo/XS/main/convert_to_text.h (TEXT_OPTIONS): add converter to
    text options, use it for untranslated text, translated commands
    without arguments, verbatiminclude errors.  Use options for
    definition_category_tree.
    
    * tp/Texinfo/XS/convert/ConvertXS.xs
    (html_prepare_converted_output_info),
    tp/Texinfo/XS/main/get_perl_info.c (recopy_converter_conf_sv)
    (set_output_converter_sv): add recopy_converter_conf_sv to reset a
    converter value based on perl converter, use in
    html_prepare_converted_output_info and set_output_converter_sv.
    
    * tp/Texinfo/Convert/HTML.pm (%XS_conversion_overrides): use
    _prepare_converted_output_info override.
---
 ChangeLog                            | 19 ++++++++++++
 tp/Texinfo/Convert/HTML.pm           |  4 +--
 tp/Texinfo/XS/convert/ConvertXS.xs   |  5 +++-
 tp/Texinfo/XS/main/convert_to_text.c | 57 +++++++++++++++++++++---------------
 tp/Texinfo/XS/main/convert_to_text.h |  4 ++-
 tp/Texinfo/XS/main/get_perl_info.c   | 50 +++++++++++++++----------------
 tp/Texinfo/XS/main/get_perl_info.h   |  2 ++
 7 files changed, 87 insertions(+), 54 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 09cf25d536..93880917bd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2023-12-13  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/main/convert_to_text.c (copy_options_for_convert_text)
+       (brace_no_arg_command, convert_to_text_internal),
+       tp/Texinfo/XS/main/convert_to_text.h (TEXT_OPTIONS): add converter to
+       text options, use it for untranslated text, translated commands
+       without arguments, verbatiminclude errors.  Use options for
+       definition_category_tree.
+
+       * tp/Texinfo/XS/convert/ConvertXS.xs
+       (html_prepare_converted_output_info),
+       tp/Texinfo/XS/main/get_perl_info.c (recopy_converter_conf_sv)
+       (set_output_converter_sv): add recopy_converter_conf_sv to reset a
+       converter value based on perl converter, use in
+       html_prepare_converted_output_info and set_output_converter_sv.
+
+       * tp/Texinfo/Convert/HTML.pm (%XS_conversion_overrides): use
+       _prepare_converted_output_info override.
+
 2023-12-13  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/Document.pm (%XS_overrides, _XS_set_document_global_info)
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 8fc16cf4c2..b0874ebdd3 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -120,8 +120,8 @@ my %XS_conversion_overrides = (
    => "Texinfo::Convert::ConvertXS::html_finalize_output_state",
   "Texinfo::Convert::HTML::_prepare_simpletitle"
    => "Texinfo::Convert::ConvertXS::html_prepare_simpletitle",
-#  "Texinfo::Convert::HTML::_prepare_converted_output_info"
-#   => "Texinfo::Convert::ConvertXS::html_prepare_converted_output_info",
+  "Texinfo::Convert::HTML::_prepare_converted_output_info"
+   => "Texinfo::Convert::ConvertXS::html_prepare_converted_output_info",
 
   "Texinfo::Convert::HTML::_register_id"
    => "Texinfo::Convert::ConvertXS::html_register_id",
diff --git a/tp/Texinfo/XS/convert/ConvertXS.xs 
b/tp/Texinfo/XS/convert/ConvertXS.xs
index c5695cf1c3..75adb951dd 100644
--- a/tp/Texinfo/XS/convert/ConvertXS.xs
+++ b/tp/Texinfo/XS/convert/ConvertXS.xs
@@ -1253,11 +1253,14 @@ html_prepare_converted_output_info (SV *converter_in)
   PREINIT:
          CONVERTER *self = 0;
     CODE:
-         self = get_sv_converter (converter_in, 
"html_prepare_title_titlepage");
+         self = get_sv_converter (converter_in,
+                                  "html_prepare_converted_output_info");
          if (self)
            {
              HV *converter_hv = (HV *) SvRV (converter_in);
 
+             recopy_converter_conf_sv (converter_hv, self, &self->conf, 
"conf");
+
              html_prepare_converted_output_info (self);
              if (self->added_title_tree)
                build_texinfo_tree (self->title_tree, 1);
diff --git a/tp/Texinfo/XS/main/convert_to_text.c 
b/tp/Texinfo/XS/main/convert_to_text.c
index 6ac1c281af..2becdc2304 100644
--- a/tp/Texinfo/XS/main/convert_to_text.c
+++ b/tp/Texinfo/XS/main/convert_to_text.c
@@ -37,6 +37,7 @@
 #include "document.h"
 #include "convert_to_texinfo.h"
 #include "debug.h"
+#include "translations.h"
 #include "convert_to_text.h"
 
 #include "cmd_symbol.c"
@@ -169,6 +170,7 @@ copy_options_for_convert_text (CONVERTER *self,
           sizeof (STRING_LIST));
 
   options->other_converter_options = self->conf;
+  options->converter = self;
 
   return options;
 }
@@ -234,16 +236,12 @@ brace_no_arg_command (const ELEMENT *e, TEXT_OPTIONS 
*options)
         result = strdup (brace_no_arg_unicode);
     }
 
-  /* TODO to do when it is possible to test
-  if (!defined($result) and $options and $options->{'converter'}) {
-    my $tree
-     = 
Texinfo::Convert::Utils::translated_command_tree($options->{'converter'},
-                                                        $command);
-    if ($tree) {
-      $result = _convert($tree, $options);
+  if (!result && options->converter)
+    {
+      ELEMENT *tree = translated_command_tree (options->converter, cmd);
+      if (tree)
+        result = convert_to_text (tree, options);
     }
-  }
-  */
   if (!result)
     {
       if (options->sort_string
@@ -424,19 +422,27 @@ convert_to_text_internal (const ELEMENT *element, 
TEXT_OPTIONS *text_options,
   /* or element->text.space? */
   if (element->text.end > 0)
     {
+      if (element->type == ET_untranslated && text_options->converter)
+        {
 /*
-    if ($element->{'type'} and $element->{'type'} eq 'untranslated'
-        and $options and $options->{'converter'}) {
-      # the tree documentlanguage corresponds to the documentlanguage
-      # at the place of the tree, but the converter may want to use
-      # another documentlanguage, for instance the documentlanguage at
-      # the end of the preamble, so we let the converter set it.
-      #my $tree = $options->{'converter'}->gdt($element->{'text'}, undef,
-      #                  undef, $element->{'extra'}->{'documentlanguage'});
-      my $tree = $options->{'converter'}->gdt($element->{'text'});
-      $result = _convert($tree, $options);
-    } else
+       the tree documentlanguage corresponds to the documentlanguage
+       at the place of the tree, but the converter may want to use
+       another documentlanguage, for instance the documentlanguage at
+       the end of the preamble, so we let the converter set it.
+          documentlanguage = lookup_extra_string (element, "documentlanguage");
 */
+          char *translation_context
+            = lookup_extra_string (element, "translation_context");
+          ELEMENT *tree = gdt_tree (element->text.text,
+                                    text_options->converter->document,
+                                    text_options->converter->conf, 0,
+                                    translation_context, 0);
+          if (tree)
+            {
+              convert_to_text_internal (tree, text_options, result);
+            }
+        }
+      else
         {
           char *p;
           if (element->type == ET_raw
@@ -791,11 +797,14 @@ convert_to_text_internal (const ELEMENT *element, 
TEXT_OPTIONS *text_options,
       else if (element->cmd == CM_verbatiminclude)
         {
           ELEMENT *verbatim_include_verbatim = 0;
+          ERROR_MESSAGE_LIST *error_messages = 0;
+          if (text_options->converter)
+            error_messages = &text_options->converter->error_messages;
+
           if (text_options->other_converter_options) {
-            /* TODO retrieve other converter document information
-               and error messages */
             verbatim_include_verbatim
-             = expand_verbatiminclude (0, 
text_options->other_converter_options,
+             = expand_verbatiminclude (error_messages,
+                                       text_options->other_converter_options,
                                        0, element);
           } else {
             GLOBAL_INFO *global_information = 0;
@@ -835,7 +844,7 @@ convert_to_text_internal (const ELEMENT *element, 
TEXT_OPTIONS *text_options,
     {
       PARSED_DEF *parsed_def = definition_arguments_content (element);
       ELEMENT *parsed_definition_category
-         = definition_category_tree (0, /* $options->{'converter'} */
+         = definition_category_tree (text_options->other_converter_options,
                                      element);
       if (parsed_definition_category)
         {
diff --git a/tp/Texinfo/XS/main/convert_to_text.h 
b/tp/Texinfo/XS/main/convert_to_text.h
index 6d2ce74bf6..f3c12dcee9 100644
--- a/tp/Texinfo/XS/main/convert_to_text.h
+++ b/tp/Texinfo/XS/main/convert_to_text.h
@@ -18,8 +18,10 @@ typedef struct TEXT_OPTIONS {
     int NUMBER_SECTIONS;
     EXPANDED_FORMAT *expanded_formats;
     STRING_LIST include_directories;
+    CONVERTER *converter;
     OPTIONS *other_converter_options; /* corresponds to converter passed
-                                         to convert_to_text text options */
+                                         to convert_to_text text options.
+      same than converter if set, but can be set directly from perl */
     OPTIONS *self_converter_options; /* text converter options available
                                         as the OPTIONS structure */
     int document_descriptor;
diff --git a/tp/Texinfo/XS/main/get_perl_info.c 
b/tp/Texinfo/XS/main/get_perl_info.c
index b241a01de8..67d37fa4c1 100644
--- a/tp/Texinfo/XS/main/get_perl_info.c
+++ b/tp/Texinfo/XS/main/get_perl_info.c
@@ -477,6 +477,7 @@ converter_initialize (SV *converter_sv)
          = copy_sv_options (*converter_init_conf_sv, converter);
     }
 
+#undef FETCH
   set_translated_commands (converter, hv_in);
 
   get_expanded_formats (hv_in, &converter->expanded_formats);
@@ -491,13 +492,31 @@ converter_initialize (SV *converter_sv)
   return converter_descriptor;
 }
 
+void
+recopy_converter_conf_sv (HV *hv, CONVERTER *converter,
+                          OPTIONS **conf, const char *conf_key)
+{
+  SV **conf_sv;
+
+  dTHX;
+
+  conf_sv = hv_fetch (hv, conf_key, strlen (conf_key), 0);
+
+  if (conf_sv && SvOK(*conf_sv))
+    {
+      if (*conf)
+        free_options (*conf);
+      free (*conf);
+
+      *conf = copy_sv_options (*conf_sv, converter);
+    }
+}
+
 /* initialize an XS converter from a perl converter right before conversion */
 CONVERTER *
 set_output_converter_sv (SV *sv_in, char *warn_string)
 {
   HV *hv_in;
-  SV **conf_sv;
-  SV **output_init_conf_sv;
   CONVERTER *converter = 0;
 
   dTHX;
@@ -506,33 +525,12 @@ set_output_converter_sv (SV *sv_in, char *warn_string)
 
   hv_in = (HV *)SvRV (sv_in);
 
-  FETCH(conf)
-
-  if (conf_sv)
-    {
-      if (converter->conf)
-        free_options (converter->conf);
-      free (converter->conf);
-
-      converter->conf
-         = copy_sv_options (*conf_sv, converter);
-    }
-
-  FETCH(output_init_conf)
-
-  if (output_init_conf_sv && SvOK(*output_init_conf_sv))
-    {
-      if (converter->init_conf)
-        free_options (converter->init_conf);
-      free (converter->init_conf);
-
-      converter->init_conf
-         = copy_sv_options (*output_init_conf_sv, converter);
-    }
+  recopy_converter_conf_sv (hv_in, converter, &converter->conf, "conf");
 
+  recopy_converter_conf_sv (hv_in, converter, &converter->init_conf,
+                            "output_init_conf");
   return converter;
 }
-#undef FETCH
 
 /* code in comments allow to sort the index names to have a fixed order
    in the data structure.  Not clear that it is useful or not, not enabled
diff --git a/tp/Texinfo/XS/main/get_perl_info.h 
b/tp/Texinfo/XS/main/get_perl_info.h
index 89d9ff8a7b..8ae558269d 100644
--- a/tp/Texinfo/XS/main/get_perl_info.h
+++ b/tp/Texinfo/XS/main/get_perl_info.h
@@ -34,6 +34,8 @@ SOURCE_INFO *get_source_info (SV *source_info_sv);
 void get_line_message (CONVERTER *self, enum error_type type, int continuation,
                        SV *error_location_info, char *message);
 OPTIONS *copy_sv_options (SV *sv_in, CONVERTER *converter);
+void recopy_converter_conf_sv (HV *hv, CONVERTER *converter,
+                               OPTIONS **conf, const char *conf_key);
 void set_conf (CONVERTER *converter, const char *conf, SV *value);
 
 CONVERTER *set_output_converter_sv (SV *sv_in, char *warn_string);



reply via email to

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