texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/Texinfo/Convert/Converter.pm (_generic_conve


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/Convert/Converter.pm (_generic_converter_init), tp/Texinfo/XS/convert/ConvertXS.xs (generic_converter_init): do not pass class to generic_converter_init, get it through ref and equivalent in XS.
Date: Fri, 04 Oct 2024 19:48:02 -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 2712828481 * tp/Texinfo/Convert/Converter.pm 
(_generic_converter_init), tp/Texinfo/XS/convert/ConvertXS.xs 
(generic_converter_init): do not pass class to generic_converter_init, get it 
through ref and equivalent in XS.
2712828481 is described below

commit 2712828481bbe20681fa82a9bb05d917b0ffc61d
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Aug 17 17:21:21 2024 +0200

    * tp/Texinfo/Convert/Converter.pm (_generic_converter_init),
    tp/Texinfo/XS/convert/ConvertXS.xs (generic_converter_init): do not
    pass class to generic_converter_init, get it through ref and
    equivalent in XS.
    
    * tp/Texinfo/XS/convert/get_converter_perl_info.c
    (get_converter_info_from_sv): get class_name as argument only.  If
    NULL, no error message.
    
    * tp/Texinfo/XS/convert/ConvertXS.xs (converter_defaults): call
    get_converter_info_from_sv without class name argument to avoid a
    duplicate message.
---
 ChangeLog                                       | 15 +++++++++++++++
 tp/Texinfo/Convert/Converter.pm                 |  7 +++----
 tp/Texinfo/XS/convert/ConvertXS.xs              | 17 ++++++++++++-----
 tp/Texinfo/XS/convert/get_converter_perl_info.c | 14 ++++----------
 tp/t/convert_to_text.t                          |  2 ++
 5 files changed, 36 insertions(+), 19 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 7845aa13ac..be0ebbc86a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2024-08-17  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/Convert/Converter.pm (_generic_converter_init),
+       tp/Texinfo/XS/convert/ConvertXS.xs (generic_converter_init): do not
+       pass class to generic_converter_init, get it through ref and
+       equivalent in XS.
+
+       * tp/Texinfo/XS/convert/get_converter_perl_info.c
+       (get_converter_info_from_sv): get class_name as argument only.  If
+       NULL, no error message.
+
+       * tp/Texinfo/XS/convert/ConvertXS.xs (converter_defaults): call
+       get_converter_info_from_sv without class name argument to avoid a
+       duplicate message.
+
 2024-08-17  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/convert/html_converter_init_options.c,
diff --git a/tp/Texinfo/Convert/Converter.pm b/tp/Texinfo/Convert/Converter.pm
index 87ebf2df57..ef5bde7e00 100644
--- a/tp/Texinfo/Convert/Converter.pm
+++ b/tp/Texinfo/Convert/Converter.pm
@@ -258,10 +258,9 @@ sub set_document($$)
 }
 
 # initialization either in generic XS converter or in Perl
