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 (set


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/XS/main/customization_options.c (set_informative_command_value, set_global_document_command), tp/Texinfo/XS/main/utils.c: move set_informative_command_value and set_global_document_command to customization_options.c.
Date: Fri, 04 Oct 2024 19:58:43 -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 230addc237 * tp/Texinfo/XS/main/customization_options.c 
(set_informative_command_value, set_global_document_command), 
tp/Texinfo/XS/main/utils.c: move set_informative_command_value and 
set_global_document_command to customization_options.c.
230addc237 is described below

commit 230addc2373cbaf5367b02c2ea5b403418264c92
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Aug 17 23:52:52 2024 +0200

    * tp/Texinfo/XS/main/customization_options.c
    (set_informative_command_value, set_global_document_command),
    tp/Texinfo/XS/main/utils.c: move set_informative_command_value and
    set_global_document_command to customization_options.c.
    
    * tp/Texinfo/XS/main/document.c (set_output_encoding),
    tp/Texinfo/XS/main/utils.c: move set_output_encoding to document.c.
    
    * tp/Texinfo/XS/main/document.c (initialize_document_options): call
    option_set_conf.
    
    * tp/Texinfo/XS/main/utils.c: remove now unused set_conf_string.
---
 ChangeLog                                  | 15 ++++++
 tp/Texinfo/XS/main/customization_options.c | 47 +++++++++++++++++++
 tp/Texinfo/XS/main/customization_options.h |  6 +++
 tp/Texinfo/XS/main/document.c              | 16 +++++--
 tp/Texinfo/XS/main/document.h              |  3 ++
 tp/Texinfo/XS/main/utils.c                 | 73 ------------------------------
 tp/Texinfo/XS/main/utils.h                 |  6 ---
 7 files changed, 84 insertions(+), 82 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 1fac1bb7cc..30cdce28b4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2024-08-17  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/main/customization_options.c
+       (set_informative_command_value, set_global_document_command),
+       tp/Texinfo/XS/main/utils.c: move set_informative_command_value and
+       set_global_document_command to customization_options.c.
+
+       * tp/Texinfo/XS/main/document.c (set_output_encoding),
+       tp/Texinfo/XS/main/utils.c: move set_output_encoding to document.c.
+
+       * tp/Texinfo/XS/main/document.c (initialize_document_options): call
+       option_set_conf.
+
+       * tp/Texinfo/XS/main/utils.c: remove now unused set_conf_string.
+
 2024-08-17  Patrice Dumas  <pertusus@free.fr>
 
        * tp/t/input_files/last_file_same_parser.texi: add an @include.
diff --git a/tp/Texinfo/XS/main/customization_options.c 
b/tp/Texinfo/XS/main/customization_options.c
index 843b6040c1..1a06d5e407 100644
--- a/tp/Texinfo/XS/main/customization_options.c
+++ b/tp/Texinfo/XS/main/customization_options.c
@@ -22,7 +22,10 @@
 #include "options_types.h"
 #include "converter_types.h"
 #include "api_to_perl.h"
+/* *_strings_list html_clear_direction_icons 
html_free_button_specification_list
+ */
 #include "utils.h"
+#include "builtin_commands.h"
 #include "customization_options.h"
 
 
@@ -580,3 +583,47 @@ free_options_list (OPTIONS_LIST *options_list)
   free (options_list->list);
 }
 
