[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Sun, 26 Nov 2023 10:40:44 -0500 (EST) |
branch: master
commit 8421b06374a7085893e24ae8029eb155d58855cc
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Nov 26 16:12:22 2023 +0100
* tp/Texinfo/XS/main/DocumentXS.xs (gdt): move from TranslationsXS to
DocumentXS. Remove TranslationsXS.pm and TranslationsXS.xs.
* tp/Texinfo/XSLoader.pm (init): update message.
---
ChangeLog | 7 +++
tp/TODO | 4 --
tp/Texinfo/Translations.pm | 2 +-
tp/Texinfo/TranslationsXS.pm | 44 --------------
tp/Texinfo/XS/Makefile.am | 20 -------
tp/Texinfo/XS/main/DocumentXS.xs | 77 ++++++++++++++++++++++++
tp/Texinfo/XS/main/TranslationsXS.xs | 110 -----------------------------------
tp/Texinfo/XSLoader.pm | 2 +-
8 files changed, 86 insertions(+), 180 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 978f64ce6d..b293cf2c68 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2023-11-26 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/XS/main/DocumentXS.xs (gdt): move from TranslationsXS to
+ DocumentXS. Remove TranslationsXS.pm and TranslationsXS.xs.
+
+ * tp/Texinfo/XSLoader.pm (init): update message.
+
2023-11-26 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XS/main/utils.c (section_level),
diff --git a/tp/TODO b/tp/TODO
index ca89c3b994..414f6c61c3 100644
--- a/tp/TODO
+++ b/tp/TODO
@@ -41,10 +41,6 @@ does not work perfectly with XS. See FIXME in the code.
Tested in
./manual_tests/manual_sectioning_gap_test.sh
Not a priority.
-Use a union for extra/info information instead of coercing a pointer?
-
-Use ELEMENT_LIST for extra_contents extra_directions?
-
Bugs
====
diff --git a/tp/Texinfo/Translations.pm b/tp/Texinfo/Translations.pm
index f9329499c0..4ed1f8df51 100644
--- a/tp/Texinfo/Translations.pm
+++ b/tp/Texinfo/Translations.pm
@@ -58,7 +58,7 @@ sub import {
# general.
#Texinfo::XSLoader::override(
# "Texinfo::Translations::gdt",
- # "Texinfo::TranslationsXS::gdt");
+ # "Texinfo::DocumentXS::gdt");
$module_loaded = 1;
}
# The usual import method
diff --git a/tp/Texinfo/TranslationsXS.pm b/tp/Texinfo/TranslationsXS.pm
deleted file mode 100644
index e380243d50..0000000000
--- a/tp/Texinfo/TranslationsXS.pm
+++ /dev/null
@@ -1,44 +0,0 @@
-# TranslationsXS.pm: load string document related XS functions.
-#
-# Copyright 2010-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/>.
-
-# currently unused
-
-package Texinfo::TranslationXS;
-
-use strict;
-use warnings;
-
-our $VERSION = '7.1dev';
-
-use Texinfo::XSLoader;
-
-BEGIN {
- our $warning_message = undef;
- our $fatal_message = undef;
-
- my $package = Texinfo::XSLoader::init (
- "Texinfo::TranslationsXS",
- "Texinfo::TranslationsXS",
- "TranslationsXS",
- undef,
- 0,
- $warning_message,
- $fatal_message
- );
-}
-
-1;
diff --git a/tp/Texinfo/XS/Makefile.am b/tp/Texinfo/XS/Makefile.am
index 75c653467f..c93d960249 100644
--- a/tp/Texinfo/XS/Makefile.am
+++ b/tp/Texinfo/XS/Makefile.am
@@ -325,26 +325,6 @@ DocumentXS_la_CFLAGS = $(XSLIBS_CFLAGS)
DocumentXS_la_LIBADD = libtexinfoxs.la libtexinfo.la
DocumentXS_la_LDFLAGS = $(XSLIBS_LDFLAGS)
-########################## Translations XS
-
-# Not used for now as replaced_substrings
-# perl element tree cannot be retrieved in C stored documents.
-
-#if HAVE_ICONV
-#xs_LTLIBRARIES += TranslationsXS.la
-#endif
-#
-#TranslationsXS_la_SOURCES = \
-# main/TranslationsXS.c
-#
-#EXTRA_DIST += main/TranslationsXS.xs
-#
-## locate include files under out-of-source builds.
-#TranslationsXS_la_CPPFLAGS = -I$(srcdir)/main $(AM_CPPFLAGS)
$(XSLIBS_CPPFLAGS)
-#TranslationsXS_la_CFLAGS = $(XSLIBS_CFLAGS)
-#TranslationsXS_la_LIBADD = libtexinfoxs.la libtexinfo.la
-#TranslationsXS_la_LDFLAGS = $(XSLIBS_LDFLAGS)
-
########################## StructuringTransfo XS
if HAVE_ICONV
diff --git a/tp/Texinfo/XS/main/DocumentXS.xs b/tp/Texinfo/XS/main/DocumentXS.xs
index ad5c087862..37c15e7434 100644
--- a/tp/Texinfo/XS/main/DocumentXS.xs
+++ b/tp/Texinfo/XS/main/DocumentXS.xs
@@ -38,6 +38,7 @@
#include "get_perl_info.h"
#include "build_perl_info.h"
+
MODULE = Texinfo::DocumentXS PACKAGE = Texinfo::DocumentXS
PROTOTYPES: ENABLE
@@ -175,3 +176,79 @@ set_document_options (SV *sv_options_in, SV *document_in)
register_document_options (document, options);
}
+# Next correspond to misc XS interfaces that have no associated
+# .xs file.
+
+
+# Next one is unused, kept as documentation only, as the code is
+# ok, but the approach is flawed as the trees in replaced_substrings
+# do not exist in XS/C data.
+
+# TODO not sure that the options_in argument is good to be
+# copy_sv_options argument, may need to retrieve a converter
+# first or Parser configuration. Does not matter much as
+# the approach does not work because replaced_substrings
+# perl element tree cannot be retrieved in C stored documents.
+# optional:
+# replaced_substrings, translation_context, lang
+SV *
+gdt (SV *options_in, string, ...)
+ char *string = (char *)SvPVutf8_nolen($arg);
+ PROTOTYPE: $$;$$$
+ PREINIT:
+ char *translation_context = 0;
+ char *in_lang = 0;
+ HV *hv_replaced_substrings = 0;
+ NAMED_STRING_ELEMENT_LIST *replaced_substrings = 0;
+ OPTIONS *options = 0;
+ HV *result_tree;
+ int gdt_document_descriptor;
+ DOCUMENT *gdt_document;
+ CODE:
+ if (SvOK(options_in))
+ {
+ options = copy_sv_options (options_in);
+ }
+ if (items > 4 && SvOK(ST(4)))
+ in_lang = (char *)SvPVutf8_nolen(ST(4));
+ if (items > 3 && SvOK(ST(3)))
+ translation_context = (char *)SvPVutf8_nolen(ST(3));
+ if (items > 2 && SvOK(ST(2)))
+ {
+ /* TODO put in get_perl_info.h */
+ I32 hv_number;
+ I32 i;
+ hv_replaced_substrings = (HV *)SvRV (ST(1));
+ hv_number = hv_iterinit (hv_replaced_substrings);
+ if (hv_number > 0)
+ replaced_substrings = new_named_string_element_list ();
+ for (i = 0; i < hv_number; i++)
+ {
+ char *key;
+ I32 retlen;
+ SV *value = hv_iternextsv(hv_replaced_substrings,
+ &key, &retlen);
+ DOCUMENT *document = get_sv_tree_document (value, 0);
+ /* TODO should warn/error if not found or return
+ a list of missing string identifiers? Or check
+ in caller? In any case, it cannot be good to
+ ignore a replaced substring */
+ if (document && document->tree)
+ add_element_to_named_string_element_list (
+ replaced_substrings, key, document->tree);
+ }
+ }
+
+ gdt_document_descriptor
+ = gdt (string, options, replaced_substrings,
+ translation_context, in_lang);
+ gdt_document = retrieve_document (gdt_document_descriptor);
+ result_tree = build_texinfo_tree (gdt_document->tree);
+ hv_store (result_tree, "tree_document_descriptor",
+ strlen ("tree_document_descriptor"),
+ newSViv ((IV) gdt_document_descriptor), 0);
+ RETVAL = newRV_inc ((SV *) result_tree);
+ OUTPUT:
+ RETVAL
+
+
diff --git a/tp/Texinfo/XS/main/TranslationsXS.xs
b/tp/Texinfo/XS/main/TranslationsXS.xs
deleted file mode 100644
index c74c87ed0d..0000000000
--- a/tp/Texinfo/XS/main/TranslationsXS.xs
+++ /dev/null
@@ -1,110 +0,0 @@
-/* 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 "options_types.h"
-#include "document.h"
-#include "build_perl_info.h"
-#include "get_perl_info.h"
-#include "translations.h"
-
-MODULE = Texinfo::TranslationsXS PACKAGE = Texinfo::TranslationsXS
-
-PROTOTYPES: ENABLE
-
-# TODO not sure that the options_in argument is good to be
-# copy_sv_options argument, may need to retrieve a converter
-# first or Parser configuration. Does not matter much as
-# the approach does not work because replaced_substrings
-# perl element tree cannot be retrieved in C stored documents.
-# optional:
-# replaced_substrings, translation_context, lang
-SV *
-gdt (SV *options_in, string, ...)
- char *string = (char *)SvPVutf8_nolen($arg);
- PROTOTYPE: $$;$$$
- PREINIT:
- char *translation_context = 0;
- char *in_lang = 0;
- HV *hv_replaced_substrings = 0;
- NAMED_STRING_ELEMENT_LIST *replaced_substrings = 0;
- OPTIONS *options = 0;
- HV *result_tree;
- int gdt_document_descriptor;
- DOCUMENT *gdt_document;
- CODE:
- if (SvOK(options_in))
- {
- options = copy_sv_options (options_in);
- }
- if (items > 4 && SvOK(ST(4)))
- in_lang = (char *)SvPVutf8_nolen(ST(4));
- if (items > 3 && SvOK(ST(3)))
- translation_context = (char *)SvPVutf8_nolen(ST(3));
- if (items > 2 && SvOK(ST(2)))
- {
- /* TODO put in get_perl_info.h */
- I32 hv_number;
- I32 i;
- hv_replaced_substrings = (HV *)SvRV (ST(1));
- hv_number = hv_iterinit (hv_replaced_substrings);
- if (hv_number > 0)
- replaced_substrings = new_named_string_element_list ();
- for (i = 0; i < hv_number; i++)
- {
- char *key;
- I32 retlen;
- SV *value = hv_iternextsv(hv_replaced_substrings,
- &key, &retlen);
- DOCUMENT *document = get_sv_tree_document (value, 0);
- /* TODO should warn/error if not found or return
- a list of missing string identifiers? Or check
- in caller? In any case, it cannot be good to
- ignore a replaced substring */
- if (document && document->tree)
- add_element_to_named_string_element_list (
- replaced_substrings, key, document->tree);
- }
- }
-
- gdt_document_descriptor
- = gdt (string, options, replaced_substrings,
- translation_context, in_lang);
- gdt_document = retrieve_document (gdt_document_descriptor);
- result_tree = build_texinfo_tree (gdt_document->tree);
- hv_store (result_tree, "tree_document_descriptor",
- strlen ("tree_document_descriptor"),
- newSViv ((IV) gdt_document_descriptor), 0);
- RETVAL = newRV_inc ((SV *) result_tree);
- OUTPUT:
- RETVAL
-
-
diff --git a/tp/Texinfo/XSLoader.pm b/tp/Texinfo/XSLoader.pm
index 31f15d773d..9a1b722751 100644
--- a/tp/Texinfo/XSLoader.pm
+++ b/tp/Texinfo/XSLoader.pm
@@ -226,7 +226,7 @@ sub init {
FALLBACK:
if ($TEXINFO_XS eq 'required') {
- die "unset the TEXINFO_XS environment variable to use the "
+ die "set the TEXINFO_XS environment variable to 'omit' to use the "
."pure Perl modules\n";
} elsif ($TEXINFO_XS eq 'warn' or $TEXINFO_XS eq 'debug') {
if (defined($fallback_module)) {