-sub _generic_converter_init($$$;$)
+sub _generic_converter_init($$;$)
 {
   my $converter = shift;
-  my $class = shift;
   my $format_defaults = shift;
   my $conf = shift;
 
@@ -287,6 +286,7 @@ sub _generic_converter_init($$$;$)
       if (Texinfo::Common::valid_customization_option($key)) {
         $converter->{'conf'}->{$key} = $conf->{$key};
       } elsif (!exists($defaults{$key})) {
+        my $class = ref($converter);
         warn "$class: $key not a possible configuration\n";
       } else {
         $converter->{$key} = $conf->{$key};
@@ -331,8 +331,7 @@ sub converter($;$)
 
   my $format_defaults = $converter->converter_defaults($conf);
 
-  # if with XS, XS converter initialization.
-  _generic_converter_init($converter, $class, $format_defaults, $conf);
+  _generic_converter_init($converter, $format_defaults, $conf);
 
   $converter->converter_initialize();
 
diff --git a/tp/Texinfo/XS/convert/ConvertXS.xs 
b/tp/Texinfo/XS/convert/ConvertXS.xs
index d77d4bf176..aa70402f71 100644
--- a/tp/Texinfo/XS/convert/ConvertXS.xs
+++ b/tp/Texinfo/XS/convert/ConvertXS.xs
@@ -135,8 +135,12 @@ converter_defaults (SV *converter_in, SV *conf_sv)
           = find_perl_converter_class_converter_format (class_name);
 
         /* use txi_base_sorted_options to find the type of options
-           specified by name */
-        conf = get_converter_info_from_sv (conf_sv, class_name, 0,
+           specified by name.
+
+           Do not pass class_name to avoid error messages, there will
+           be an error messages in generic_converter_init (as in Perl)
+         */
+        conf = get_converter_info_from_sv (conf_sv, 0, 0,
                                            txi_base_sorted_options);
 
         format_defaults = converter_defaults (converter_format, conf);
@@ -171,16 +175,19 @@ converter_defaults (SV *converter_in, SV *conf_sv)
     OUTPUT:
         RETVAL
 
-# NOTE not sure what the scope of class_name is.  When tested, valgrind did not
-# complain.
 void
-generic_converter_init (SV *converter_in, const char *class_name, SV 
*format_defaults_sv, SV *conf_sv=0)
+generic_converter_init (SV *converter_in, SV *format_defaults_sv, SV 
*conf_sv=0)
       PREINIT:
         CONVERTER *self;
         CONVERTER_INITIALIZATION_INFO *format_defaults;
         CONVERTER_INITIALIZATION_INFO *conf;
         HV *converter_hv;
+        HV *stash;
+        const char *class_name;
       CODE:
+        stash = SvSTASH (SvRV (converter_in));
+        class_name = HvNAME (stash);
+
         self = get_or_create_sv_converter (converter_in, class_name);
         converter_hv = (HV *)SvRV (converter_in);
         self->hv = converter_hv;
diff --git a/tp/Texinfo/XS/convert/get_converter_perl_info.c 
b/tp/Texinfo/XS/convert/get_converter_perl_info.c
index 0befa60d75..fc8720e5d7 100644
--- a/tp/Texinfo/XS/convert/get_converter_perl_info.c
+++ b/tp/Texinfo/XS/convert/get_converter_perl_info.c
@@ -234,10 +234,10 @@ new_numbered_option_from_sv (SV *option_sv, CONVERTER 
*converter,
   return option;
 }
 
-/* class is Perl converter class for warning message in case the class
-   cannot be found otherwise */
+/* CLASS_NAME is Perl converter class for warning message.  If NULL, no 
message.
+   CONVERTER may be NULL (when called from converter_defaults). */
 CONVERTER_INITIALIZATION_INFO *
-get_converter_info_from_sv (SV *conf_sv, const char *class,
+get_converter_info_from_sv (SV *conf_sv, const char *class_name,
                             CONVERTER *converter,
                             OPTION **sorted_options)
 {
@@ -301,14 +301,8 @@ get_converter_info_from_sv (SV *conf_sv, const char *class,
                       /* TODO add to converter and set.  Only used for
                          htmlxref, so should wait for that to implement */
                     }
-                  else
+                  else if (class_name)
                     {
-                      const char *class_name;
-                      if (converter->format >= 0)
-                        class_name
-              = converter_format_data[converter->format].perl_converter_class;
-                       else
-                        class_name = class;
                       fprintf (stderr,
                                "%s: %s not a possible configuration\n",
                                class_name, key);
diff --git a/tp/t/convert_to_text.t b/tp/t/convert_to_text.t
index a1c2d36995..612c958bbe 100644
--- a/tp/t/convert_to_text.t
+++ b/tp/t/convert_to_text.t
@@ -37,6 +37,8 @@ use Texinfo::Convert::HTML;
 # Note that Texinfo::Convert::Utils::add_heading_number is called
 # from Texinfo::Convert::Plaintext converter for sectioning commands
 # with translations support.
+#
+# This tests an HTML converter initialization without options.
 
 
 # setup translated strings



reply via email to

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