texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/Texinfo/XS/main/customization_options.c (ini


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/XS/main/customization_options.c (initialize_options_list): remove the possibility to preset the number of elements in list, remove the number argument. Update callers.
Date: Mon, 28 Oct 2024 04:18:27 -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 e4cba7f05c * tp/Texinfo/XS/main/customization_options.c 
(initialize_options_list): remove the possibility to preset the number of 
elements in list, remove the number argument.  Update callers.
e4cba7f05c is described below

commit e4cba7f05c10709020619631dbb340e72281beab
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Mon Oct 28 09:18:12 2024 +0100

    * tp/Texinfo/XS/main/customization_options.c
    (initialize_options_list): remove the possibility to preset the number
    of elements in list, remove the number argument.  Update callers.
    
    * tp/Texinfo/XS/convert/get_converter_perl_info.c
    (new_numbered_option_from_sv, get_converter_info_from_sv): call
    options_list_add_option_number in new_numbered_option_from_sv and
    simplify get_converter_info_from_sv.
---
 ChangeLog                                       | 11 ++++
 tp/Texinfo/XS/convert/converter.c               |  2 +-
 tp/Texinfo/XS/convert/get_converter_perl_info.c | 78 +++++++++----------------
 tp/Texinfo/XS/convert/texinfo.c                 |  2 -
 tp/Texinfo/XS/main/customization_options.c      | 12 +---
 tp/Texinfo/XS/main/customization_options.h      |  2 +-
 tp/Texinfo/XS/teximakehtml.c                    | 12 ++--
 7 files changed, 48 insertions(+), 71 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 1c1316bb97..80d55a3ce5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2024-10-28  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/main/customization_options.c
+       (initialize_options_list): remove the possibility to preset the number
+       of elements in list, remove the number argument.  Update callers.
+
+       * tp/Texinfo/XS/convert/get_converter_perl_info.c
+       (new_numbered_option_from_sv, get_converter_info_from_sv): call
+       options_list_add_option_number in new_numbered_option_from_sv and
+       simplify get_converter_info_from_sv.
+
 2024-10-28  Patrice Dumas  <pertusus@free.fr>
 
        Always have an OPTIONS structure associated to an options list
diff --git a/tp/Texinfo/XS/convert/converter.c 
b/tp/Texinfo/XS/convert/converter.c
index b179a8a947..3a92dcdbac 100644
--- a/tp/Texinfo/XS/convert/converter.c
+++ b/tp/Texinfo/XS/convert/converter.c
@@ -373,7 +373,7 @@ new_converter_initialization_info (void)
      malloc (sizeof (CONVERTER_INITIALIZATION_INFO));
   memset (result, 0, sizeof (CONVERTER_INITIALIZATION_INFO));
 
-  initialize_options_list (&result->conf, 0);
+  initialize_options_list (&result->conf);
   return result;
 }
 
diff --git a/tp/Texinfo/XS/convert/get_converter_perl_info.c 
b/tp/Texinfo/XS/convert/get_converter_perl_info.c
index b54e2bc305..c2a052c77f 100644
--- a/tp/Texinfo/XS/convert/get_converter_perl_info.c
+++ b/tp/Texinfo/XS/convert/get_converter_perl_info.c
@@ -211,20 +211,19 @@ set_translated_commands (SV *translated_commands_sv)
 
 static OPTION *
 new_numbered_option_from_sv (SV *option_sv, CONVERTER *converter,
-                    OPTION **sorted_options, const char *option_name,
+                    OPTIONS_LIST *options_list, const char *option_name,
                     int *status)
 {
-  OPTION *option = 0;
-
-  const OPTION *ref_option = find_option_string (sorted_options, option_name);
-  if (!ref_option)
+  OPTION *option = find_option_string (options_list->sorted_options,
+                                       option_name);
+  if (!option)
     *status = -2;
   else
     {
-      option
-        = new_option (ref_option->type, ref_option->name, ref_option->number);
-
-      *status = get_sv_option (option, option_sv, 0, 0, converter);
+      *status = get_sv_option (option, option_sv, 0, options_list->options,
+                               converter);
+      if (!*status)
+        options_list_add_option_number (options_list, option->number);
     }
 
   return option;
@@ -255,59 +254,38 @@ get_converter_info_from_sv (SV *conf_sv, const char 
*class_name,
       if (!hv_number)
         return initialization_info;
 
-      initialize_options_list (&initialization_info->conf, hv_number);
-      initialization_info->conf.number = 0;
-
       for (i = 0; i < hv_number; i++)
         {
           int status;
           char *key;
           I32 retlen;
           SV *value = hv_iternextsv (conf_hv, &key, &retlen);
-          /* FIXME could directly set the value in
-              &initialization_info->conf */
           OPTION *option = new_numbered_option_from_sv (value, converter,
-                                               sorted_options, key, &status);
+                                  &initialization_info->conf, key, &status);
 
-          if (!status)
-            {
-              size_t index = option->number -1;
-              OPTION *dst_option
-                = initialization_info->conf.sorted_options[index];
-
-              initialization_info->conf.list[initialization_info->conf.number]
-                = option->number;
-              initialization_info->conf.number++;
-
-              copy_option (dst_option, option);
-              free_option (option);
-            }
-          else
+          if (status == -2)
             {
-              if (status == -2)
-                {
-                  add_string (key,
-                    &initialization_info->non_valid_customization);
-
-                  if (!strcmp (key, "translated_commands"))
-                    initialization_info->translated_commands
-                      = set_translated_commands (value);
-                  /* FIXME get deprecated_config_directories if needed */
-                  else if (!strcmp (key, "deprecated_config_directories"))
-                    {}
-                  else if (class_name)
-                    {
-                      fprintf (stderr,
-                               "%s: %s not a possible configuration\n",
-                               class_name, key);
-                    }
-                }
-              else
+              add_string (key,
+                &initialization_info->non_valid_customization);
+
+              if (!strcmp (key, "translated_commands"))
+                initialization_info->translated_commands
+                  = set_translated_commands (value);
+              /* FIXME get deprecated_config_directories if needed */
+              else if (!strcmp (key, "deprecated_config_directories"))
+                {}
+              else if (class_name)
                 {
-                  free_option (option);
-                  fprintf (stderr, "ERROR: %s unexpected conf error\n", key);
+                  fprintf (stderr,
+                           "%s: %s not a possible configuration\n",
+                           class_name, key);
                 }
             }
+          else if (status)
+            {
+              free_option (option);
+              fprintf (stderr, "ERROR: %s unexpected conf error\n", key);
+            }
         }
     }
   return initialization_info;
