texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/Texinfo/XS/convert/html_prepare_converter.c


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/XS/convert/html_prepare_converter.c (parse_htmlxref_files): remove only the last /.
Date: Sat, 05 Oct 2024 05:29:58 -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 243f463f6b * tp/Texinfo/XS/convert/html_prepare_converter.c 
(parse_htmlxref_files): remove only the last /.
243f463f6b is described below

commit 243f463f6b560b55dc8e3e307661f41fccc7b609
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Aug 25 22:26:20 2024 +0200

    * tp/Texinfo/XS/convert/html_prepare_converter.c
    (parse_htmlxref_files): remove only the last /.
    
    * tp/Texinfo/XS/main/customization_options.c
    (add_option_strlist_value): add.
    
    * tp/Texinfo/XS/convert/converter.c (apply_converter_info)
    (destroy_converter_initialization_info)
    (copy_converter_initialization_info),
    tp/Texinfo/XS/convert/get_converter_perl_info.c
    (get_converter_info_from_sv),
    tp/Texinfo/XS/convert/html_prepare_converter.c (load_htmlxref_files),
    tp/Texinfo/XS/main/converter_types.h (CONVERTER_INITIALIZATION_INFO)
    (CONVERTER): remove texinfo_language_config_dirs from converter and
    initialization info.  Set htmlxref_dirs from the
    TEXINFO_LANGUAGE_DIRECTORIES customization variable.
    
    * tp/Texinfo/XS/convert/texinfo.c (txi_converter_setup): get
    texinfo_language_config_dirs as a STRING_LIST and use
    add_option_strlist_value and a copy to set
    TEXINFO_LANGUAGE_DIRECTORIES.
    
    * tp/Texinfo/XS/teximakehtml.c (main): set
    texinfo_language_config_dirs as a string list.  Add the
    converter_texinfo_language_config_dirs to prepend the current
    directory and input_directory and pass to txi_converter_setup.
    
    * tp/Texinfo/XS/convert/html_prepare_converter.c
    (clear_string_variables_list, parse_htmlxref_files): clear and free
    variables lists and lines.
---
 ChangeLog                                       | 33 ++++++++++++++
 tp/Texinfo/XS/convert/converter.c               |  8 ----
 tp/Texinfo/XS/convert/get_converter_perl_info.c |  6 ---
 tp/Texinfo/XS/convert/html_prepare_converter.c  | 42 ++++++++++++++----
 tp/Texinfo/XS/convert/texinfo.c                 | 29 +++++++------
 tp/Texinfo/XS/convert/texinfo.h                 |  2 +-
 tp/Texinfo/XS/main/converter_types.h            |  2 -
 tp/Texinfo/XS/main/customization_options.c      | 25 ++++++++++-
 tp/Texinfo/XS/main/customization_options.h      |  3 ++
 tp/Texinfo/XS/teximakehtml.c                    | 57 +++++++++++++++----------
 10 files changed, 145 insertions(+), 62 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e83fa05af0..bd28bd1a35 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,36 @@
+2024-08-25  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/convert/html_prepare_converter.c
+       (parse_htmlxref_files): remove only the last /.
+
+       * tp/Texinfo/XS/main/customization_options.c
+       (add_option_strlist_value): add.
+
+       * tp/Texinfo/XS/convert/converter.c (apply_converter_info)
+       (destroy_converter_initialization_info)
+       (copy_converter_initialization_info),
+       tp/Texinfo/XS/convert/get_converter_perl_info.c
+       (get_converter_info_from_sv),
+       tp/Texinfo/XS/convert/html_prepare_converter.c (load_htmlxref_files),
+       tp/Texinfo/XS/main/converter_types.h (CONVERTER_INITIALIZATION_INFO)
+       (CONVERTER): remove texinfo_language_config_dirs from converter and
+       initialization info.  Set htmlxref_dirs from the
+       TEXINFO_LANGUAGE_DIRECTORIES customization variable.
+
+       * tp/Texinfo/XS/convert/texinfo.c (txi_converter_setup): get
+       texinfo_language_config_dirs as a STRING_LIST and use
+       add_option_strlist_value and a copy to set
+       TEXINFO_LANGUAGE_DIRECTORIES.
+
+       * tp/Texinfo/XS/teximakehtml.c (main): set
+       texinfo_language_config_dirs as a string list.  Add the
+       converter_texinfo_language_config_dirs to prepend the current
+       directory and input_directory and pass to txi_converter_setup.
+
+       * tp/Texinfo/XS/convert/html_prepare_converter.c
+       (clear_string_variables_list, parse_htmlxref_files): clear and free
+       variables lists and lines.
+
 2024-08-25  Patrice Dumas  <pertusus@free.fr>
 
        * tp/ext/latex2html.pm (l2h_process), tp/ext/tex4ht.pm
