texinfo-commits
[Top][All Lists]
Advanced

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

[no subject]


From: Patrice Dumas
Date: Mon, 15 Jan 2024 16:18:21 -0500 (EST)

branch: master
commit 15b0157e69dd5ee889f56c48efce3a01122c802b
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Mon Jan 15 18:59:35 2024 +0100

    * tp/Makefile.am (dist_modules_DATA), tp/Texinfo/Indices.pm,
    tp/Texinfo/IndicesXS.pm, tp/Texinfo/XS/Makefile.am
    (StructuringTransfoXS_la_SOURCES, StructuringTransfoXS_la_CPPFLAGS),
    (xs_LTLIBRARIES, IndicesXS_la_*), tp/Texinfo/XS/convert/IndicesXS.xs,
    tp/Texinfo/XS/structuring_transfo/StructuringTransfoXS.xs: move code
    related to indices to a new XS file convert/IndicesXS.xs out of
    StructuringTransfoXS.xs.
---
 .gitignore                                         |   1 +
 ChangeLog                                          |  10 ++
 tp/Makefile.am                                     |   1 +
 tp/Texinfo/Indices.pm                              |   6 +-
 tp/Texinfo/IndicesXS.pm                            |  62 +++++++++
 tp/Texinfo/XS/Makefile.am                          |  26 +++-
 tp/Texinfo/XS/convert/IndicesXS.xs                 | 155 +++++++++++++++++++++
 .../XS/structuring_transfo/StructuringTransfoXS.xs | 108 --------------
 8 files changed, 255 insertions(+), 114 deletions(-)