diff --git a/tp/Texinfo/XS/convert/texinfo.c b/tp/Texinfo/XS/convert/texinfo.c
index f711a8887b..68d07b2648 100644
--- a/tp/Texinfo/XS/convert/texinfo.c
+++ b/tp/Texinfo/XS/convert/texinfo.c
@@ -353,8 +353,6 @@ txi_converter_setup (const char *format_str,
 
   conf = new_converter_initialization_info ();
 
-  initialize_options_list (&conf->conf, 10);
-
   /* prepare specific information for the converter */
   if (output_format)
     err_add_option_string_value (&conf->conf, txi_base_sorted_options,
diff --git a/tp/Texinfo/XS/main/customization_options.c 
b/tp/Texinfo/XS/main/customization_options.c
index d3860c90ea..cc147a483d 100644
--- a/tp/Texinfo/XS/main/customization_options.c
+++ b/tp/Texinfo/XS/main/customization_options.c
@@ -465,17 +465,9 @@ set_sorted_option_key_configured (OPTION **sorted_options, 
const char *key,
 /* functions to set and use options list */
 
 void
-initialize_options_list (OPTIONS_LIST *options_list, size_t number)
+initialize_options_list (OPTIONS_LIST *options_list)
 {
-  options_list->number = 0;
-  options_list->space = number;
-  if (number > 0)
-    {
-      options_list->list = (size_t *) malloc (sizeof (size_t) * number);
-      memset (options_list->list, 0, sizeof (size_t) * number);
-    }
-  else
-    options_list->list = 0;
+  memset (options_list, 0, sizeof (OPTIONS_LIST));
 
   options_list->options = new_options ();
   options_list->sorted_options = new_sorted_options (options_list->options);
diff --git a/tp/Texinfo/XS/main/customization_options.h 
b/tp/Texinfo/XS/main/customization_options.h
index 3fe0b1a20c..73652c4a6a 100644
--- a/tp/Texinfo/XS/main/customization_options.h
+++ b/tp/Texinfo/XS/main/customization_options.h
@@ -64,7 +64,7 @@ void set_sorted_option_key_configured (OPTION 
**sorted_options,
 
 
 
-void initialize_options_list (OPTIONS_LIST *options_list, size_t number);
+void initialize_options_list (OPTIONS_LIST *options_list);
 OPTION *add_option_value (OPTIONS_LIST *options_list,
                           const char *name,
                           int int_value, const char *char_value);
diff --git a/tp/Texinfo/XS/teximakehtml.c b/tp/Texinfo/XS/teximakehtml.c
index 4f91d9f5a3..837ed7c9e3 100644
--- a/tp/Texinfo/XS/teximakehtml.c
+++ b/tp/Texinfo/XS/teximakehtml.c
@@ -104,7 +104,7 @@ main (int argc, char *argv[])
 
   locale_encoding = nl_langinfo (CODESET);
 
-  initialize_options_list (&cmdline_options, 2);
+  initialize_options_list (&cmdline_options);
   /*
   add_new_option_value (&cmdline_options, GOT_integer,
                            "DEBUG", 1, 0);
@@ -191,8 +191,7 @@ main (int argc, char *argv[])
   txi_converter_output_format_setup ("html");
 
   /*
-  add_new_option_value (&cmdline_options, GOT_integer,
-                        "TEXI2HTML", 1, 0);
+  add_option_value (&cmdline_options, "TEXI2HTML", 1, 0);
    */
 
   /* FORMAT_MENU for parser should be set based on converter_defaults taking 
into
@@ -202,10 +201,9 @@ main (int argc, char *argv[])
    */
 
   /* TODO add cmdline_options filtering in only parser options */
-  initialize_options_list (&parser_options, 2);
+  initialize_options_list (&parser_options);
   /*
-  add_new_option_value (&parser_options, GOT_integer,
-                           "DEBUG", 1, 0);
+  add_option_value (&parser_options, "DEBUG", 1, 0);
    */
   if (test)
     {
@@ -261,7 +259,7 @@ main (int argc, char *argv[])
   errors_count += errors_nr;
 
   /* conversion initialization */
-  initialize_options_list (&convert_options, 2);
+  initialize_options_list (&convert_options);
 
   if (test)
     {



reply via email to

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