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: reo


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/XS/main/customization_options.c: reorder code, add form feed delimited sections.
Date: Fri, 04 Oct 2024 20:06:26 -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 d2a0b9473d * tp/Texinfo/XS/main/customization_options.c: reorder code, 
add form feed delimited sections.
d2a0b9473d is described below

commit d2a0b9473da0e6369866fd1b88254f9d551c0988
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Aug 18 08:54:16 2024 +0200

    * tp/Texinfo/XS/main/customization_options.c: reorder code, add
    form feed delimited sections.
---
 ChangeLog                                  |   5 +
 tp/Texinfo/XS/main/customization_options.c | 214 ++++++++++++++++-------------
 tp/Texinfo/XS/main/customization_options.h |  44 +++---
 3 files changed, 147 insertions(+), 116 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 0e05b402c8..9504f0b24f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2024-08-18  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/main/customization_options.c: reorder code, add
+       form feed delimited sections.
+
 2024-08-18  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/Makefile.am (libtexinfo_la_SOURCES, BUILT_SOURCES)
diff --git a/tp/Texinfo/XS/main/customization_options.c 
b/tp/Texinfo/XS/main/customization_options.c
index 1a06d5e407..5a9cd01a60 100644
--- a/tp/Texinfo/XS/main/customization_options.c
+++ b/tp/Texinfo/XS/main/customization_options.c
@@ -29,7 +29,9 @@
 #include "customization_options.h"
 
 
-/* options and converters */
+
+/* single option and options structure functions */
+
 OPTIONS *
 new_options (void)
 {
@@ -39,48 +41,6 @@ new_options (void)
   return options;
 }
 
-static int
-compare_option_str (const void *a, const void *b)
-{
-  const OPTION **opt_a = (const OPTION **) a;
-  const OPTION **opt_b = (const OPTION **) b;
-
-  return strcmp ((*opt_a)->name, (*opt_b)->name);
-}
-
-/* sort options and set the index in the option structure to the index in
-   the sorted array */
-OPTION **
-setup_sorted_options (OPTIONS *options)
-{
-  size_t i;
-  OPTION **sorted_options = setup_sortable_options (options);
-  qsort (sorted_options, TXI_OPTIONS_NR, sizeof (OPTION *), 
compare_option_str);
-
-  for (i = 0; i < TXI_OPTIONS_NR; i++)
-    {
-      sorted_options[i]->number = i + 1;
-    }
-
-  return sorted_options;
-}
-
-OPTION *
-find_option_string (OPTION **sorted_options, const char *name)
-{
-  static OPTION option_key;
-  OPTION *option_ref = &option_key;
-  OPTION **result;
-
-  option_key.name = name;
-  result = (OPTION **)bsearch (&option_ref, sorted_options, TXI_OPTIONS_NR,
-                               sizeof (OPTION *), compare_option_str);
-  if (result)
-    return *result;
-  else
-    return 0;
-}
-
 void
 clear_option (OPTION *option)
 {
@@ -188,6 +148,19 @@ initialize_option (OPTION *option, enum global_option_type 
type,
     }
 }
 
+/* note that the value in union o is not initialized */
+OPTION *
+new_option (enum global_option_type type, const char *name, size_t number)
+{
+  OPTION *option = (OPTION *) malloc (sizeof (OPTION));
+
+  initialize_option (option, type, name);
+  option->number = number;
+  option->configured = 0;
+
+  return option;
+}
+
 /* only for strings and integers */
 static void
 option_set_conf_internal (OPTION *option, int int_value, const char 
*char_value)
@@ -376,31 +349,50 @@ copy_option (OPTION *destination, const OPTION *source)
     }
 }
 
-void
-set_sorted_option_key_configured (OPTION **sorted_options, const char *key,
-                                  int configured)
+
+
+/* functions setup and use sorted options */
+
+static int
+compare_option_str (const void *a, const void *b)
 {
-  if (configured > 0)
-    {
-      OPTION *option = find_option_string (sorted_options, key);
+  const OPTION **opt_a = (const OPTION **) a;
+  const OPTION **opt_b = (const OPTION **) b;
 
-      if (option)
-        option->configured = configured;
-    }
+  return strcmp ((*opt_a)->name, (*opt_b)->name);
 }
 