diff --git a/.gitignore b/.gitignore
index 1f08816347..537e1c833b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -353,6 +353,7 @@ tp/Texinfo/XS/parsetexi/*.la
 tp/Texinfo/XS/parsetexi/*.lo
 
 tp/Texinfo/XS/convert/ConvertXS.c
+tp/Texinfo/XS/convert/IndicesXS.c
 
 tp/Texinfo/XS/convert/.libs
 tp/Texinfo/XS/convert/*.la
diff --git a/ChangeLog b/ChangeLog
index e5c8d59e33..e50ba3bc0d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,16 @@
        convert_output_unit, and explain the purpose of saving it.  Reorder
        code slightly for clarity.  No functional changes intended.
 
+2024-01-15  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Makefile.am (dist_modules_DATA), tp/Texinfo/Indices.pm,
+       tp/Texinfo/IndicesXS.pm, tp/Texinfo/XS/Makefile.am
+       (StructuringTransfoXS_la_SOURCES, StructuringTransfoXS_la_CPPFLAGS),
+       (xs_LTLIBRARIES, IndicesXS_la_*), tp/Texinfo/XS/convert/IndicesXS.xs,
+       tp/Texinfo/XS/structuring_transfo/StructuringTransfoXS.xs: move code
+       related to indices to a new XS file convert/IndicesXS.xs out of
+       StructuringTransfoXS.xs.
+
 2024-01-15  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/Indices.pm, tp/Texinfo/Structuring.pm, tp/Makefile.am
diff --git a/tp/Makefile.am b/tp/Makefile.am
index 2effebbc67..4a189e704b 100644
--- a/tp/Makefile.am
+++ b/tp/Makefile.am
@@ -73,6 +73,7 @@ dist_modules_DATA = \
  Texinfo/DocumentXS.pm \
  Texinfo/Documentlanguages.pm \
  Texinfo/Indices.pm \
+ Texinfo/IndicesXS.pm \
  Texinfo/MiscXS.pm \
  Texinfo/Options.pm \
  Texinfo/Parser.pm \
diff --git a/tp/Texinfo/Indices.pm b/tp/Texinfo/Indices.pm
index 37dd08900f..d920f98aaf 100644
--- a/tp/Texinfo/Indices.pm
+++ b/tp/Texinfo/Indices.pm
@@ -38,7 +38,7 @@ use Carp qw(cluck confess);
 
 use Unicode::Normalize;
 
-use Texinfo::StructTransfXS;
+use Texinfo::IndicesXS;
 
 use Texinfo::XSLoader;
 
@@ -77,9 +77,9 @@ $XS_convert = 1 if ($XS_structuring
 my %XS_convert_overrides = (
 
   "Texinfo::Indices::index_entry_element_sort_string"
-    => "Texinfo::StructTransfXS::index_entry_element_sort_string",
+    => "Texinfo::IndicesXS::index_entry_element_sort_string",
   "Texinfo::Indices::setup_index_entry_keys_formatting",
-    => "Texinfo::StructTransfXS::setup_index_entry_keys_formatting",
+    => "Texinfo::IndicesXS::setup_index_entry_keys_formatting",
 
 );
 
diff --git a/tp/Texinfo/IndicesXS.pm b/tp/Texinfo/IndicesXS.pm
new file mode 100644
index 0000000000..9e306987b0
--- /dev/null
+++ b/tp/Texinfo/IndicesXS.pm
@@ -0,0 +1,62 @@
+# Indices.pm: load indices XS
+# Copyright 2023 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License,
+# or (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+package Texinfo::IndicesXS;
+
+use strict;
+use warnings;
+
+our $VERSION = '7.1dev';
+
+use Texinfo::XSLoader;
+
+BEGIN {
+  my $XS_structuring = ((not defined($ENV{TEXINFO_XS})
+                        or $ENV{TEXINFO_XS} ne 'omit')
+                       and (not defined($ENV{TEXINFO_XS_PARSER})
+                            or $ENV{TEXINFO_XS_PARSER} eq '1')
+                       and (not defined($ENV{TEXINFO_XS_STRUCTURE})
+                            or $ENV{TEXINFO_XS_STRUCTURE} ne '0'));
+
+  my $XS_convert = 0;
+  $XS_convert = 1 if ($XS_structuring
+                    and defined $ENV{TEXINFO_XS_CONVERT}
+                    and $ENV{TEXINFO_XS_CONVERT} eq '1');
+
+  if ($XS_convert) {
+    Texinfo::XSLoader::init (
+      "Texinfo::IndicesXS",
+      "Texinfo::IndicesXS",
+      "IndicesXS",
+      undef,
+      0,
+      undef,
+      undef,
+    );
+  }
+}
+
+# NB Don't add more functions down here, because this can cause an error
+# with some versions of Perl, connected with any typeglob assignments done
+# above.  ("Can't call mro_method_changed_in() on anonymous symbol table").
+#
+# See 
http://perl5.git.perl.org/perl.git/commitdiff/03d9f026ae253e9e69212a3cf6f1944437e9f070?hp=ac73ea1ec401df889d312b067f78b618f7ffecc3
+#
+# (change to Perl interpreter on 22 Oct 2011)
+
+
+1;
+__END__
diff --git a/tp/Texinfo/XS/Makefile.am b/tp/Texinfo/XS/Makefile.am
index 367d2e6c0d..f46c533123 100644
--- a/tp/Texinfo/XS/Makefile.am
+++ b/tp/Texinfo/XS/Makefile.am
@@ -351,19 +351,39 @@ nodist_StructuringTransfoXS_la_SOURCES = \
 CLEANFILES += \
                     structuring_transfo/StructuringTransfoXS.c
 StructuringTransfoXS_la_SOURCES = \
-                    convert/indices_in_conversion.h \
-                    convert/indices_in_conversion.c \
                     structuring_transfo/transformations.c \
                     structuring_transfo/transformations.h
 
 EXTRA_DIST += structuring_transfo/StructuringTransfoXS.xs
 
 # locate include files under out-of-source builds.
-StructuringTransfoXS_la_CPPFLAGS = -I$(srcdir)/main 
-I$(srcdir)/structuring_transfo -I$(srcdir)/convert $(AM_CPPFLAGS) 
$(GNULIB_CPPFLAGS) $(XSLIBS_CPPFLAGS)
+StructuringTransfoXS_la_CPPFLAGS = -I$(srcdir)/main 
-I$(srcdir)/structuring_transfo $(AM_CPPFLAGS) $(GNULIB_CPPFLAGS) 
$(XSLIBS_CPPFLAGS)
 StructuringTransfoXS_la_CFLAGS = $(XSLIBS_CFLAGS)
 StructuringTransfoXS_la_LIBADD = libtexinfoxs.la libtexinfo.la 
$(top_builddir)/gnulib/lib/libgnu.la
 StructuringTransfoXS_la_LDFLAGS = $(XSLIBS_LDFLAGS) $(LTLIBICONV) 
$(LTLIBUNISTRING)
 
+########################## IndicesXS
+
+if HAVE_ICONV
+xs_LTLIBRARIES += IndicesXS.la
+endif
+
+nodist_IndicesXS_la_SOURCES = \
+                    convert/IndicesXS.c
+CLEANFILES += \
+                    convert/IndicesXS.c
+IndicesXS_la_SOURCES = \
+                    convert/indices_in_conversion.h \
+                    convert/indices_in_conversion.c
+
+EXTRA_DIST += convert/IndicesXS.xs
+
+# locate include files under out-of-source builds.
+IndicesXS_la_CPPFLAGS = -I$(srcdir)/main -I$(srcdir)/convert $(AM_CPPFLAGS) 
$(GNULIB_CPPFLAGS) $(XSLIBS_CPPFLAGS)
+IndicesXS_la_CFLAGS = $(XSLIBS_CFLAGS)
+IndicesXS_la_LIBADD = libtexinfoxs.la libtexinfo.la 
$(top_builddir)/gnulib/lib/libgnu.la
+IndicesXS_la_LDFLAGS = $(XSLIBS_LDFLAGS) $(LTLIBICONV) $(LTLIBUNISTRING)
+
 ########################## ConvertXS
 
 if HAVE_ICONV
diff --git a/tp/Texinfo/XS/convert/IndicesXS.xs 
b/tp/Texinfo/XS/convert/IndicesXS.xs
new file mode 100644
index 0000000000..b20311c12b
--- /dev/null
+++ b/tp/Texinfo/XS/convert/IndicesXS.xs
@@ -0,0 +1,155 @@
+/* Copyright 2023 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+/* Avoid namespace conflicts. */
+#define context perl_context
+
+#define PERL_NO_GET_CONTEXT
+#include "EXTERN.h"
+#include "perl.h"
+#if defined _WIN32 && !defined __CYGWIN__
+# undef free
+#endif
+#include "XSUB.h"
+
+#undef context
+
+#include "ppport.h"
+
+#include "tree_types.h"
+#include "document_types.h"
+/*
+#include "tree.h"
+#include "utils.h"
+ */
+#include "document.h"
+#include "indices_in_conversion.h"
+#include "get_perl_info.h"
+/* for newSVpv_utf8 */
+#include "build_perl_info.h"
+
+MODULE = Texinfo::IndicesXS    PACKAGE = Texinfo::IndicesXS
+
+PROTOTYPES: ENABLE
+
+# This function triggers setting the information needed for calls
+# to index_entry_element_sort_string in C, either in a document
+# or in a converter, depending whether index sorting is done with a converter
+# or without.
+# A returned hash reference is needed as some information is set in the
+# hash in perl afterwards, but this information is not used as the hash
+# is not used by any function not overriden, so there is no need to
+# return information corresponding to the text options for perl.  An empty
+# hash reference is therefore returned.
+SV *
+setup_index_entry_keys_formatting (SV *customization_info_sv)
+    PREINIT:
+        CONVERTER *self;
+        HV *hv;
+     CODE:
+        self = get_sv_converter (customization_info_sv, 0);
+        if (self)
+          {
+            TEXT_OPTIONS *text_options
+              = setup_converter_index_entry_keys_formatting (self);
+            /* this can happen if indices are sorted more than once */
+            if (self->convert_index_text_options)
+              destroy_text_options (self->convert_index_text_options);
+            self->convert_index_text_options = text_options;
+          }
+        else
+          {
+            DOCUMENT *document;
+            document = get_sv_document_document (customization_info_sv,
+                         "setup_index_entry_keys_formatting");
+            if (document && document->options)
+              {
+                TEXT_OPTIONS *text_options
+                 = setup_index_entry_keys_formatting (document->options);
+                register_document_convert_index_text_options (document,
+                                                           text_options);
+              }
+          }
+        hv = newHV ();
+        RETVAL = newRV_noinc ((SV *) hv);
+    OUTPUT:
+         RETVAL
+
+SV *
+index_entry_element_sort_string (SV *customization_info_sv, SV *main_entry_sv, 
SV *element_sv, SV *options_sv, SV *prefer_reference_element_sv=0)
+    PREINIT:
+        CONVERTER *self;
+        DOCUMENT *document;
+        char *sort_string = 0;
+        TEXT_OPTIONS *convert_index_text_options = 0;
+     CODE:
+        self = get_sv_converter (customization_info_sv, 0);
+        if (self)
+          {
+            document = self->document;
+            convert_index_text_options = self->convert_index_text_options;
+          }
+        else
+          {
+            document = get_sv_document_document (customization_info_sv,
+                     "index_entry_element_sort_string");
+            if (document)
+              convert_index_text_options
+                = document->convert_index_text_options;
+          }
+        if (document)
+          {
+            const INDEX *entry_idx = 0;
+            int entry_number;
+            int prefer_reference_element = 0;
+            int in_code;
+            int allocated_text_options = 0;
+            ELEMENT *element = find_element_from_sv (0, document,
+                                                    element_sv, 0);
+            INDEX_ENTRY *main_entry = find_index_entry_sv (main_entry_sv,
+                                          document->index_names, 0,
+                                          &entry_idx, &entry_number);
+            in_code = entry_idx->in_code;
+
+            /* should not be possible */
+            if (!convert_index_text_options)
+              {
+                allocated_text_options = 1;
+                convert_index_text_options
+                  = copy_sv_options_for_convert_text (options_sv);
+              }
+
+            if (prefer_reference_element_sv && SvOK 
(prefer_reference_element_sv))
+              prefer_reference_element = SvIV (prefer_reference_element_sv);
+
+            sort_string = index_entry_element_sort_string (main_entry,
+                          element, convert_index_text_options, in_code,
+                          prefer_reference_element);
+            if (allocated_text_options)
+              destroy_text_options (convert_index_text_options);
+          }
+
+       if (!sort_string)
+         RETVAL = newSV (0);
+       else
+         {
+           RETVAL = newSVpv_utf8 (sort_string, 0);
+           free (sort_string);
+         }
+    OUTPUT:
+         RETVAL
+
diff --git a/tp/Texinfo/XS/structuring_transfo/StructuringTransfoXS.xs 
b/tp/Texinfo/XS/structuring_transfo/StructuringTransfoXS.xs
index ea44ea5daa..ec1d58410a 100644
--- a/tp/Texinfo/XS/structuring_transfo/StructuringTransfoXS.xs
+++ b/tp/Texinfo/XS/structuring_transfo/StructuringTransfoXS.xs
@@ -40,7 +40,6 @@
 #include "transformations.h"
 #include "structuring.h"
 #include "output_unit.h"
