texinfo-commits
[Top][All Lists]
Advanced

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

[no subject]


From: Patrice Dumas
Date: Sat, 19 Oct 2024 04:38:37 -0400 (EDT)

branch: master
commit 9d5447e3d26ab26ace4c0c5f498a5ae396bc9f17
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Oct 19 10:36:57 2024 +0200

    * tp/Texinfo/XS/convert/converter.c (converter_setup),
    tp/Texinfo/XS/main/document.c: inline txi_setup_lib_data in
    converter_setup.
    
    * tp/Texinfo/XS/main/utils.c (txi_base_setup),
    tp/Texinfo/XS/main/build_perl_info.c (init): move code related to
    messages gettext and encoding conversion iniitialization from
    build_perl_info.c init to the new init function in utils.c.
    
    * tp/Texinfo/XS/teximakehtml.c (main): call txi_base_setup.  Rearrange
    code.
---
 ChangeLog                            | 18 +++++++++++++++++
 tp/Texinfo/XS/convert/converter.c    |  6 +++++-
 tp/Texinfo/XS/main/build_perl_info.c | 30 ++--------------------------
 tp/Texinfo/XS/main/document.c        | 13 ------------
 tp/Texinfo/XS/main/document.h        |  3 ---
 tp/Texinfo/XS/main/utils.c           | 38 ++++++++++++++++++++++++++++++++++++
 tp/Texinfo/XS/main/utils.h           |  2 ++
 tp/Texinfo/XS/teximakehtml.c         | 28 ++++++++++----------------
 tp/texi2any.pl                       |  6 +++---
 9 files changed, 78 insertions(+), 66 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 0b5760bb61..fe9f075b26 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2024-10-19  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/convert/converter.c (converter_setup),
+       tp/Texinfo/XS/main/document.c: inline txi_setup_lib_data in
+       converter_setup.
+
+       * tp/Texinfo/XS/main/utils.c (txi_base_setup),
+       tp/Texinfo/XS/main/build_perl_info.c (init): move code related to
+       messages gettext and encoding conversion iniitialization from
+       build_perl_info.c init to the new init function in utils.c.
+
+       * tp/Texinfo/XS/teximakehtml.c (main): call txi_base_setup.  Rearrange
+       code.
+
+2024-10-19  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/texi2any.pl: comment out $pkgdatadir as it is not used anymore.
+
 2024-10-18  Gavin Smith <gavinsmith0123@gmail.com>
 
        * README-hacking: add note that gettext also needs to be upgraded