diff --git a/tp/Texinfo/XS/convert/converter.c 
b/tp/Texinfo/XS/convert/converter.c
index 479827e9f4..d0bba8785b 100644
--- a/tp/Texinfo/XS/convert/converter.c
+++ b/tp/Texinfo/XS/convert/converter.c
@@ -336,9 +336,6 @@ apply_converter_info (CONVERTER *converter,
       converter->translated_commands = init_info->translated_commands;
       init_info->translated_commands = 0;
     }
-
-  copy_strings (&converter->texinfo_language_config_dirs,
-                &init_info->texinfo_language_config_dirs);
 }
 
 /* apply format_defaults and user_conf initialization information.
@@ -399,8 +396,6 @@ destroy_converter_initialization_info 
(CONVERTER_INITIALIZATION_INFO *init_info)
 
   free (init_info->output_format);
 
-  free_strings_list (&init_info->texinfo_language_config_dirs);
-
   free_options_list (&init_info->conf);
 
   free_strings_list (&init_info->non_valid_customization);
@@ -417,9 +412,6 @@ copy_converter_initialization_info 
(CONVERTER_INITIALIZATION_INFO *dst_info,
       dst_info->output_format = strdup (src_info->output_format);
     }
 
-  copy_strings (&dst_info->texinfo_language_config_dirs,
-                &src_info->texinfo_language_config_dirs);
-
   copy_strings (&dst_info->non_valid_customization,
                 &src_info->non_valid_customization);
 
diff --git a/tp/Texinfo/XS/convert/get_converter_perl_info.c 
b/tp/Texinfo/XS/convert/get_converter_perl_info.c
index 9e3ec09786..4039838013 100644
--- a/tp/Texinfo/XS/convert/get_converter_perl_info.c
+++ b/tp/Texinfo/XS/convert/get_converter_perl_info.c
@@ -297,12 +297,6 @@ get_converter_info_from_sv (SV *conf_sv, const char 
*class_name,
                       if (!strcmp (key, "translated_commands"))
                         initialization_info->translated_commands
                           = set_translated_commands (value);
-                      else if (!strcmp (key, "texinfo_language_config_dirs"))
-                        {
-                          add_svav_to_string_list (value,
-                            &initialization_info->texinfo_language_config_dirs,
-                            svt_dir);
-                        }
                       else if (class_name)
                         {
                           fprintf (stderr,
diff --git a/tp/Texinfo/XS/convert/html_prepare_converter.c 
b/tp/Texinfo/XS/convert/html_prepare_converter.c
index 99b1be007f..df80634730 100644
--- a/tp/Texinfo/XS/convert/html_prepare_converter.c
+++ b/tp/Texinfo/XS/convert/html_prepare_converter.c
@@ -674,6 +674,20 @@ set_variable_value (STRING_VARIABLES_LIST *variables,
   variables->number++;
 }
 
+static void
+clear_string_variables_list (STRING_VARIABLES_LIST *variables)
+{
+  size_t i;
+
+  for (i = 0; i < variables->number; i++)
+    {
+      STRING_VARIABLE_INFO *variable = &variables->list[i];
+      free (variable->name);
+      free (variable->string);
+    }
+  variables->number = 0;
+}
+
 /* generic, similar to Perl re (\w+) with /a modifier */
 static size_t
 read_var_len (const char *text)
