texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/Texinfo/XS/convert/get_converter_perl_info.c


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/XS/convert/get_converter_perl_info.c (get_converter_info_from_sv), tp/Texinfo/XS/main/build_perl_info.c (pass_generic_converter_to_converter_sv): always pass output_format and converted_format to Perl. Do not put them in non_valid_customization options information.
Date: Fri, 04 Oct 2024 19:50:18 -0400

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 286c243926 * tp/Texinfo/XS/convert/get_converter_perl_info.c 
(get_converter_info_from_sv), tp/Texinfo/XS/main/build_perl_info.c 
(pass_generic_converter_to_converter_sv): always pass output_format and 
converted_format to Perl.  Do not put them in non_valid_customization options 
information.
286c243926 is described below

commit 286c243926960996f6f53ed7c33f415d264c0cab
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Aug 17 18:06:46 2024 +0200

    * tp/Texinfo/XS/convert/get_converter_perl_info.c
    (get_converter_info_from_sv), tp/Texinfo/XS/main/build_perl_info.c
    (pass_generic_converter_to_converter_sv): always pass output_format
    and converted_format to Perl.  Do not put them in
    non_valid_customization options information.
    
    * tp/Makefile.tres, tp/t/test_converter_option.t: new tests file
    testing converters set/get converted_format and output_format.
---
 ChangeLog                                       | 11 +++++
 tp/Makefile.tres                                |  1 +
 tp/Texinfo/XS/convert/ConvertXS.xs              |  1 -
 tp/Texinfo/XS/convert/get_converter_perl_info.c | 43 ++++++++++---------
 tp/Texinfo/XS/main/build_perl_info.c            |  6 +++
 tp/t/test_converter_option.t                    | 55 +++++++++++++++++++++++++
 6 files changed, 97 insertions(+), 20 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index be0ebbc86a..98d0ad3d20 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2024-08-17  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/convert/get_converter_perl_info.c
+       (get_converter_info_from_sv), tp/Texinfo/XS/main/build_perl_info.c
+       (pass_generic_converter_to_converter_sv): always pass output_format
+       and converted_format to Perl.  Do not put them in
+       non_valid_customization options information.
+
+       * tp/Makefile.tres, tp/t/test_converter_option.t: new tests file
+       testing converters set/get converted_format and output_format.
+
 2024-08-17  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/Convert/Converter.pm (_generic_converter_init),
diff --git a/tp/Makefile.tres b/tp/Makefile.tres
index d3f78b69ae..d519db1231 100644
--- a/tp/Makefile.tres
+++ b/tp/Makefile.tres
@@ -56,6 +56,7 @@ test_tap_files_generated_list = \
   t/reference_to_text_in_tree.t \
   t/same_parser_multiple_files.t \
   t/test_brace_count.t \
+  t/test_converter_option.t \
   t/test_document.t \
   t/test_fill_gaps_in_sectioning.t \
   t/test_is_content_empty.t \
diff --git a/tp/Texinfo/XS/convert/ConvertXS.xs 
b/tp/Texinfo/XS/convert/ConvertXS.xs
index aa70402f71..7cd2d176a3 100644
--- a/tp/Texinfo/XS/convert/ConvertXS.xs
+++ b/tp/Texinfo/XS/convert/ConvertXS.xs
@@ -209,7 +209,6 @@ generic_converter_init (SV *converter_in, SV 
*format_defaults_sv, SV *conf_sv=0)
         set_converter_init_information (self, self->format,
                                         format_defaults, conf);
 