-#include "indices_in_conversion.h"
 #include "get_perl_info.h"
 #include "build_perl_info.h"
 
@@ -426,110 +425,3 @@ split_pages (SV *output_units_in, char *split)
         if (output_units)
           split_pages (output_units, split);
 
-# This function triggers setting the information needed for calls
-# to index_entry_element_sort_string in C, either in a document
-# or in a converter, depending whether index sorting is done with a converter
-# or without.
-# A returned hash reference is needed as some information is set in the
-# hash in perl afterwards, but this information is not used as the hash
-# is not used by any function not overriden, so there is no need to
-# return information corresponding to the text options for perl.  An empty
-# hash reference is therefore returned.
-SV *
-setup_index_entry_keys_formatting (SV *customization_info_sv)
-    PREINIT:
-        CONVERTER *self;
-        HV *hv;
-     CODE:
-        self = get_sv_converter (customization_info_sv, 0);
-        if (self)
-          {
-            TEXT_OPTIONS *text_options
-              = setup_converter_index_entry_keys_formatting (self);
-            /* this can happen if indices are sorted more than once */
-            if (self->convert_index_text_options)
-              destroy_text_options (self->convert_index_text_options);
-            self->convert_index_text_options = text_options;
-          }
-        else
-          {
-            DOCUMENT *document;
-            document = get_sv_document_document (customization_info_sv,
-                         "setup_index_entry_keys_formatting");
-            if (document && document->options)
-              {
-                TEXT_OPTIONS *text_options
-                 = setup_index_entry_keys_formatting (document->options);
-                register_document_convert_index_text_options (document,
-                                                           text_options);
-              }
-          }
-        hv = newHV ();
-        RETVAL = newRV_noinc ((SV *) hv);
-    OUTPUT:
-         RETVAL
-
-SV *
-index_entry_element_sort_string (SV *customization_info_sv, SV *main_entry_sv, 
SV *element_sv, SV *options_sv, SV *prefer_reference_element_sv=0)
-    PREINIT:
-        CONVERTER *self;
-        DOCUMENT *document;
-        char *sort_string = 0;
-        TEXT_OPTIONS *convert_index_text_options = 0;
-     CODE:
-        self = get_sv_converter (customization_info_sv, 0);
-        if (self)
-          {
-            document = self->document;
-            convert_index_text_options = self->convert_index_text_options;
-          }
-        else
-          {
-            document = get_sv_document_document (customization_info_sv,
-                     "index_entry_element_sort_string");
-            if (document)
-              convert_index_text_options
-                = document->convert_index_text_options;
-          }
-        if (document)
-          {
-            const INDEX *entry_idx = 0;
-            int entry_number;
-            int prefer_reference_element = 0;
-            int in_code;
-            int allocated_text_options = 0;
-            ELEMENT *element = find_element_from_sv (0, document,
-                                                    element_sv, 0);
-            INDEX_ENTRY *main_entry = find_index_entry_sv (main_entry_sv,
-                                          document->index_names, 0,
-                                          &entry_idx, &entry_number);
-            in_code = entry_idx->in_code;
-
-            /* should not be possible */
-            if (!convert_index_text_options)
-              {
-                allocated_text_options = 1;
-                convert_index_text_options
-                  = copy_sv_options_for_convert_text (options_sv);
-              }
-
-            if (prefer_reference_element_sv && SvOK 
(prefer_reference_element_sv))
-              prefer_reference_element = SvIV (prefer_reference_element_sv);
-
-            sort_string = index_entry_element_sort_string (main_entry,
-                          element, convert_index_text_options, in_code,
-                          prefer_reference_element);
-            if (allocated_text_options)
-              destroy_text_options (convert_index_text_options);
-          }
-
-       if (!sort_string)
-         RETVAL = newSV (0);
-       else
-         {
-           RETVAL = newSVpv_utf8 (sort_string, 0);
-           free (sort_string);
-         }
-    OUTPUT:
-         RETVAL
-



reply via email to

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