@@ -876,7 +890,7 @@ parse_htmlxref_files (CONVERTER *self, HTMLXREF_MANUAL_LIST 
*htmlxref_list,
 
           p += strspn (p, whitespace_chars);
           if (*p == '#' || *p == '\0')
-            continue;
+            goto next_line;
 
           len = read_var_len (p);
           if (len)
@@ -901,7 +915,7 @@ parse_htmlxref_files (CONVERTER *self, HTMLXREF_MANUAL_LIST 
*htmlxref_list,
                      */
                   free (definition);
                   free (name);
-                  continue;
+                  goto next_line;
                 }
             }
           len = strcspn (p, whitespace_chars);
@@ -947,7 +961,7 @@ parse_htmlxref_files (CONVERTER *self, HTMLXREF_MANUAL_LIST 
*htmlxref_list,
 
               message_list_line_error_ext (&self->error_messages,
                 self->conf, MSG_warning, 0, &source_info, "missing type");
-              continue;
+              goto next_line;
             }
           else if (htmlxref_type == htmlxref_split_type_none)
             {
@@ -958,7 +972,7 @@ parse_htmlxref_files (CONVERTER *self, HTMLXREF_MANUAL_LIST 
*htmlxref_list,
                 self->conf, MSG_warning, 0, &source_info,
                 "unrecognized type: %s", split_or_mono);
               free (split_or_mono);
-              continue;
+              goto next_line;
             }
 
           manual = strndup (p, len);
@@ -986,7 +1000,7 @@ parse_htmlxref_files (CONVERTER *self, 
HTMLXREF_MANUAL_LIST *htmlxref_list,
                 "missing %s URL prefix for `%s'", split_or_mono, manual);
               free (split_or_mono);
               free (manual);
-              continue;
+              goto next_line;
             }
            */
           free (split_or_mono);
@@ -1002,7 +1016,7 @@ parse_htmlxref_files (CONVERTER *self, 
HTMLXREF_MANUAL_LIST *htmlxref_list,
           if (htmlxref_manual->urlprefix[htmlxref_type])
             {
               free (href);
-              continue;
+              goto next_line;
             }
 
           if (href)
@@ -1015,8 +1029,12 @@ parse_htmlxref_files (CONVERTER *self, 
HTMLXREF_MANUAL_LIST *htmlxref_list,
                 {
                   size_t j;
                   for (j = strlen (subst_href); j > 0; j--)
-                    if (subst_href[j-1] == '/')
-                      subst_href[j-1] = '\0';
+                    {
+                      if (subst_href[j-1] == '/')
+                        subst_href[j-1] = '\0';
+                      else
+                        break;
+                    }
                 }
             }
           else
@@ -1029,8 +1047,12 @@ parse_htmlxref_files (CONVERTER *self, 
HTMLXREF_MANUAL_LIST *htmlxref_list,
 
           htmlxref_manual->urlprefix[htmlxref_type] = strdup (subst_href);
           free (subst_href);
+        next_line:
+          free (line);
         }
 
+      clear_string_variables_list (&variables);
+
       if (fclose (stream) == EOF)
         {
           char *decoded_file;
@@ -1052,6 +1074,7 @@ parse_htmlxref_files (CONVERTER *self, 
HTMLXREF_MANUAL_LIST *htmlxref_list,
           free (decoded_file);
         }
     }
+  free (variables.list);
 }
 
 static void
@@ -1117,7 +1140,8 @@ load_htmlxref_files (CONVERTER *self)
         }
       else
         {
-          copy_strings (&htmlxref_dirs, &self->texinfo_language_config_dirs);
+          copy_strings (&htmlxref_dirs,
+                        self->conf->TEXINFO_LANGUAGE_DIRECTORIES.o.strlist);
         }
 
       if (self->conf->TEST.o.integer > 0)
