[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/XS/convert/texinfo.c (txi_general_se
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/XS/convert/texinfo.c (txi_general_setup), tp/Texinfo/XS/teximakehtml.c (main): do not get locales directory for output strings domain from argument, determine it as in texi2any.pl. |
Date: |
Wed, 27 Nov 2024 14:07:05 -0500 |
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 98fb043b2c * tp/Texinfo/XS/convert/texinfo.c (txi_general_setup),
tp/Texinfo/XS/teximakehtml.c (main): do not get locales directory for output
strings domain from argument, determine it as in texi2any.pl.
98fb043b2c is described below
commit 98fb043b2c7f62617bb224794744d6b1746c586a
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Wed Nov 27 20:06:51 2024 +0100
* tp/Texinfo/XS/convert/texinfo.c (txi_general_setup),
tp/Texinfo/XS/teximakehtml.c (main): do not get locales directory for
output strings domain from argument, determine it as in texi2any.pl.
* tp/Texinfo/XS/teximakehtml.c (enum teximakehtml_mode)
(demo_parser_EXPANDED_FORMATS, main): consider 4 run modes, default to
mimick texi2any, test corresponding to TEST set, but no mimicking of
texi2any, 'mimick test' with both TEST set and mimicking of texi2any
and demo. Add command-line options to set the different modes.
* tp/Texinfo/XS/teximakehtml.c (main): set PACKAGE_* for tests run
modes as in texi2any.pl.
---
ChangeLog | 15 ++++++++
tp/Texinfo/XS/convert/texinfo.c | 32 ++++++++++++++---
tp/Texinfo/XS/convert/texinfo.h | 3 +-
tp/Texinfo/XS/main/translations.c | 2 +-
tp/Texinfo/XS/teximakehtml.c | 76 +++++++++++++++++++++++++++------------
5 files changed, 98 insertions(+), 30 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 28d8906993..80cd32462f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2024-11-27 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/XS/convert/texinfo.c (txi_general_setup),
+ tp/Texinfo/XS/teximakehtml.c (main): do not get locales directory for
+ output strings domain from argument, determine it as in texi2any.pl.
+
+ * tp/Texinfo/XS/teximakehtml.c (enum teximakehtml_mode)
+ (demo_parser_EXPANDED_FORMATS, main): consider 4 run modes, default to
+ mimick texi2any, test corresponding to TEST set, but no mimicking of
+ texi2any, 'mimick test' with both TEST set and mimicking of texi2any
+ and demo. Add command-line options to set the different modes.
+
+ * tp/Texinfo/XS/teximakehtml.c (main): set PACKAGE_* for tests run
+ modes as in texi2any.pl.
+
2024-11-26 Patrice Dumas <pertusus@free.fr>
* configure.ac (--enable-xs-perl-libintl), tp/Texinfo/XS/configure.ac
diff --git a/tp/Texinfo/XS/convert/texinfo.c b/tp/Texinfo/XS/convert/texinfo.c
index 88cf571753..276090fa6f 100644
--- a/tp/Texinfo/XS/convert/texinfo.c
+++ b/tp/Texinfo/XS/convert/texinfo.c
@@ -26,6 +26,7 @@
#include <stddef.h>
#include <string.h>
#include <stdio.h>
+#include <dirent.h>
#include "document_types.h"
#include "option_types.h"
@@ -46,14 +47,35 @@
/* initialization of the library for parsing and conversion (generic),
to be called once */
void
-txi_general_setup (const char *localesdir, int texinfo_uninstalled,
- const char *converterdatadir, const char *tp_builddir,
- const char *top_srcdir)
+txi_general_setup (int texinfo_uninstalled, const char *converterdatadir,
+ const char *tp_builddir, const char *top_srcdir)
{
+ char *locales_dir;
+
messages_and_encodings_setup ();
- if (localesdir)
- configure_output_strings_translations (localesdir, 0, -1);
+ /* code in texinfo.pl */
+ if (texinfo_uninstalled)
+ {
+ DIR *dir;
+
+ xasprintf (&locales_dir, "%s/LocaleData", tp_builddir);
+ dir = opendir (locales_dir);
+ if (dir)
+ {
+ closedir (dir);
+ configure_output_strings_translations (locales_dir, 0, -1);
+ }
+ else
+ fprintf (stderr, "Locales dir for document strings not found\n");
+ }
+ else
+ {
+ xasprintf (&locales_dir, "%s/locale", converterdatadir);
+ configure_output_strings_translations (locales_dir, 0, -1);
+ }
+
+ free (locales_dir);
converter_setup (texinfo_uninstalled, converterdatadir, tp_builddir,
top_srcdir);
diff --git a/tp/Texinfo/XS/convert/texinfo.h b/tp/Texinfo/XS/convert/texinfo.h
index 2fe4a11177..b98bef94ee 100644
--- a/tp/Texinfo/XS/convert/texinfo.h
+++ b/tp/Texinfo/XS/convert/texinfo.h
@@ -22,8 +22,7 @@
and regenerate_master_menu */
#define STTF_complete_menus_use_sections 0x0400
-/* locales dir for output strings translations */
-void txi_general_setup (const char *localesdir, int texinfo_uninstalled,
+void txi_general_setup (int texinfo_uninstalled,
const char *converterdatadir, const char *tp_builddir,
const char *top_srcdir);
diff --git a/tp/Texinfo/XS/main/translations.c
b/tp/Texinfo/XS/main/translations.c
index 79aa7bb38f..6748cdb612 100644
--- a/tp/Texinfo/XS/main/translations.c
+++ b/tp/Texinfo/XS/main/translations.c
@@ -62,7 +62,7 @@ static int use_external_translate_string;
/* USE_EXTERNAL_TRANSLATE_STRING_IN:
-1: never call external (Perl) translate string
- 0: default, use HAVE_USABLE_GETENV_IN_XS value
+ 0: default, use USE_LIBINTL_PERL_IN_XS value
1: always call external (Perl) translate string
*/
void
diff --git a/tp/Texinfo/XS/teximakehtml.c b/tp/Texinfo/XS/teximakehtml.c
index 837ed7c9e3..8f03f0a450 100644
--- a/tp/Texinfo/XS/teximakehtml.c
+++ b/tp/Texinfo/XS/teximakehtml.c
@@ -52,11 +52,26 @@ static char *parser_EXPANDED_FORMATS_array[] = {"html"};
static STRING_LIST parser_EXPANDED_FORMATS
= {parser_EXPANDED_FORMATS_array, 1, 1};
-/* in test mode, also expand @iftex for the sake of testing */
-static char *test_parser_EXPANDED_FORMATS_array[] = {"HTML", "tex"};
-static STRING_LIST test_parser_EXPANDED_FORMATS
- = {test_parser_EXPANDED_FORMATS_array, 2, 2};
+/* in demo mode, also expand @iftex for the sake of demonstration */
+static char *demo_parser_EXPANDED_FORMATS_array[] = {"HTML", "tex"};
+static STRING_LIST demo_parser_EXPANDED_FORMATS
+ = {demo_parser_EXPANDED_FORMATS_array, 2, 2};
+
+/* different modes for the program.
+ - default: mimick the Perl program (use same name/version)
+ - test: similar to setting TEST customization variable, try to
+ have a reproducible output, though without mimicking Perl
+ - mimick test: same as test, and in addition mimick the Perl program
+ - demo: with customization set in order to check that the output
+ is correct with exotic or even weird customizations
+ */
+enum teximakehtml_mode {
+ TEXIMAKEHTML_mode_default,
+ TEXIMAKEHTML_mode_test,
+ TEXIMAKEHTML_mode_mimick_test,
+ TEXIMAKEHTML_mode_demo,
+};
int
main (int argc, char *argv[])
@@ -85,14 +100,7 @@ main (int argc, char *argv[])
char *top_srcdir;
char *top_builddir;
char *tp_builddir = 0;
-
- /* there are two modes, depending on test value.
- - if test is set, the output is setup to test specific output
- options, use the true program name and try to generate
- reproducible output.
- - if test is unset, the program tries to mimic texi2any.
- */
- int test = 0;
+ enum teximakehtml_mode run_mode = TEXIMAKEHTML_mode_default;
/*
const char *texinfo_text;
@@ -114,14 +122,20 @@ main (int argc, char *argv[])
{
int option_character;
- option_character = getopt (argc, argv, "t");
+ option_character = getopt (argc, argv, "tmd");
if (option_character == -1)
break;
switch (option_character)
{
case 't':
- test = 1;
+ run_mode = TEXIMAKEHTML_mode_test;
+ break;
+ case 'm':
+ run_mode = TEXIMAKEHTML_mode_mimick_test;
+ break;
+ case 'd':
+ run_mode = TEXIMAKEHTML_mode_demo;
break;
/*
case '?':
@@ -134,7 +148,7 @@ main (int argc, char *argv[])
break;
*/
default:
- fprintf (stderr, "Usage: %s [-t] input_file\n", program_file);
+ fprintf (stderr, "Usage: %s [-t|-m|-d] input_file\n", program_file);
exit (EXIT_FAILURE);
}
}
@@ -183,7 +197,7 @@ main (int argc, char *argv[])
/* this is correct for in-source builds only. */
top_builddir = strdup (top_srcdir);
- txi_general_setup (LOCALEDIR, 1, 0, tp_builddir, top_srcdir);
+ txi_general_setup (1, 0, tp_builddir, top_srcdir);
free (tp_builddir);
free (top_srcdir);
@@ -205,10 +219,10 @@ main (int argc, char *argv[])
/*
add_option_value (&parser_options, "DEBUG", 1, 0);
*/
- if (test)
+ if (run_mode == TEXIMAKEHTML_mode_demo)
{
add_option_strlist_value (&parser_options, "EXPANDED_FORMATS",
- &test_parser_EXPANDED_FORMATS);
+ &demo_parser_EXPANDED_FORMATS);
}
else
{
@@ -261,7 +275,26 @@ main (int argc, char *argv[])
/* conversion initialization */
initialize_options_list (&convert_options);
- if (test)
+ if (run_mode == TEXIMAKEHTML_mode_test
+ || run_mode == TEXIMAKEHTML_mode_mimick_test)
+ {
+ /* this is set to help with comparison with previous invokations */
+ add_option_value (&convert_options, "TEST", 1, 0);
+
+ add_option_value (&convert_options, "PACKAGE_VERSION", 0, "");
+ add_option_value (&convert_options, "PACKAGE", 0, "texinfo");
+ add_option_value (&convert_options, "PACKAGE_NAME", 0, "GNU Texinfo");
+ add_option_value (&convert_options, "PACKAGE_AND_VERSION", 0,
+ "texinfo");
+ add_option_value (&convert_options, "PACKAGE_URL", 0,
+ "https://www.gnu.org/software/texinfo/");
+ add_option_value (&convert_options, "PROGRAM", 0, "texi2any");
+
+ /*
+ add_option_value (&convert_options, "DEBUG", 1, 0);
+ */
+ }
+ else if (run_mode == TEXIMAKEHTML_mode_demo)
{
/* customize buttons. It is a bit silly to use link buttons for
footer, it is for the demonstration */
@@ -269,10 +302,9 @@ main (int argc, char *argv[])
add_new_button_option (&convert_options,
"NODE_FOOTER_BUTTONS", custom_node_footer_buttons);
add_option_value (&convert_options, "PROGRAM_NAME_IN_FOOTER", 1, 0);
- /* this is set to help with comparison with previous invokations */
- add_option_value (&convert_options, "TEST", 1, 0);
}
- else
+
+ if (run_mode == TEXIMAKEHTML_mode_default)
{
/* mimics what is done in texi2any.pl, under the assumption that
teximakehtml output will be compared to calls of in-source
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/XS/convert/texinfo.c (txi_general_setup), tp/Texinfo/XS/teximakehtml.c (main): do not get locales directory for output strings domain from argument, determine it as in texi2any.pl.,
Patrice Dumas <=