-void
-initialize_options_list (OPTIONS_LIST *options_list, size_t number)
+/* sort options and set the index in the option structure to the index in
+   the sorted array */
+OPTION **
+setup_sorted_options (OPTIONS *options)
 {
-  options_list->number = 0;
-  options_list->space = number;
-  if (number > 0)
+  size_t i;
+  OPTION **sorted_options = setup_sortable_options (options);
+  qsort (sorted_options, TXI_OPTIONS_NR, sizeof (OPTION *), 
compare_option_str);
+
+  for (i = 0; i < TXI_OPTIONS_NR; i++)
     {
-      options_list->list = (OPTION **) malloc (sizeof (OPTION *) * number);
-      memset (options_list->list, 0, sizeof (OPTION *) * number);
+      sorted_options[i]->number = i + 1;
     }
+
+  return sorted_options;
+}
+
+OPTION *
+find_option_string (OPTION **sorted_options, const char *name)
+{
+  static OPTION option_key;
+  OPTION *option_ref = &option_key;
+  OPTION **result;
+
+  option_key.name = name;
+  result = (OPTION **)bsearch (&option_ref, sorted_options, TXI_OPTIONS_NR,
+                               sizeof (OPTION *), compare_option_str);
+  if (result)
+    return *result;
   else
-    options_list->list = 0;
+    return 0;
 }
 
 /* copy OPTIONS_LIST options to an OPTIONS structure, using the sorted options
@@ -435,17 +427,17 @@ copy_numbered_options_list_options (OPTIONS *options,
     }
 }
 
-/* note that the value in union o is not initialized */
-OPTION *
-new_option (enum global_option_type type, const char *name, size_t number)
+void
+set_sorted_option_key_configured (OPTION **sorted_options, const char *key,
+                                  int configured)
 {
-  OPTION *option = (OPTION *) malloc (sizeof (OPTION));
-
-  initialize_option (option, type, name);
-  option->number = number;
-  option->configured = 0;
+  if (configured > 0)
+    {
+      OPTION *option = find_option_string (sorted_options, key);
 
-  return option;
+      if (option)
+        option->configured = configured;
+    }
 }
 
 static OPTION *
@@ -465,6 +457,25 @@ new_option_string_value (OPTION **sorted_options,
   return option;
 }
 
+
+
+/* functions to set and use options list.  Functions in this section do
+   not need options to be numbered */
+
+void
+initialize_options_list (OPTIONS_LIST *options_list, size_t number)
+{
+  options_list->number = 0;
+  options_list->space = number;
+  if (number > 0)
+    {
+      options_list->list = (OPTION **) malloc (sizeof (OPTION *) * number);
+      memset (options_list->list, 0, sizeof (OPTION *) * number);
+    }
+  else
+    options_list->list = 0;
+}
+
 void
 options_list_add_option (OPTIONS_LIST *options_list, OPTION *option)
 {
@@ -477,21 +488,7 @@ options_list_add_option (OPTIONS_LIST *options_list, 
OPTION *option)
   options_list->number++;
 }
 
-OPTION *
-add_option_string_value (OPTIONS_LIST *options_list, OPTION **sorted_options,
-                         const char *option_name, int int_value,
-                         const char *char_value)
-{
-  OPTION *option = new_option_string_value (sorted_options, option_name,
-                                            int_value, char_value);
-
-  if (option)
-    options_list_add_option (options_list, option);
-
-  return option;
-}
-
-OPTION *
+static OPTION *
 add_option_copy (OPTIONS_LIST *options_list, const OPTION *src_option)
 {
   OPTION *option
@@ -546,6 +543,38 @@ copy_options_list (OPTIONS_LIST *options_list, const 
OPTIONS_LIST *options_src)
     }
 }
 
+void
+free_options_list (OPTIONS_LIST *options_list)
+{
+  size_t i;
+
+  for (i = 0; i < options_list->number; i++)
+    {
+      free_option (options_list->list[i]);
+      free (options_list->list[i]);
+    }
+
+  free (options_list->list);
+}
+
+
+
+/* options list functions for numbered options */
+
+OPTION *
+add_option_string_value (OPTIONS_LIST *options_list, OPTION **sorted_options,
+                         const char *option_name, int int_value,
+                         const char *char_value)
+{
+  OPTION *option = new_option_string_value (sorted_options, option_name,
+                                            int_value, char_value);
+
+  if (option)
+    options_list_add_option (options_list, option);
+
+  return option;
+}
+
 void
 number_options_list (OPTIONS_LIST *options_list, OPTION **sorted_options)
 {
@@ -567,22 +596,9 @@ number_options_list (OPTIONS_LIST *options_list, OPTION 
**sorted_options)
     }
 }
 