diff --git a/tp/Texinfo/XS/convert/texinfo.c b/tp/Texinfo/XS/convert/texinfo.c
index a559cc41a8..ad5a032948 100644
--- a/tp/Texinfo/XS/convert/texinfo.c
+++ b/tp/Texinfo/XS/convert/texinfo.c
@@ -288,7 +288,7 @@ txi_converter_setup (const char *format_str,
                      const char *output_format,
                      const char *locale_encoding,
                      const char *program_file,
-                     char * const*texinfo_language_config_dirs,
+                     const STRING_LIST *texinfo_language_config_dirs,
                      OPTIONS_LIST *customizations)
 {
   enum converter_format converter_format
@@ -304,29 +304,26 @@ txi_converter_setup (const char *format_str,
   else
     conf->output_format = strdup (format_str);
 
+  initialize_options_list (&conf->conf, 10);
+
   if (texinfo_language_config_dirs)
     {
-      int i;
-      for (i = 0; texinfo_language_config_dirs[i]; i++)
-        {
-          add_string (texinfo_language_config_dirs[i],
-                      &conf->texinfo_language_config_dirs);
-        }
+      add_option_strlist_value (&conf->conf, txi_base_sorted_options,
+                               "TEXINFO_LANGUAGE_DIRECTORIES",
+                               texinfo_language_config_dirs);
     }
 
-  initialize_options_list (&conf->conf, 10);
-
   /* similar to options coming from texi2any */
   add_option_string_value (&conf->conf, txi_base_sorted_options,
-                           "PROGRAM", 0, program_file);
    /*
+                           "PROGRAM", 0, program_file);
     */
   /* comment the line above and uncomment below to compare with
      texi2any output
-                        "texi2any");
+   */
+                           "PROGRAM", 0, "texi2any");
   add_option_string_value (&conf->conf, txi_base_sorted_options,
                       "PACKAGE_AND_VERSION", 0, "Texinfo 7.1.90+dev");
-   */
   add_option_string_value (&conf->conf, txi_base_sorted_options,
                         "COMMAND_LINE_ENCODING", 0, locale_encoding);
   add_option_string_value (&conf->conf, txi_base_sorted_options,
@@ -356,6 +353,14 @@ txi_converter_setup (const char *format_str,
 
 /* formats conversion */
 
+/*
+char *
+txi_output (CONVERTER *converter, DOCUMENT *document)
+{
+  return converter_output (converter, document);
+}
+*/
+
 /* similar to Texinfo::Convert::HTML->output */
 char *
 txi_html_output (CONVERTER *converter, DOCUMENT *document)
diff --git a/tp/Texinfo/XS/convert/texinfo.h b/tp/Texinfo/XS/convert/texinfo.h
index 12558fe28f..fb56e840c0 100644
--- a/tp/Texinfo/XS/convert/texinfo.h
+++ b/tp/Texinfo/XS/convert/texinfo.h
@@ -45,7 +45,7 @@ CONVERTER *txi_converter_setup (const char *converter_format,
                      const char *output_format,
                      const char *locale_encoding,
                      const char *program_file,
-                     char *const *texinfo_language_config_dirs,
+                     const STRING_LIST *texinfo_language_config_dirs,
                      OPTIONS_LIST *customizations);
 
 char *txi_html_output (CONVERTER *converter, DOCUMENT *document);
diff --git a/tp/Texinfo/XS/main/converter_types.h 
b/tp/Texinfo/XS/main/converter_types.h
index 6db2d190fc..f0bd03ea82 100644
--- a/tp/Texinfo/XS/main/converter_types.h
+++ b/tp/Texinfo/XS/main/converter_types.h
@@ -765,7 +765,6 @@ typedef struct PRE_CLASS_TYPE_INFO {
 typedef struct CONVERTER_INITIALIZATION_INFO {
     char *output_format;
     TRANSLATED_COMMAND *translated_commands;
-    STRING_LIST texinfo_language_config_dirs;
     OPTIONS_LIST conf;
     /* gather strings that are not customization options */
     STRING_LIST non_valid_customization;
@@ -789,7 +788,6 @@ typedef struct CONVERTER {
     OPTION **sorted_options;
     OPTIONS *init_conf;
     OPTIONS *format_defaults_conf;
-    STRING_LIST texinfo_language_config_dirs;
     char *output_format;
     EXPANDED_FORMAT *expanded_formats;
     TRANSLATED_COMMAND *translated_commands;
diff --git a/tp/Texinfo/XS/main/customization_options.c 
b/tp/Texinfo/XS/main/customization_options.c
index 6872def930..54dee604ce 100644
--- a/tp/Texinfo/XS/main/customization_options.c
+++ b/tp/Texinfo/XS/main/customization_options.c
@@ -365,7 +365,7 @@ copy_option (OPTION *destination, const OPTION *source)
 
 
 
-/* functions setup and use sorted options */
+/* functions to setup and use sorted options */
 
 static int
 compare_option_str (const void *a, const void *b)
@@ -598,6 +598,29 @@ add_option_string_value (OPTIONS_LIST *options_list, 
OPTION **sorted_options,
   return option;
 }
 
+OPTION *
+add_option_strlist_value (OPTIONS_LIST *options_list, OPTION **sorted_options,
+                          const char *option_name, const STRING_LIST *strlist)
+{
+  OPTION *option;
+  const OPTION *ref_option = find_option_string (sorted_options, option_name);
+  if (!ref_option)
+    return 0;
+
+  if (ref_option->type != GOT_char_string_list
+      && ref_option->type != GOT_bytes_string_list
+      && ref_option->type != GOT_file_string_list)
+    return 0;
+
+  option = new_option (ref_option->type, ref_option->name, ref_option->number);
+
+  copy_strings (option->o.strlist, strlist);
+
+  options_list_add_option (options_list, option);
+
+  return option;
+}
+
 void
 number_options_list (OPTIONS_LIST *options_list, OPTION **sorted_options)
 {
diff --git a/tp/Texinfo/XS/main/customization_options.h 
b/tp/Texinfo/XS/main/customization_options.h
index ebe4a533e5..0077d2ac59 100644
--- a/tp/Texinfo/XS/main/customization_options.h
+++ b/tp/Texinfo/XS/main/customization_options.h
@@ -82,6 +82,9 @@ OPTION *add_option_string_value (OPTIONS_LIST *options_list,
                          OPTION **sorted_options,
                          const char *option_name, int int_value,
                          const char *char_value);
+OPTION *add_option_strlist_value (OPTIONS_LIST *options_list,
+                                  OPTION **sorted_options,
+                          const char *option_name, const STRING_LIST *strlist);
 void number_options_list (OPTIONS_LIST *options_list, OPTION **sorted_options);
 
 
diff --git a/tp/Texinfo/XS/teximakehtml.c b/tp/Texinfo/XS/teximakehtml.c
index 3d5f4764d2..6688904a7e 100644
--- a/tp/Texinfo/XS/teximakehtml.c
+++ b/tp/Texinfo/XS/teximakehtml.c
@@ -92,6 +92,7 @@ main (int argc, char *argv[])
   int status;
   char *program_file_name_and_directory[2];
   char *program_file;
+  char *input_directory;
   DOCUMENT *document;
   CONVERTER *converter;
   char *result;
@@ -100,10 +101,10 @@ main (int argc, char *argv[])
   OPTIONS_LIST convert_options;
   size_t errors_count = 0;
   size_t errors_nr;
-  char *texinfo_language_config_dirs[5] = {".texinfo"};
-  int txi_language_idx = 1;
+  STRING_LIST texinfo_language_config_dirs;
+  STRING_LIST converter_texinfo_language_config_dirs;
   char *home_dir;
-  char *home_texinfo_language_config_dirs = 0;
+  const char *curdir = ".";
 
   /*
   const char *texinfo_text;
@@ -127,36 +128,30 @@ main (int argc, char *argv[])
 
   txi_setup (LOCALEDIR, 0, 0, 0, 0);
 
+  memset (&texinfo_language_config_dirs, 0, sizeof (STRING_LIST));
+  add_string (".config", &texinfo_language_config_dirs);
 
   home_dir = getenv ("HOME");
   if (home_dir)
     {
+      char *home_texinfo_language_config_dirs;
       xasprintf (&home_texinfo_language_config_dirs, "%s/.texinfo",
                  home_dir);
-      texinfo_language_config_dirs[txi_language_idx]
-        = home_texinfo_language_config_dirs;
-      txi_language_idx++;
+      add_string (home_texinfo_language_config_dirs,
+                  &texinfo_language_config_dirs);
+      free (home_texinfo_language_config_dirs);
     }
+
   if (strlen (SYSCONFDIR))
-    {
-      texinfo_language_config_dirs[txi_language_idx]
-        = SYSCONFDIR "/texinfo";
-      txi_language_idx++;
-    }
+    add_string (SYSCONFDIR "/texinfo", &texinfo_language_config_dirs);
 
   if (strlen (DATADIR))
-    {
-      texinfo_language_config_dirs[txi_language_idx]
-        = DATADIR "/texinfo";
-      txi_language_idx++;
-    }
-
-  texinfo_language_config_dirs[txi_language_idx] = 0;
+    add_string (DATADIR "/texinfo", &texinfo_language_config_dirs);
 
 
   parse_file_path (argv[0], program_file_name_and_directory);
   program_file = program_file_name_and_directory[0];
-  free (program_file_name_and_directory[1]);
+  input_directory = program_file_name_and_directory[1];
 
 /*
  if ($^O eq 'MSWin32') {
@@ -214,30 +209,46 @@ main (int argc, char *argv[])
   errors_count += errors_nr;
 
 
-  /* conversion intitialization */
+  /* conversion initialization */
   initialize_options_list (&convert_options, 2);
 
-  /* customize buttons.  This is a bit silly to use link buttons for
+  /* customize buttons.  It is a bit silly to use link buttons for
      footer, it is for the demonstration */
   custom_node_footer_buttons = new_base_links_buttons (0);
+  /*
   add_new_button_option (&convert_options,
                      "NODE_FOOTER_BUTTONS", custom_node_footer_buttons);
   add_new_option_value (&convert_options, GOT_integer,
                            "PROGRAM_NAME_IN_FOOTER", 1, 0);
+   */
   /* this is set to help with comparison with previous invokations */
   /*
   add_new_option_value (&convert_options, GOT_integer,
                            "TEST", 1, 0);
    */
+  add_new_option_value (&convert_options, GOT_integer,
+                        "CHECK_HTMLXREF", 1, 0);
+
+  memset (&converter_texinfo_language_config_dirs, 0, sizeof (STRING_LIST));
+
+  add_string (curdir, &converter_texinfo_language_config_dirs);
+  if (strcmp (curdir, input_directory))
+    add_string (input_directory, &converter_texinfo_language_config_dirs);
+  free (input_directory);
+
+  copy_strings (&converter_texinfo_language_config_dirs,
+                &texinfo_language_config_dirs);
 
   converter = txi_converter_setup ("html", "html", locale_encoding,
                                    program_file,
-                                   texinfo_language_config_dirs,
+                                   &converter_texinfo_language_config_dirs,
                                    &convert_options);
 
+  free_strings_list (&converter_texinfo_language_config_dirs);
+  free_strings_list (&texinfo_language_config_dirs);
+
   free_options_list (&convert_options);
   free (program_file);
-  free (home_texinfo_language_config_dirs);
 
 
   /* conversion */



reply via email to

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