diff --git a/tp/Texinfo/XS/convert/converter.c 
b/tp/Texinfo/XS/convert/converter.c
index 35e96f3897..fcf4699804 100644
--- a/tp/Texinfo/XS/convert/converter.c
+++ b/tp/Texinfo/XS/convert/converter.c
@@ -147,11 +147,15 @@ converter_setup (int texinfo_uninstalled, const char 
*tp_builddir,
 {
   int i;
 
+  /* for now the following information is only used in converters, although
+     it may have been relevant at earlier steps */
   setup_converter_paths_information (texinfo_uninstalled,
                              converterdatadir, tp_builddir, top_srcdir);
 
-  txi_setup_lib_data ();
+  set_element_type_name_info ();
+  txi_initialise_base_options ();
 
+  /* conversion specific information */
   for (i = 0; i < BUILTIN_CMD_NUMBER; i++)
     {
       if (xml_text_entity_no_arg_commands[i])
diff --git a/tp/Texinfo/XS/main/build_perl_info.c 
b/tp/Texinfo/XS/main/build_perl_info.c
index 0914b4eb4c..4e34175e2e 100644
--- a/tp/Texinfo/XS/main/build_perl_info.c
+++ b/tp/Texinfo/XS/main/build_perl_info.c
@@ -35,6 +35,7 @@
  */
 
 #include <config.h>
+
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
@@ -50,10 +51,6 @@
 
 #undef context
 
-#ifdef ENABLE_NLS
-#include <libintl.h>
-#endif
-
 #include "command_ids.h"
 #include "element_types.h"
 #include "types_data.h"
@@ -88,8 +85,6 @@
 #include "get_perl_info.h"
 #include "build_perl_info.h"
 
-#define LOCALEDIR DATADIR "/locale"
-
   /* NOTE This file includes the Perl headers, therefore we get the Perl
      redefinitions of functions related to memory allocation, such as
      'free' or 'malloc'.  In other files, the Gnulib redefinition of
@@ -160,28 +155,7 @@ int
 init (int texinfo_uninstalled, SV *converterdatadir_sv, SV *builddir_sv,
       SV *top_srcdir_sv)
 {
-#ifdef ENABLE_NLS
-
-  setlocale (LC_ALL, "");
-
-  /* Note: this uses the installed translations even when running an
-     uninstalled program. */
-  bindtextdomain (PACKAGE_CONFIG, LOCALEDIR);
-
-  textdomain (PACKAGE_CONFIG);
-
-  /* set the tp gnulib text message domain. */
-  bindtextdomain (PACKAGE_CONFIG "_tp-gnulib", LOCALEDIR);
-#else
-
-#endif
-
-  /* do that before any other call to get_encoding_conversion with
-     &output_conversions, otherwise the utf-8 conversion will never
-     be initialized.  Same for &input_conversions.
-    */
-  get_encoding_conversion ("utf-8", &output_conversions);
-  get_encoding_conversion ("utf-8", &input_conversions);
+  txi_base_setup ();
 
   return 1;
 }
diff --git a/tp/Texinfo/XS/main/document.c b/tp/Texinfo/XS/main/document.c
index 7ee7a0ef46..9b4d2f8717 100644
--- a/tp/Texinfo/XS/main/document.c
+++ b/tp/Texinfo/XS/main/document.c
@@ -45,19 +45,6 @@ static size_t document_number;
 static size_t document_space;
 
 
-/* Call code only called once needed for the library data initialization.
-   This function is not related to the Texinfo document, but needs to be
-   in a code file that can include all the headers needed for the
-   initialization, and is included in all the codes that need to initialize
-   the library, so the current file was chosen.
- */
-void
-txi_setup_lib_data (void)
-{
-  set_element_type_name_info ();
-  txi_initialise_base_options ();
-}
-
 DOCUMENT *
 retrieve_document (size_t document_descriptor)
 {
diff --git a/tp/Texinfo/XS/main/document.h b/tp/Texinfo/XS/main/document.h
index 75735bec71..9ba16e501d 100644
--- a/tp/Texinfo/XS/main/document.h
+++ b/tp/Texinfo/XS/main/document.h
@@ -12,9 +12,6 @@
 /* avoid an interdependency with convert_to_text.h */
 struct TEXT_OPTIONS;
 
-/* library data initialization */
-void txi_setup_lib_data (void);
-
 
 DOCUMENT *retrieve_document (size_t document_descriptor);
 DOCUMENT *new_document (void);
diff --git a/tp/Texinfo/XS/main/utils.c b/tp/Texinfo/XS/main/utils.c
index 05bf350dd0..7100c9d63e 100644
--- a/tp/Texinfo/XS/main/utils.c
+++ b/tp/Texinfo/XS/main/utils.c
@@ -31,6 +31,11 @@
 /* for euidaccess.  Not portable, use gnulib */
 #include <unistd.h>
 
+#ifdef ENABLE_NLS
+#include <locale.h>
+#include <libintl.h>
+#endif
+
 #include "conversion_data.h"
 /* also for xvasprintf */
 #include "text.h"
@@ -70,6 +75,8 @@ const char *null_device_names[] = {
 #endif
  0};
 
+#define LOCALEDIR DATADIR "/locale"
+
 const char *whitespace_chars = " \t\v\f\r\n";
 const char *digit_chars = "0123456789";
 
@@ -280,6 +287,37 @@ isascii_upper (int c)
 
 
 
+/* Setup global information that is not specific of Texinfo.
+   Should be called once and early */
+void
+txi_base_setup (void)
+{
+#ifdef ENABLE_NLS
+
+  setlocale (LC_ALL, "");
+
+  /* Note: this uses the installed translations even when running an
+     uninstalled program. */
+  bindtextdomain (PACKAGE_CONFIG, LOCALEDIR);
+
+  textdomain (PACKAGE_CONFIG);
+
+  /* set the tp gnulib text message domain. */
+  bindtextdomain (PACKAGE_CONFIG "_tp-gnulib", LOCALEDIR);
+#else
+
+#endif
+
+  /* do that before any other call to get_encoding_conversion with
+   &output_conversions, otherwise the utf-8 conversion will never
+   be initialized.  Same for &input_conversions.
+  */
+  get_encoding_conversion ("utf-8", &output_conversions);
+  get_encoding_conversion ("utf-8", &input_conversions);
+}
+
+
+
 /* operations on strings considered as multibytes.  Use libunistring */
 
 /* count characters, not bytes. */
diff --git a/tp/Texinfo/XS/main/utils.h b/tp/Texinfo/XS/main/utils.h
index 44cd249209..fea13a05d6 100644
--- a/tp/Texinfo/XS/main/utils.h
+++ b/tp/Texinfo/XS/main/utils.h
@@ -130,6 +130,8 @@ char *to_upper_or_lower_multibyte (const char *text, int 
lower_or_upper);
 int width_multibyte (const char *text);
 int word_bytes_len_multibyte (const char *text);
 
+void txi_base_setup (void);
+
 void wipe_values (VALUE_LIST *values);
 
 void delete_global_info (GLOBAL_INFO *global_info_ref);
diff --git a/tp/Texinfo/XS/teximakehtml.c b/tp/Texinfo/XS/teximakehtml.c
index 8bce3e8c8e..22d4e83d1d 100644
--- a/tp/Texinfo/XS/teximakehtml.c
+++ b/tp/Texinfo/XS/teximakehtml.c
@@ -31,7 +31,7 @@
 
 #include "document_types.h"
 #include "converter_types.h"
-/* parse_file_path */
+/* parse_file_path txi_base_setup */
 #include "utils.h"
 #include "customization_options.h"
 /*
@@ -127,23 +127,14 @@ main (int argc, char *argv[])
   const char *texinfo_text;
    */
 
-#ifdef ENABLE_NLS
-  setlocale (LC_ALL, "");
-
-  /* Set the text message domain.  */
-  bindtextdomain (PACKAGE_CONFIG, LOCALEDIR);
-  textdomain (PACKAGE_CONFIG);
-
-  /* set the gnulib text message domain. */
-  bindtextdomain (PACKAGE_CONFIG "_tp-gnulib", LOCALEDIR);
-#endif
-
-  locale_encoding = nl_langinfo (CODESET);
-
   parse_file_path (argv[0], program_file_name_and_directory);
   program_file = program_file_name_and_directory[0];
   input_directory = program_file_name_and_directory[1];
 
+  txi_base_setup ();
+
+  locale_encoding = nl_langinfo (CODESET);
+
   while (1)
     {
       int option_character;
@@ -176,8 +167,6 @@ main (int argc, char *argv[])
   if (optind >= argc)
     exit (EXIT_FAILURE);
 
-  txi_setup (LOCALEDIR, 0, 0, 0, 0);
-
   memset (&texinfo_language_config_dirs, 0, sizeof (STRING_LIST));
   add_string (".config", &texinfo_language_config_dirs);
 
@@ -199,14 +188,14 @@ main (int argc, char *argv[])
     add_string (DATADIR "/texinfo", &texinfo_language_config_dirs);
 
 
+  txi_setup (LOCALEDIR, 0, 0, 0, 0);
+
 /*
  if ($^O eq 'MSWin32') {
   $main_program_set_options->{'DOC_ENCODING_FOR_INPUT_FILE_NAME'} = 0;
 }
 */
 
-  /* Texinfo file parsing */
-  input_file_path = argv[optind];
 
   initialize_options_list (&parser_options, 2);
   /*
@@ -224,6 +213,9 @@ main (int argc, char *argv[])
                             "EXPANDED_FORMATS", &parser_EXPANDED_FORMATS);
     }
 
+  /* Texinfo file parsing */
+  input_file_path = argv[optind];
+
   /* initialize parser */
   txi_parser (input_file_path, locale_encoding, expanded_formats, &values,
               &parser_options);
diff --git a/tp/texi2any.pl b/tp/texi2any.pl
index c0889b6453..53a0585ead 100755
--- a/tp/texi2any.pl
+++ b/tp/texi2any.pl
@@ -153,7 +153,7 @@ my $prefix = '@prefix@';
 my $datadir;
 my $datarootdir;
 my $sysconfdir;
-my $pkgdatadir;
+#my $pkgdatadir;
 my $converter;
 
 my $fallback_prefix = File::Spec->catdir(File::Spec->rootdir(), 'usr', 
'local');
@@ -177,10 +177,10 @@ if ('@datadir@' ne '@' . 'datadir@' and '@PACKAGE@' ne 
'@' . 'PACKAGE@') {
   $datadir = eval '"@datadir@"';
   my $package = '@PACKAGE@';
   $converter = '@CONVERTER@';
-  $pkgdatadir = File::Spec->catdir($datadir, $package);
+  #$pkgdatadir = File::Spec->catdir($datadir, $package);
 } else {
   $datadir = File::Spec->catdir($fallback_prefix, 'share');
-  $pkgdatadir = File::Spec->catdir($datadir, 'texinfo');
+  #$pkgdatadir = File::Spec->catdir($datadir, 'texinfo');
   $converter = 'texi2any';
 }
 



reply via email to

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