bug-texinfo
[Top][All Lists]
Advanced

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

Re: Disabling XS translation functions - please help


From: Gavin Smith
Subject: Re: Disabling XS translation functions - please help
Date: Fri, 27 Oct 2023 21:33:18 +0100

On Fri, Oct 27, 2023 at 01:56:21PM +0100, Gavin Smith wrote:

> I consider texi2any to be in a semi-broken state at the moment, with
> the new code entangled with the program in a way that I am finding
> difficult to remove.  I may not have much more time to work on this in
> the coming days.

I had another go at it, and the test suite nearly passes with the
patch below (there were a couple of commits since on master that
may have changed the situation).  The only test that failed was
'different_languages_gen_master_menu.sh' (in tp/tests/many_input_files),
where the output is not translated fully.  I'm hopeful with the other
tests passing, it should be close to what is needed to disable the
XS translations.  If I get time, I'll track through where the translation
fails and hopefully be able to propose a more finished patch.

It's tangential, but it may be good to avoid the need to call
Texinfo::Structuring::rebuild_document anywhere in the code.  I suggest
that in Texinfo::Document, Perl data structures could be build on
demand.

For example 'indices_information' could check if $self->{'indices'}
is built, and if not, regenerate it.  If there are transformations that
operate on XS data structures, the Perl data structures could be marked
as invalid or deleted, so they will be automatically regenerated if/when
needed.

It would be transparent to the calling code whether the information
is ready or not, provided it sticks to using the correct interfaces to
the module.  They should not have to call rebuild_document or worry about
getting out of date information.  That way, if the Perl data structures
are never needed, they will not be built.  Does that sound like a good
way forwards?

It might require splitting up the XS code in rebuild_document to
regenerate different parts of the document information.



diff --git a/tp/Texinfo/Translations.pm b/tp/Texinfo/Translations.pm
index 28f91bb29d..7823a9df7f 100644
--- a/tp/Texinfo/Translations.pm
+++ b/tp/Texinfo/Translations.pm
@@ -24,6 +24,8 @@ our $VERSION = '7.1';
 
 use Texinfo::XSLoader;
 
+use Texinfo::TranslationsNonXS;
+
 # BEWARE the setup is weird here, because we load the NonXS module in any case.
 # Indeed, the XS module does not work, except for the configure(_XS) function
 # that we want to call.  So, we load the XS code here, but also the NonXS
@@ -32,7 +34,8 @@ use Texinfo::XSLoader;
 # NonXS functions.  We override a function with configure(_XS) in the NonXS
 # module to call the XS code configure(_XS).
 
-BEGIN {
+#BEGIN {
+if (0) {
   our $warning_message = undef;
   our $fatal_message = undef;
 
diff --git a/tp/Texinfo/XS/parsetexi/Parsetexi.pm 
b/tp/Texinfo/XS/parsetexi/Parsetexi.pm
index f64bb2c76f..d6f6f0a759 100644
--- a/tp/Texinfo/XS/parsetexi/Parsetexi.pm
+++ b/tp/Texinfo/XS/parsetexi/Parsetexi.pm
@@ -194,8 +194,8 @@ sub _get_parser_info($$;$) {
 
   my $document = build_document ($document_descriptor, $no_store);
 
-  #Texinfo::Translations::complete_indices ($self,
-  #                                 $document->indices_information());
+  Texinfo::Translations::complete_indices ($self,
+                                   $document->indices_information());
 
   # Copy the errors into the error list in Texinfo::Report.
   foreach my $error (@{$document->{'errors'}}) {
diff --git a/tp/Texinfo/XS/parsetexi/indices.c 
b/tp/Texinfo/XS/parsetexi/indices.c
index a2478e7f48..0019d6e028 100644
--- a/tp/Texinfo/XS/parsetexi/indices.c
+++ b/tp/Texinfo/XS/parsetexi/indices.c
@@ -367,6 +367,8 @@ resolve_indices_merged_in (void)
     }
 }
 
+/* Currently unused, as it relies on getting translations with gdt/gettext
+   which does not currently work in the XS module. */
 void
 complete_indices (int document_descriptor)
 {
diff --git a/tp/Texinfo/XS/parsetexi/parser.c b/tp/Texinfo/XS/parsetexi/parser.c
index ea542f0107..b78783d15c 100644
--- a/tp/Texinfo/XS/parsetexi/parser.c
+++ b/tp/Texinfo/XS/parsetexi/parser.c
@@ -2743,7 +2743,8 @@ parse_texi (ELEMENT *root_elt, ELEMENT *current_elt)
 
   document_descriptor = store_document(current);
 
-  complete_indices (document_descriptor);
+  /* Does not currently work. */
+  //complete_indices (document_descriptor);
 
   return document_descriptor;
 }
diff --git a/tp/t/test_utils.pl b/tp/t/test_utils.pl
index 29fdc521b9..4268d07621 100644
--- a/tp/t/test_utils.pl
+++ b/tp/t/test_utils.pl
@@ -1081,6 +1081,9 @@ sub test($$)
   }
 
   $document = Texinfo::Structuring::rebuild_document($document);
+  Texinfo::Translations::complete_indices ($parser,
+                                           $document->indices_information());
+
   # should not actually be useful, as the same element should be reused.
   $tree = $document->tree();
 
diff --git a/tp/texi2any.pl b/tp/texi2any.pl
index 26cb16e2c0..e5da917432 100755
--- a/tp/texi2any.pl
+++ b/tp/texi2any.pl
@@ -1633,6 +1633,8 @@ while(@input_files) {
   }
 
   $document = Texinfo::Structuring::rebuild_document($document);
+  Texinfo::Translations::complete_indices ($parser,
+                                           $document->indices_information());
 
   if ($with_XS) {
     foreach my $error (@{$document->{'errors'}}) {





reply via email to

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