[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/XS/Makefile.am (libtexinfoxs_la_SOUR
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/XS/Makefile.am (libtexinfoxs_la_SOURCES), (main/api_to_perl.c, main/api_to_perl.h) (tp/Texinfo/XS/main/build_perl_info.c): rename main/tree_perl_api.h as main/api_to_perl.h and move corresponding code from main/build_perl_info.c to main/api_to_perl.c, newly created. |
Date: |
Sat, 28 Oct 2023 09:36:59 -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 e8dffa7ccb * tp/Texinfo/XS/Makefile.am (libtexinfoxs_la_SOURCES),
(main/api_to_perl.c, main/api_to_perl.h)
(tp/Texinfo/XS/main/build_perl_info.c): rename main/tree_perl_api.h as
main/api_to_perl.h and move corresponding code from main/build_perl_info.c to
main/api_to_perl.c, newly created.
e8dffa7ccb is described below
commit e8dffa7ccb18577e9aeb01b043beca7868914177
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Oct 28 15:37:01 2023 +0200
* tp/Texinfo/XS/Makefile.am (libtexinfoxs_la_SOURCES),
(main/api_to_perl.c, main/api_to_perl.h)
(tp/Texinfo/XS/main/build_perl_info.c): rename main/tree_perl_api.h as
main/api_to_perl.h and move corresponding code from
main/build_perl_info.c to main/api_to_perl.c, newly created.
* main/api_to_perl.c (call_sync_locale, call_switch_to_global_locale)
tp/Texinfo/XS/main/translations.c (translate_string),
tp/tests/many_input_files/different_languages_gen_master_menu.sh
(LC_ALL), tp/tests/run_parser_all.sh b/tp/tests/run_parser_all.sh
(LC_ALL): call switch_to_global_locale and sync_locale to fix C locale
not being translated, it is required in XS code that calls setlocale.
Analysis and solution from Gavin.
---
ChangeLog | 16 ++++++
tp/TODO | 3 --
tp/Texinfo/XS/Makefile.am | 3 +-
tp/Texinfo/XS/convert/convert_html.c | 1 -
tp/Texinfo/XS/main/api_to_perl.c | 63 ++++++++++++++++++++++
tp/Texinfo/XS/main/build_perl_info.c | 15 ------
tp/Texinfo/XS/main/node_name_normalization.c | 2 +-
tp/Texinfo/XS/main/translations.c | 8 +++
tp/Texinfo/XS/main/tree.c | 2 +-
tp/Texinfo/XS/main/tree_perl_api.h | 10 ----
.../verbatiminclude_names_latin1.2 | 8 +--
.../verbatiminclude_names_latin1.2 | 4 +-
.../different_languages_gen_master_menu.sh | 4 +-
tp/tests/run_parser_all.sh | 4 +-
14 files changed, 99 insertions(+), 44 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index d083e04488..3633cdab54 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2023-10-28 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/XS/Makefile.am (libtexinfoxs_la_SOURCES),
+ (main/api_to_perl.c, main/api_to_perl.h)
+ (tp/Texinfo/XS/main/build_perl_info.c): rename main/tree_perl_api.h as
+ main/api_to_perl.h and move corresponding code from
+ main/build_perl_info.c to main/api_to_perl.c, newly created.
+
+ * main/api_to_perl.c (call_sync_locale, call_switch_to_global_locale)
+ tp/Texinfo/XS/main/translations.c (translate_string),
+ tp/tests/many_input_files/different_languages_gen_master_menu.sh
+ (LC_ALL), tp/tests/run_parser_all.sh b/tp/tests/run_parser_all.sh
+ (LC_ALL): call switch_to_global_locale and sync_locale to fix C locale
+ not being translated, it is required in XS code that calls setlocale.
+ Analysis and solution from Gavin.
+
2023-10-28 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XS/Makefile.am (libtexinfoxs_la_SOURCES),
diff --git a/tp/TODO b/tp/TODO
index 50e4332a9a..e8dbab44e0 100644
--- a/tp/TODO
+++ b/tp/TODO
@@ -13,9 +13,6 @@ Before next release
check $(native_tools) variable in Makefile.am does not seems to be
set and seems useless.
-Find a workaround to be able to change the locale for gettext in C for
-in-document strings, even if the locale is C/POSIX.
-
Check format_translate_message_tree api after the changes in gdt api
when the translation of HTML to C is advnaced enough that it becomes clear
that the API won't change again.
diff --git a/tp/Texinfo/XS/Makefile.am b/tp/Texinfo/XS/Makefile.am
index dd9ae71fe4..7570731922 100644
--- a/tp/Texinfo/XS/Makefile.am
+++ b/tp/Texinfo/XS/Makefile.am
@@ -282,7 +282,8 @@ lib_LTLIBRARIES += libtexinfoxs.la
endif
libtexinfoxs_la_SOURCES= \
- main/tree_perl_api.h \
+ main/api_to_perl.c \
+ main/api_to_perl.h \
main/build_perl_info.c \
main/build_perl_info.h \
main/get_perl_info.c \
diff --git a/tp/Texinfo/XS/convert/convert_html.c
b/tp/Texinfo/XS/convert/convert_html.c
index 657a1072c6..38fc012a28 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -28,7 +28,6 @@
#include "targets.h"
#include "debug.h"
#include "output_unit.h"
-#include "tree_perl_api.h"
#include "converter.h"
#include "node_name_normalization.h"
#include "indices_in_conversion.h"
diff --git a/tp/Texinfo/XS/main/api_to_perl.c b/tp/Texinfo/XS/main/api_to_perl.c
new file mode 100644
index 0000000000..76525ab22b
--- /dev/null
+++ b/tp/Texinfo/XS/main/api_to_perl.c
@@ -0,0 +1,63 @@
+/* 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/>. */
+
+#include <config.h>
+
+/* Avoid namespace conflicts. */
+#define context perl_context
+
+#define PERL_NO_GET_CONTEXT
+#include "EXTERN.h"
+#include "perl.h"
+/* Avoid warnings about Perl headers redefining symbols that gnulib
+ redefined already. */
+#if defined _WIN32 && !defined __CYGWIN__
+ #undef free
+#endif
+#include "XSUB.h"
+
+#undef context
+
+#include "tree_types.h"
+
+/* to be called when a tree element is destroyed, to remove the reference
+ of the association with the C tree */
+void
+unregister_perl_tree_element (ELEMENT *e)
+{
+ dTHX;
+
+ if (e->hv)
+ {
+ SvREFCNT_dec ((SV *) e->hv);
+ e->hv = 0;
+ }
+}
+
+void
+call_switch_to_global_locale ()
+{
+ dTHX;
+
+ switch_to_global_locale ();
+}
+
+void
+call_sync_locale ()
+{
+ dTHX;
+
+ sync_locale ();
+}
diff --git a/tp/Texinfo/XS/main/build_perl_info.c
b/tp/Texinfo/XS/main/build_perl_info.c
index 3bdf4ceab9..6acee63570 100644
--- a/tp/Texinfo/XS/main/build_perl_info.c
+++ b/tp/Texinfo/XS/main/build_perl_info.c
@@ -50,7 +50,6 @@
#include "output_unit.h"
/* for wipe_error_message_list */
#include "errors.h"
-#include "tree_perl_api.h"
#include "command_stack.h"
#include "build_perl_info.h"
@@ -94,20 +93,6 @@ init (int texinfo_uninstalled, char *builddir)
static void element_to_perl_hash (ELEMENT *e);
-/* to be called when a tree element is destroyed, to remove the reference
- of the association with the C tree */
-void
-unregister_perl_tree_element (ELEMENT *e)
-{
- dTHX;
-
- if (e->hv)
- {
- SvREFCNT_dec ((SV *) e->hv);
- e->hv = 0;
- }
-}
-
/* Return reference to Perl array built from e. If any of
the elements in E don't have 'hv' set, set it to an empty
hash table, or create it if there is no parent element, indicating the
diff --git a/tp/Texinfo/XS/main/node_name_normalization.c
b/tp/Texinfo/XS/main/node_name_normalization.c
index 92b9d5b743..11462e59e7 100644
--- a/tp/Texinfo/XS/main/node_name_normalization.c
+++ b/tp/Texinfo/XS/main/node_name_normalization.c
@@ -37,7 +37,7 @@
#include "extra.h"
#include "builtin_commands.h"
#include "debug.h"
-#include "tree_perl_api.h"
+#include "call_perl_function.h"
#include "unicode.h"
#include "node_name_normalization.h"
diff --git a/tp/Texinfo/XS/main/translations.c
b/tp/Texinfo/XS/main/translations.c
index 32723a95db..3299712d14 100644
--- a/tp/Texinfo/XS/main/translations.c
+++ b/tp/Texinfo/XS/main/translations.c
@@ -39,6 +39,7 @@
#include "api.h"
#include "document.h"
#include "convert_to_texinfo.h"
+#include "api_to_perl.h"
#include "translations.h"
/*
@@ -179,6 +180,11 @@ translate_string (OPTIONS *options, char * string,
#else
+ /* if a code calls setlocale and accesses global locale while perl
+ uses per thread locale, the result is unpredictable. So we switch to
+ global locales as we use setlocale */
+ call_switch_to_global_locale ();
+
/*
We need to set LC_MESSAGES to a valid locale other than "C" or "POSIX"
for translation via LANGUAGE to work. (The locale is "C" if the
@@ -358,6 +364,8 @@ translate_string (OPTIONS *options, char * string,
#endif
+ call_sync_locale ();
+
#endif
return translated_string;
diff --git a/tp/Texinfo/XS/main/tree.c b/tp/Texinfo/XS/main/tree.c
index 42ca334051..ed7f495a7f 100644
--- a/tp/Texinfo/XS/main/tree.c
+++ b/tp/Texinfo/XS/main/tree.c
@@ -48,7 +48,7 @@ static int *obs_element_first = 0;
/* for debug
#include "debug.h"
*/
-#include "tree_perl_api.h"
+#include "api_to_perl.h"
#include "tree.h"
/* Used with destroy_element to reuse storage, e.g. from
diff --git a/tp/Texinfo/XS/main/tree_perl_api.h
b/tp/Texinfo/XS/main/tree_perl_api.h
deleted file mode 100644
index c59744130c..0000000000
--- a/tp/Texinfo/XS/main/tree_perl_api.h
+++ /dev/null
@@ -1,10 +0,0 @@
-/* tree_perl_api.h - API to interact with perl from C code */
-#ifndef TREE_PERL_API_H
-#define TREE_PERL_API_H
-
-#include "tree_types.h"
-
-/* in build_perl_info */
-void unregister_perl_tree_element (ELEMENT *e);
-
-#endif
diff --git
a/tp/tests/encoded/res_parser/verbatiminclude_names_latin1_html/verbatiminclude_names_latin1.2
b/tp/tests/encoded/res_parser/verbatiminclude_names_latin1_html/verbatiminclude_names_latin1.2
index 81466777d5..46e75d054c 100644
---
a/tp/tests/encoded/res_parser/verbatiminclude_names_latin1_html/verbatiminclude_names_latin1.2
+++
b/tp/tests/encoded/res_parser/verbatiminclude_names_latin1_html/verbatiminclude_names_latin1.2
@@ -1,4 +1,4 @@
-verbatiminclude_names_latin1.texi:6: @verbatiminclude: could not find
included_akçentêd.texi
-verbatiminclude_names_latin1.texi:8: @verbatiminclude: could not find
vi_not_existïng.téxi
-verbatiminclude_names_latin1.texi:18: @verbatiminclude: could not find
included_akçentêd.texi
-verbatiminclude_names_latin1.texi:20: @verbatiminclude: could not find
vi_not_existïng.téxi
+verbatiminclude_names_latin1.texi:6: @verbatiminclude: could not find
included_ak?ent?d.texi
+verbatiminclude_names_latin1.texi:8: @verbatiminclude: could not find
vi_not_exist?ng.t?xi
+verbatiminclude_names_latin1.texi:18: @verbatiminclude: could not find
included_ak?ent?d.texi
+verbatiminclude_names_latin1.texi:20: @verbatiminclude: could not find
vi_not_exist?ng.t?xi
diff --git
a/tp/tests/encoded/res_parser/verbatiminclude_names_latin1_html_explicit_encoding/verbatiminclude_names_latin1.2
b/tp/tests/encoded/res_parser/verbatiminclude_names_latin1_html_explicit_encoding/verbatiminclude_names_latin1.2
index 9caef1067f..c162bd5eff 100644
---
a/tp/tests/encoded/res_parser/verbatiminclude_names_latin1_html_explicit_encoding/verbatiminclude_names_latin1.2
+++
b/tp/tests/encoded/res_parser/verbatiminclude_names_latin1_html_explicit_encoding/verbatiminclude_names_latin1.2
@@ -1,2 +1,2 @@
-verbatiminclude_names_latin1.texi:8: @verbatiminclude: could not find
vi_not_existïng.téxi
-verbatiminclude_names_latin1.texi:20: @verbatiminclude: could not find
vi_not_existïng.téxi
+verbatiminclude_names_latin1.texi:8: @verbatiminclude: could not find
vi_not_exist?ng.t?xi
+verbatiminclude_names_latin1.texi:20: @verbatiminclude: could not find
vi_not_exist?ng.t?xi
diff --git a/tp/tests/many_input_files/different_languages_gen_master_menu.sh
b/tp/tests/many_input_files/different_languages_gen_master_menu.sh
index a45dccdec8..216c2a4f25 100755
--- a/tp/tests/many_input_files/different_languages_gen_master_menu.sh
+++ b/tp/tests/many_input_files/different_languages_gen_master_menu.sh
@@ -12,9 +12,7 @@
#
# Originally written by Patrice Dumas.
-#LC_ALL=C; export LC_ALL
-# Temporary to have translations of messages in document with XS code
-LC_ALL=en_US.utf-8; export LC_ALL
+LC_ALL=C; export LC_ALL
basename=different_languages_gen_master_menu
diffs_dir=diffs
diff --git a/tp/tests/run_parser_all.sh b/tp/tests/run_parser_all.sh
index 530e65fafa..d7061562b6 100755
--- a/tp/tests/run_parser_all.sh
+++ b/tp/tests/run_parser_all.sh
@@ -167,9 +167,7 @@ post_process_output ()
fi
}
-#LC_ALL=C; export LC_ALL
-# Temporary to have translations of messages in document with XS code
-LC_ALL=en_US.utf-8; export LC_ALL
+LC_ALL=C; export LC_ALL
LANGUAGE=en; export LANGUAGE
prepended_command=
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/XS/Makefile.am (libtexinfoxs_la_SOURCES), (main/api_to_perl.c, main/api_to_perl.h) (tp/Texinfo/XS/main/build_perl_info.c): rename main/tree_perl_api.h as main/api_to_perl.h and move corresponding code from main/build_perl_info.c to main/api_to_perl.c, newly created.,
Patrice Dumas <=
- Prev by Date:
branch master updated: * tp/Texinfo/XS/Makefile.am (libtexinfoxs_la_SOURCES), tp/Texinfo/XS/main/call_perl_function.h: add call_perl_function.h file for a more common code, also given that these functions should probably only called from the HTML converter.
- Next by Date:
branch master updated: * tp/Texinfo/XS/convert/convert_html.c (convert_to_html_internal), tp/Texinfo/XS/main/element_types.txt (text): add a virtual element type for all the elements holding text, and use it for the selection of the conversion function, similar to perl code.
- Previous by thread:
branch master updated: * tp/Texinfo/XS/Makefile.am (libtexinfoxs_la_SOURCES), tp/Texinfo/XS/main/call_perl_function.h: add call_perl_function.h file for a more common code, also given that these functions should probably only called from the HTML converter.
- Next by thread:
branch master updated: * tp/Texinfo/XS/convert/convert_html.c (convert_to_html_internal), tp/Texinfo/XS/main/element_types.txt (text): add a virtual element type for all the elements holding text, and use it for the selection of the conversion function, similar to perl code.
- Index(es):