+
+void
+set_informative_command_value (OPTIONS *options, const ELEMENT *element)
+{
+  const char *value = 0;
+
+  value = informative_command_value (element);
+
+  if (value)
+    {
+      OPTION *option;
+      enum command_id cmd = element_builtin_cmd (element);
+      if (cmd == CM_summarycontents)
+        cmd = CM_shortcontents;
+
+      option = get_command_option (options, cmd);
+      if (option)
+        {
+          int int_value = -1;
+          if (option->type == GOT_integer)
+            int_value = strtoul (value, NULL, 10);
+          option_set_conf (option, int_value, value);
+        }
+    }
+}
+
+/*
+  Notice that the only effect is to use set_conf (directly or through
+  set_informative_command_value), no @-commands setting side effects are done
+  and associated customization variables are not set/reset either.
+ */
+const ELEMENT *
+set_global_document_command (GLOBAL_COMMANDS *global_commands, OPTIONS 
*options,
+                             enum command_id cmd,
+                             enum command_location command_location)
+{
+  const ELEMENT *element
+     = get_global_document_command (global_commands, cmd,
+                                    command_location);
+  if (element)
+    set_informative_command_value (options, element);
+  return element;
+}
+
diff --git a/tp/Texinfo/XS/main/customization_options.h 
b/tp/Texinfo/XS/main/customization_options.h
index 4255450151..e43b42dc02 100644
--- a/tp/Texinfo/XS/main/customization_options.h
+++ b/tp/Texinfo/XS/main/customization_options.h
@@ -19,6 +19,8 @@
 
 #include "option_types.h"
 #include "options_types.h"
+/* for enum command_location */
+#include "document_types.h"
 #include "converter_types.h"
 
 /* in options_init_free.c */
@@ -65,4 +67,8 @@ void copy_options_list (OPTIONS_LIST *options_list,
                         const OPTIONS_LIST *options_src);
 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,
+                             enum command_location command_location);
 #endif
diff --git a/tp/Texinfo/XS/main/document.c b/tp/Texinfo/XS/main/document.c
index 3b80ebc1d6..39d735a3c6 100644
--- a/tp/Texinfo/XS/main/document.c
+++ b/tp/Texinfo/XS/main/document.c
@@ -124,6 +124,18 @@ register_document_options (DOCUMENT *document, OPTIONS 
*options,
   document->sorted_options = sorted_options;
 }
 
+/* In perl, OUTPUT_PERL_ENCODING is set too.  Note that if the perl
+   version is called later on, the OUTPUT_ENCODING_NAME value will be re-set */
+void
+set_output_encoding (OPTIONS *customization_information, DOCUMENT *document)
+{
+  if (customization_information
+      && document && document->global_info.input_encoding_name) {
+    option_set_conf (&customization_information->OUTPUT_ENCODING_NAME, -1,
+                     document->global_info.input_encoding_name);
+  }
+}
+
 /* not used when document options are set from Perl */
 void
 initialize_document_options (DOCUMENT *document)
@@ -143,9 +155,7 @@ initialize_document_options (DOCUMENT *document)
   if (document_language)
     {
       const char *language = informative_command_value (document_language);
-      /* TODO use set_conf_string? or add set_conf in utils.h */
-      document->options->documentlanguage.o.string
-       = strdup (language);
+      option_set_conf (&document->options->documentlanguage, -1, language);
     }
   set_output_encoding (document->options, document);
 }