-
         if (format_defaults)
           {
     /* set directly Perl converter keys with non 'valid' customization info */
diff --git a/tp/Texinfo/XS/convert/get_converter_perl_info.c 
b/tp/Texinfo/XS/convert/get_converter_perl_info.c
index fc8720e5d7..c6ed81e1c1 100644
--- a/tp/Texinfo/XS/convert/get_converter_perl_info.c
+++ b/tp/Texinfo/XS/convert/get_converter_perl_info.c
@@ -281,31 +281,36 @@ get_converter_info_from_sv (SV *conf_sv, const char 
*class_name,
             {
               if (status == -2)
                 {
-                  add_string (key,
-                        &initialization_info->non_valid_customization);
-
-                  if (!strcmp (key, "translated_commands"))
-                    initialization_info->translated_commands
-                      = set_translated_commands (value);
-                  /* FIXME get deprecated_config_directories if needed */
-                  else if (!strcmp (key, "deprecated_config_directories"))
-                    {}
-                  else if (!strcmp (key, "output_format"))
+                  /* next two passed in
+                     pass_generic_converter_to_converter_sv */
+                  if (!strcmp (key, "output_format"))
                     initialization_info->output_format
                       = non_perl_strdup (SvPVutf8_nolen (value));
                   else if (!strcmp (key, "converted_format"))
                     initialization_info->converted_format
                       = non_perl_strdup (SvPVutf8_nolen (value));
-                  else if (!strcmp (key, "texinfo_language_config_dirs"))
-                    {
-                      /* TODO add to converter and set.  Only used for
-                         htmlxref, so should wait for that to implement */
-                    }
-                  else if (class_name)
+                  /* FIXME get deprecated_config_directories if needed */
+                  else if (!strcmp (key, "deprecated_config_directories"))
+                    {}
+                  else
                     {
-                      fprintf (stderr,
-                               "%s: %s not a possible configuration\n",
-                               class_name, key);
+                      add_string (key,
+                        &initialization_info->non_valid_customization);
+
+                      if (!strcmp (key, "translated_commands"))
+                        initialization_info->translated_commands
+                          = set_translated_commands (value);
+                      else if (!strcmp (key, "texinfo_language_config_dirs"))
+                        {
+                          /* TODO add to converter and set.  Only used for
+                             htmlxref, so should wait for that to implement */
+                        }
+                      else if (class_name)
+                        {
+                          fprintf (stderr,
+                                   "%s: %s not a possible configuration\n",
+                                   class_name, key);
+                        }
                     }
                 }
               else
diff --git a/tp/Texinfo/XS/main/build_perl_info.c 
b/tp/Texinfo/XS/main/build_perl_info.c
index 8349729070..6942efe181 100644
--- a/tp/Texinfo/XS/main/build_perl_info.c
+++ b/tp/Texinfo/XS/main/build_perl_info.c
@@ -3174,6 +3174,12 @@ pass_generic_converter_to_converter_sv (SV *converter_sv,
     = build_translated_commands (converter->translated_commands);
   STORE("translated_commands", newRV_noinc ((SV *) translated_commands_hv));
 
+  if (converter->output_format)
+    STORE("output_format", newSVpv_utf8 (converter->output_format, 0));
+
+  if (converter->converted_format)
+    STORE("converted_format", newSVpv_utf8 (converter->converted_format, 0));
+
   /* store converter_descriptor in perl converter */
   /* FIXME converter->converter_descriptor is size_t, there will be an overflow
            if > max of IV */
diff --git a/tp/t/test_converter_option.t b/tp/t/test_converter_option.t
new file mode 100644
index 0000000000..2a7f81d66c
--- /dev/null
+++ b/tp/t/test_converter_option.t
@@ -0,0 +1,55 @@
+use strict;
+use utf8;
+
+use lib '.';
+use Texinfo::ModulePath (undef, undef, undef, 'updirs' => 2);
+
+use Test::More;
+
+BEGIN { plan tests => 7; }
+
+use Texinfo::Convert::HTML;
+use Texinfo::Convert::Info;
+use Texinfo::Convert::DocBook;
+
+# invalid converter configuration option
+my $html_converter = Texinfo::Convert::HTML->converter({'toto' => 1});
+# cannot be used to test, as it triggers a call to confess
+#my $toto = $html_converter->get_conf('toto');
+my $html_converted_format = $html_converter->{'converted_format'};
+#print STDERR "HTML: c '$html_converted_format'\n";
+is ($html_converted_format, 'html', 'HTML converted_format');
+my $html_output_format = $html_converter->{'output_format'};
+#print STDERR "HTML: o '$html_output_format'\n";
+is ($html_output_format, undef, 'HTML output_format unset');
+
+my $html_converter_with_output_format
+  = Texinfo::Convert::HTML->converter({'output_format' => 'my format'});
+my $html_output_format_with_output_format
+  = $html_converter_with_output_format->{'output_format'};
+#print STDERR "HTML: s o '$html_output_format_with_output_format'\n";
+is ($html_output_format_with_output_format, 'my format',
+                                            'HTML output_format set');
+
+my $info_converter = Texinfo::Convert::Info->converter({'titi' => 1});
+my $info_converted_format = $info_converter->{'converted_format'};
+#print STDERR "Info: '$info_converted_format'\n";
+is ($info_converted_format, '', 'Info converted_format');
+
+my $docbook_converter = Texinfo::Convert::DocBook->converter();
+my $docbook_converted_format = $docbook_converter->{'converted_format'};
+#print STDERR "DocBook: '$docbook_converted_format'\n";
+is ($docbook_converted_format, 'docbook', 'DocBook converted_format');
+my $docbook_output_format = $docbook_converter->{'output_format'};
+#print STDERR "DocBook: o '$docbook_output_format'\n";
+is ($docbook_output_format, undef, 'DocBook output_format unset');
+
+my $docbook_converter_with_output_format
+  = Texinfo::Convert::DocBook->converter({'output_format' => 'my dbk'});
+my $docbook_output_format_with_output_format
+  = $docbook_converter_with_output_format->{'output_format'};
+#print STDERR "DocBook: s o '$docbook_output_format_with_output_format'\n";
+is ($docbook_output_format_with_output_format, 'my dbk',
+                                               'DocBook output_format set');
+
+



reply via email to

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