+
 
-
-void
-free_options_list (OPTIONS_LIST *options_list)
-{
-  size_t i;
-
-  for (i = 0; i < options_list->number; i++)
-    {
-      free_option (options_list->list[i]);
-      free (options_list->list[i]);
-    }
-
-  free (options_list->list);
-}
-
+/* misc other functions */
 
 void
 set_informative_command_value (OPTIONS *options, const ELEMENT *element)
diff --git a/tp/Texinfo/XS/main/customization_options.h 
b/tp/Texinfo/XS/main/customization_options.h
index e43b42dc02..9ad3a3ecb7 100644
--- a/tp/Texinfo/XS/main/customization_options.h
+++ b/tp/Texinfo/XS/main/customization_options.h
@@ -30,31 +30,32 @@ void clear_options (OPTIONS *options);
 void free_options (OPTIONS *options);
 void copy_options (OPTIONS *destination, const OPTIONS *source);
 
-void copy_numbered_options_list_options (OPTIONS *options,
-                                OPTION **sorted_options,
-                                OPTIONS_LIST *options_list, int 
set_configured);
-void initialize_options_list (OPTIONS_LIST *options_list, size_t number);
-void free_options_list (OPTIONS_LIST *options_list);
 
 OPTIONS *new_options (void);
-OPTION **setup_sorted_options (OPTIONS *options);
-OPTION *find_option_string (OPTION **sorted_options, const char *name);
-void set_sorted_option_key_configured (OPTION **sorted_options,
-                                       const char *key, int configured);
 
+void clear_option (OPTION *option);
+void free_option (OPTION *option);
 void initialize_option (OPTION *option, enum global_option_type type,
                         const char *name);
 OPTION *new_option (enum global_option_type type, const char *name,
                     size_t number);
-void clear_option (OPTION *option);
-void free_option (OPTION *option);
-void copy_option (OPTION *destination, const OPTION *source);
 int option_set_conf (OPTION *option, int int_value, const char *char_value);
 void option_force_conf (OPTION *option, int int_value, const char *char_value);
-OPTION *add_option_string_value (OPTIONS_LIST *options_list,
-                         OPTION **sorted_options,
-                         const char *option_name, int int_value,
-                         const char *char_value);
+void copy_option (OPTION *destination, const OPTION *source);
+
+
+
+OPTION **setup_sorted_options (OPTIONS *options);
+OPTION *find_option_string (OPTION **sorted_options, const char *name);
+void copy_numbered_options_list_options (OPTIONS *options,
+                                OPTION **sorted_options,
+                                OPTIONS_LIST *options_list, int 
set_configured);
+void set_sorted_option_key_configured (OPTION **sorted_options,
+                                       const char *key, int configured);
+
+
+
+void initialize_options_list (OPTIONS_LIST *options_list, size_t number);
 void options_list_add_option (OPTIONS_LIST *options_list, OPTION *option);
 OPTION *add_new_option_value (OPTIONS_LIST *options_list,
                   enum global_option_type type, const char *name,
@@ -62,11 +63,20 @@ OPTION *add_new_option_value (OPTIONS_LIST *options_list,
 OPTION *add_new_button_option (OPTIONS_LIST *options_list,
                               const char *option_name,
                               BUTTON_SPECIFICATION_LIST *buttons);
-
 void copy_options_list (OPTIONS_LIST *options_list,
                         const OPTIONS_LIST *options_src);
+void free_options_list (OPTIONS_LIST *options_list);
+
+
+
+OPTION *add_option_string_value (OPTIONS_LIST *options_list,
+                         OPTION **sorted_options,
+                         const char *option_name, int int_value,
+                         const char *char_value);
 void number_options_list (OPTIONS_LIST *options_list, OPTION **sorted_options);
 
+
+
 void set_informative_command_value (OPTIONS *options, const ELEMENT *element);
 const ELEMENT *set_global_document_command (GLOBAL_COMMANDS *global_commands,
                              OPTIONS *options, enum command_id cmd,



reply via email to

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