diff --git a/tp/Texinfo/XS/main/document.h b/tp/Texinfo/XS/main/document.h
index 407f1f7805..e991b7e5b6 100644
--- a/tp/Texinfo/XS/main/document.h
+++ b/tp/Texinfo/XS/main/document.h
@@ -51,6 +51,9 @@ ELEMENT *unregister_document_merge_with_document (size_t 
document_descriptor,
 void add_other_global_info_string (OTHER_GLOBAL_INFO *other_global_info,
                                    const char *key, const char *value);
 
+void set_output_encoding (OPTIONS *customization_information,
+                          DOCUMENT *document);
+
 void wipe_document_parser_errors (size_t document_descriptor);
 void wipe_document_errors (size_t document_descriptor);
 
diff --git a/tp/Texinfo/XS/main/utils.c b/tp/Texinfo/XS/main/utils.c
index c98002b1a1..4e4314c9a3 100644
--- a/tp/Texinfo/XS/main/utils.c
+++ b/tp/Texinfo/XS/main/utils.c
@@ -1103,33 +1103,6 @@ destroy_strings_list (STRING_LIST *strings)
 
 
 
-/* FIXME does something similar as set_conf in converter.c */
-static void
-set_conf_string (OPTION *option, const char *value)
-{
-  if (option->type != GOT_char && option->type != GOT_bytes)
-    fatal ("set_conf_string bad option type\n");
-
-  if (option->configured > 0)
-    return;
-
-  free (option->o.string);
-  option->o.string = strdup (value);
-}
-
-/* In perl, OUTPUT_PERL_ENCODING is set too.  Note that if the perl
-   version is called later on, the OUTPUT_ENCODING_NAME value will be re-set */
-void
-set_output_encoding (OPTIONS *customization_information, DOCUMENT *document)
-{
-  if (customization_information
-      && document && document->global_info.input_encoding_name) {
-    set_conf_string (&customization_information->OUTPUT_ENCODING_NAME,
-                      document->global_info.input_encoding_name);
-  }
-}
-
-
 /* code related to values used in files not in parsetexi */
 void
 wipe_values (VALUE_LIST *values)
@@ -1293,34 +1266,6 @@ informative_command_value (const ELEMENT *element)
   return 0;
 }
 
-void
-set_informative_command_value (OPTIONS *options, const ELEMENT *element)
-{
-  char *value = 0;
-
-  value = informative_command_value (element);
-
-  if (value)
-    {
-      OPTION *option;
-      enum command_id cmd = element_builtin_cmd (element);
-      if (cmd == CM_summarycontents)
-        cmd = CM_shortcontents;
-
-      option = get_command_option (options, cmd);
-      if (option)
-        {
-          if (option->type == GOT_integer)
-            {
-              if (option->configured <= 0)
-                option->o.integer = strtoul (value, NULL, 10);
-            }
-          else
-            set_conf_string (option, value);
-        }
-    }
-}
-
 static int
 in_preamble (ELEMENT *element)
 {
@@ -1400,24 +1345,6 @@ get_global_document_command (const GLOBAL_COMMANDS 
*global_commands,
   return element;
 }
 
-/*
-  Notice that the only effect is to use set_conf (directly or through
-  set_informative_command_value), no @-commands setting side effects are done
-  and associated customization variables are not set/reset either.
- */
-const ELEMENT *
-set_global_document_command (GLOBAL_COMMANDS *global_commands, OPTIONS 
*options,
-                             enum command_id cmd,
-                             enum command_location command_location)
-{
-  const ELEMENT *element
-     = get_global_document_command (global_commands, cmd,
-                                    command_location);
-  if (element)
-    set_informative_command_value (options, element);
-  return element;
-}
-
 
 void
 destroy_accent_stack (ACCENTS_STACK *accent_stack)
diff --git a/tp/Texinfo/XS/main/utils.h b/tp/Texinfo/XS/main/utils.h
index 5155a422fc..580fa9b601 100644
--- a/tp/Texinfo/XS/main/utils.h
+++ b/tp/Texinfo/XS/main/utils.h
@@ -187,8 +187,6 @@ void destroy_accent_stack (ACCENTS_STACK *accent_stack);
 void wipe_index (INDEX *idx);
 void free_indices_info (INDEX_LIST *indices_info);
 
-void set_output_encoding (OPTIONS *customization_information,
-                          DOCUMENT *document);
 /* in options_init_free.c */
 OPTION *get_command_option (OPTIONS *options, enum command_id cmd);
 
@@ -222,10 +220,6 @@ const ELEMENT *get_global_document_command (
                                       enum command_id cmd,
                                       enum command_location command_location);
 char *informative_command_value (const ELEMENT *element);
-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,
-                             enum command_location command_location);
 const ELEMENT_LIST *get_cmd_global_multi_command (
                                     const GLOBAL_COMMANDS *global_commands_ref,
                                     enum command_id cmd);



reply via email to

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