texinfo-commits
[Top][All Lists]
Advanced

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

[no subject]


From: Patrice Dumas
Date: Fri, 8 Dec 2023 11:07:45 -0500 (EST)

branch: master
commit 62eea27985ef8c7be00d05941ec623651fc3f18e
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Fri Dec 8 14:19:25 2023 +0100

    Pass XS converter errors to texi2any
    
    * tp/Texinfo/Convert/Converter.pm (%XS_overrides)
    (get_converter_errors), tp/Texinfo/Convert/Text.pm
    (get_converter_errors), tp/Texinfo/XS/convert/ConvertXS.xs
    (get_converter_errors), tp/texi2any.pl: add an XS interface to get
    converter error. Add them to the Texinfo::Report associated to the
    perl converter.
---
 ChangeLog                          | 11 +++++++++++
 tp/Texinfo/Convert/Converter.pm    |  8 ++++++++
 tp/Texinfo/Convert/Text.pm         |  5 +++++
 tp/Texinfo/XS/convert/ConvertXS.xs | 21 +++++++++++++++++++++
 tp/texi2any.pl                     | 10 ++++++++++
 5 files changed, 55 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 31da3094ce..fdc08f9ff4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2023-12-08  Patrice Dumas  <pertusus@free.fr>
+
+       Pass XS converter errors to texi2any
+
+       * tp/Texinfo/Convert/Converter.pm (%XS_overrides)
+       (get_converter_errors), tp/Texinfo/Convert/Text.pm
+       (get_converter_errors), tp/Texinfo/XS/convert/ConvertXS.xs
+       (get_converter_errors), tp/texi2any.pl: add an XS interface to get
+       converter error. Add them to the Texinfo::Report associated to the
+       perl converter.
+
 2023-12-08  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/Convert/HTML.pm (_convert_def_line_type): avoid
diff --git a/tp/Texinfo/Convert/Converter.pm b/tp/Texinfo/Convert/Converter.pm
index 327df71550..1de529f827 100644
--- a/tp/Texinfo/Convert/Converter.pm
+++ b/tp/Texinfo/Convert/Converter.pm
@@ -89,6 +89,8 @@ my %XS_overrides = (
    => "Texinfo::Convert::ConvertXS::set_conf",
   "Texinfo::Convert::Converter::_XS_get_unclosed_stream"
    => "Texinfo::Convert::ConvertXS::get_unclosed_stream",
+  "Texinfo::Convert::Converter::get_converter_errors"
+   => "Texinfo::Convert::ConvertXS::get_converter_errors",
   "Texinfo::Convert::Converter::destroy"
    => "Texinfo::Convert::ConvertXS::destroy",
 );
@@ -479,6 +481,12 @@ sub destroy($)
 {
 }
 
+# Nothing to do in perl as the converter is also a Texinfo::Report.
+# In XS return the error messages.
+sub get_converter_errors($)
+{
+}
+
 ###############################################################
 # Implementation of the customization API that is used in many
 # Texinfo modules
diff --git a/tp/Texinfo/Convert/Text.pm b/tp/Texinfo/Convert/Text.pm
index 04ccab3df1..b2b8f1fc87 100644
--- a/tp/Texinfo/Convert/Text.pm
+++ b/tp/Texinfo/Convert/Text.pm
@@ -1044,6 +1044,11 @@ sub errors()
   return undef;
 }
 
+sub get_converter_errors($)
+{
+  return undef;
+}
+
 sub converter_defaults()
 {
   return ();
diff --git a/tp/Texinfo/XS/convert/ConvertXS.xs 
b/tp/Texinfo/XS/convert/ConvertXS.xs
index 3c43a1838f..6eeab45870 100644
--- a/tp/Texinfo/XS/convert/ConvertXS.xs
+++ b/tp/Texinfo/XS/convert/ConvertXS.xs
@@ -36,6 +36,7 @@
 #include "element_types.h"
 #include "converter_types.h"
 #include "builtin_commands.h"
+#include "errors.h"
 #include "convert_plain_texinfo.h"
 #include "convert_text.h"
 #include "convert_to_text.h"
@@ -126,6 +127,26 @@ get_unclosed_stream (SV *converter_in, file_path)
     OUTPUT:
          RETVAL
 
+SV *
+get_converter_errors (SV *converter_in)
+      PREINIT:
+         AV *errors_av;
+         CONVERTER *self = 0;
+      CODE:
+         self = get_sv_converter (converter_in, 0);
+         if (self && self->error_messages.number)
+           {
+             errors_av = get_errors (self->error_messages.list,
+                                     self->error_messages.number);
+             wipe_error_message_list (&self->error_messages);
+           }
+         else
+           errors_av = newAV ();
+
+         RETVAL = newRV_noinc ((SV *) errors_av);
+    OUTPUT:
+         RETVAL
+
 void
 destroy (SV *converter_in)
       PREINIT:
diff --git a/tp/texi2any.pl b/tp/texi2any.pl
index 6309fd2edc..4acec6dad6 100755
--- a/tp/texi2any.pl
+++ b/tp/texi2any.pl
@@ -1691,6 +1691,16 @@ while(@input_files) {
   my $converter = &{$formats_table{$converted_format}
         ->{'converter'}}($converter_options);
   $converter->output($document);
+
+  # If XS is used, store XS converter errors in perl Texinfo::Report
+  # object associated to the perl converter.
+  my $converter_errors = $converter->get_converter_errors();
+  if (defined($converter_errors)) {
+    foreach my $error (@$converter_errors) {
+      $converter->add_formatted_message($error);
+    }
+  }
+
   push @opened_files, Texinfo::Common::output_files_opened_files(
                               $converter->output_files_information());
   handle_errors($converter, $error_count, \@opened_files);



reply via email to

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