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/converter.c (copy_transla


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/XS/convert/converter.c (copy_translated_commands) (apply_converter_info): add copy_translated_commands to copy translated_commands list. Copy translated_commands in apply_converter_info instead of passing the argument translated_commands list.
Date: Tue, 03 Dec 2024 17:39:42 -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 7de7ffa952 * tp/Texinfo/XS/convert/converter.c 
(copy_translated_commands) (apply_converter_info): add copy_translated_commands 
to copy translated_commands list.  Copy translated_commands in 
apply_converter_info instead of passing the argument translated_commands list.
7de7ffa952 is described below

commit 7de7ffa9528c32df64bbd54132dfbbc1b35702d9
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Tue Dec 3 23:39:21 2024 +0100

    * tp/Texinfo/XS/convert/converter.c (copy_translated_commands)
    (apply_converter_info): add copy_translated_commands to copy
    translated_commands list.  Copy translated_commands in
    apply_converter_info instead of passing the argument
    translated_commands list.
    
    * tp/Texinfo/XS/main/build_perl_info.c
    (build_sv_options_from_options_list): use size_t instead of int.
---
 ChangeLog                                  | 11 +++++++++
 tp/Texinfo/XS/convert/ConvertXS.xs         |  5 +---
 tp/Texinfo/XS/convert/converter.c          | 37 +++++++++++++++++++++++++++---
 tp/Texinfo/XS/main/build_perl_info.c       |  2 +-
 tp/Texinfo/XS/main/customization_options.c |  2 +-
 tp/Texinfo/XS/main/customization_options.h |  2 +-
 6 files changed, 49 insertions(+), 10 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 067eb502e3..c3a33acc49 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2024-12-03  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/convert/converter.c (copy_translated_commands)
+       (apply_converter_info): add copy_translated_commands to copy
+       translated_commands list.  Copy translated_commands in
+       apply_converter_info instead of passing the argument
+       translated_commands list.
+
+       * tp/Texinfo/XS/main/build_perl_info.c
+       (build_sv_options_from_options_list): use size_t instead of int.
+
 2024-12-03  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/convert/converter.c (new_converter)
diff --git a/tp/Texinfo/XS/convert/ConvertXS.xs 
b/tp/Texinfo/XS/convert/ConvertXS.xs
index 1f70d52837..fc7b4ab00d 100644
--- a/tp/Texinfo/XS/convert/ConvertXS.xs
+++ b/tp/Texinfo/XS/convert/ConvertXS.xs
@@ -133,10 +133,7 @@ converter_defaults (SV *converter_in, SV *conf_sv)
         converter_format
           = find_perl_converter_class_converter_format (class_name);
 
-        /* use txi_base_sorted_options to find the type of options
-           specified by name.
-
-           Do not pass class_name to avoid error messages, there will
+        /* Do not pass class_name to avoid error messages, there will
            be an error messages in generic_converter_init (as in Perl)
          */
         conf = get_converter_info_from_sv (conf_sv, 0, 0);
diff --git a/tp/Texinfo/XS/convert/converter.c 
b/tp/Texinfo/XS/convert/converter.c
index b8b61da959..071280e979 100644
--- a/tp/Texinfo/XS/convert/converter.c
+++ b/tp/Texinfo/XS/convert/converter.c
@@ -297,6 +297,37 @@ new_converter (enum converter_format format)
   return converter_index +1;
 }
 
+static TRANSLATED_COMMAND *
+copy_translated_commands (const TRANSLATED_COMMAND *translated_commands)
+{
+  size_t translated_cmds_nr, i;
+  TRANSLATED_COMMAND *result;
+
+  for (translated_cmds_nr = 0; translated_commands[translated_cmds_nr].cmd;
+       translated_cmds_nr++)
+    {}
+
+  result = (TRANSLATED_COMMAND *)
+        malloc ((translated_cmds_nr +1) * sizeof (TRANSLATED_COMMAND));
+  memset (result, 0,
+              (translated_cmds_nr +1) * sizeof (TRANSLATED_COMMAND));
+
+  if (translated_cmds_nr)
+    {
+      for (i = 0; i < translated_cmds_nr; i++)
+        {
+          const TRANSLATED_COMMAND *reference_translated_command
+            = &translated_commands[i];
+          TRANSLATED_COMMAND *translated_command_copy = &result[i];
+
+          translated_command_copy->cmd = reference_translated_command->cmd;
+          translated_command_copy->translation
+            = strdup (reference_translated_command->translation);
+        }
+    }
+  return result;
+}
+
 void
 destroy_translated_commands (TRANSLATED_COMMAND *translated_commands)
 {
@@ -313,7 +344,7 @@ destroy_translated_commands (TRANSLATED_COMMAND 
*translated_commands)
 /* apply initialization information from one source */
 static void
 apply_converter_info (CONVERTER *converter,
-              CONVERTER_INITIALIZATION_INFO *init_info, int set_configured)
+         const CONVERTER_INITIALIZATION_INFO *init_info, int set_configured)
 {
   copy_options_list_set_configured (converter->conf,
                                     converter->sorted_options,
@@ -322,8 +353,8 @@ apply_converter_info (CONVERTER *converter,
   if (init_info->translated_commands)
     {
       destroy_translated_commands (converter->translated_commands);
-      converter->translated_commands = init_info->translated_commands;
-      init_info->translated_commands = 0;
+      converter->translated_commands
+        = copy_translated_commands (init_info->translated_commands);
     }
 }
 
diff --git a/tp/Texinfo/XS/main/build_perl_info.c 
b/tp/Texinfo/XS/main/build_perl_info.c
index 12477ac0fb..ef3371028b 100644
--- a/tp/Texinfo/XS/main/build_perl_info.c
+++ b/tp/Texinfo/XS/main/build_perl_info.c
@@ -3102,7 +3102,7 @@ build_sv_options_from_options_list (const OPTIONS_LIST 
*options_list,
 static HV *
 build_translated_commands (const TRANSLATED_COMMAND *translated_commands)
 {
-  int i;
+  size_t i;
   HV *translated_hv;
 
   dTHX;
diff --git a/tp/Texinfo/XS/main/customization_options.c 
b/tp/Texinfo/XS/main/customization_options.c
index 473389d449..af7165430d 100644
--- a/tp/Texinfo/XS/main/customization_options.c
+++ b/tp/Texinfo/XS/main/customization_options.c
@@ -513,7 +513,7 @@ copy_options_list (OPTIONS_LIST *options_list, const 
OPTIONS_LIST *options_src,
 /* copy OPTIONS_LIST options to an OPTIONS structure */
 void
 copy_options_list_set_configured (OPTIONS *options, OPTION **sorted_options,
-                                  OPTIONS_LIST *options_list,
+                                  const OPTIONS_LIST *options_list,
                                   int set_configured)
 {
   copy_options_list_options (options, sorted_options, options_list);
diff --git a/tp/Texinfo/XS/main/customization_options.h 
b/tp/Texinfo/XS/main/customization_options.h
index 238fb0b419..5b033ee317 100644
--- a/tp/Texinfo/XS/main/customization_options.h
+++ b/tp/Texinfo/XS/main/customization_options.h
@@ -64,7 +64,7 @@ void copy_options_list (OPTIONS_LIST *options_list,
                         const OPTIONS_LIST *options_src, int check_duplicates);
 void copy_options_list_set_configured (OPTIONS *options,
                                        OPTION **sorted_options,
-                                       OPTIONS_LIST *options_list,
+                                       const OPTIONS_LIST *options_list,
                                        int set_configured);
 
 OPTION *add_option_value (OPTIONS_LIST *options_list,



reply via email to

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