texinfo-commits
[Top][All Lists]
Advanced

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

[no subject]


From: Patrice Dumas
Date: Wed, 25 Dec 2024 16:12:15 -0500 (EST)

branch: master
commit 3deb8dab5e92a66d16ade4bd9e3a50169a85f55c
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Wed Dec 25 22:12:10 2024 +0100

    * tp/Texinfo/XS/main/document.c (set_document_options): replace
    initialize_document_options by set_document_options, which uses a
    temporary OPTIONS_LIST and uses program_options, cmdline_options
    and init_files_options too to set document options.  Similar to Perl
    code setting MainConfig, filling with document options, calling
    get_customization_options_hash and register_document_options.
    
    * tp/Texinfo/XS/convert/texinfo.c (txi_complete_document),
    tp/Texinfo/XS/texi2any.c (main): call set_document_options in main
    program, not in txi_complete_document.
---
 ChangeLog                       | 13 +++++++++++
 tp/Texinfo/XS/convert/texinfo.c |  2 --
 tp/Texinfo/XS/main/document.c   | 50 ++++++++++++++++++++++++++++++++++++-----
 tp/Texinfo/XS/main/document.h   |  5 ++++-
 tp/Texinfo/XS/texi2any.c        |  5 +++++
 5 files changed, 66 insertions(+), 9 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 7450b5bfdf..247570ddca 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2024-12-25  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/main/document.c (set_document_options): replace
+       initialize_document_options by set_document_options, which uses a
+       temporary OPTIONS_LIST and uses program_options, cmdline_options
+       and init_files_options too to set document options.  Similar to Perl
+       code setting MainConfig, filling with document options, calling
+       get_customization_options_hash and register_document_options.
+
+       * tp/Texinfo/XS/convert/texinfo.c (txi_complete_document),
+       tp/Texinfo/XS/texi2any.c (main): call set_document_options in main
+       program, not in txi_complete_document.
+
 2024-12-25  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/main/customization_options.c
diff --git a/tp/Texinfo/XS/convert/texinfo.c b/tp/Texinfo/XS/convert/texinfo.c
index 14dbc050d0..aa331315fc 100644
--- a/tp/Texinfo/XS/convert/texinfo.c
+++ b/tp/Texinfo/XS/convert/texinfo.c
@@ -403,8 +403,6 @@ txi_complete_document (DOCUMENT *document, unsigned long 
flags,
   CONST_ELEMENT_LIST *sections_list;
   int use_sections = (flags & STTF_complete_menus_use_sections);
 
-  initialize_document_options (document);
-
   if (flags & STTF_relate_index_entries_to_table_items)
     relate_index_entries_to_table_items_in_tree (document->tree,
                                            &document->indices_info);
diff --git a/tp/Texinfo/XS/main/document.c b/tp/Texinfo/XS/main/document.c
index 5da9009380..4a6d77fa44 100644
--- a/tp/Texinfo/XS/main/document.c
+++ b/tp/Texinfo/XS/main/document.c
@@ -143,17 +143,30 @@ set_output_encoding (OPTIONS *customization_information, 
DOCUMENT *document)
 }
 
 /* not used when document options are set from Perl */
+/* mixes main program Perl code setting $main_configuration,
+   get_customization_options_hash() call and register_document_options
+ */
 void
-initialize_document_options (DOCUMENT *document)
+set_document_options (DOCUMENT *document, const OPTIONS_LIST *program_options,
+                      const OPTIONS_LIST *cmdline_options,
+                      const OPTIONS_LIST *init_files_options)
 {
+  OPTIONS_LIST document_options;
+  const ELEMENT *document_language;
   OPTIONS *options = new_options ();
   OPTION **sorted_options = new_sorted_options (options);
-  const ELEMENT *document_language;
 
-  register_document_options (document, options, sorted_options);
+  initialize_options_list (&document_options);
+  copy_options_list (&document_options, program_options);
 
+  /* specific document options based on the document */
   if (document->global_commands.novalidate)
-    document->options->novalidate.o.integer = 1;
+    {
+      OPTION *novalidate_option = &document_options.options->novalidate;
+      novalidate_option->o.integer = 1;
+      options_list_add_option_number (&document_options,
+                                      novalidate_option->number);
+    }
 
   document_language
     = get_global_document_command (&document->global_commands,
@@ -161,9 +174,34 @@ initialize_document_options (DOCUMENT *document)
   if (document_language)
     {
       const char *language = informative_command_value (document_language);
-      option_set_conf (&document->options->documentlanguage, -1, language);
+      OPTION *documentlanguage_option
+        = &document_options.options->documentlanguage;
+      option_set_conf (documentlanguage_option, -1, language);
+      options_list_add_option_number (&document_options,
+                                      documentlanguage_option->number);
     }
-  set_output_encoding (document->options, document);
+
+  /* similar to set_output_encoding but for OPTIONS_LIST */
+  if (document->global_info.input_encoding_name)
+    {
+      OPTION *output_encoding_name_option
+        = &document_options.options->OUTPUT_ENCODING_NAME;
+      option_set_conf (output_encoding_name_option, -1,
+                       document->global_info.input_encoding_name);
+      options_list_add_option_number (&document_options,
+                                      output_encoding_name_option->number);
+    }
+
+  copy_options_list (&document_options, init_files_options);
+  copy_options_list (&document_options, cmdline_options);
+
+  copy_options_list_set_configured (options,
+                                    sorted_options,
+                                    &document_options, 0);
+
+  clear_options_list (&document_options);
+
+  register_document_options (document, options, sorted_options);
 }
 
 const MERGED_INDICES *
diff --git a/tp/Texinfo/XS/main/document.h b/tp/Texinfo/XS/main/document.h
index f92594c348..8a541c63f2 100644
--- a/tp/Texinfo/XS/main/document.h
+++ b/tp/Texinfo/XS/main/document.h
@@ -24,7 +24,10 @@ void register_document_options (DOCUMENT *document, OPTIONS 
*options,
 void register_document_convert_index_text_options (DOCUMENT *document,
                                          struct TEXT_OPTIONS *text_options);
 
-void initialize_document_options (DOCUMENT *document);
+void set_document_options (DOCUMENT *document,
+                      const OPTIONS_LIST *program_options,
+                      const OPTIONS_LIST *cmdline_options,
+                      const OPTIONS_LIST *init_files_options);
 
 const MERGED_INDICES *document_merged_indices (DOCUMENT *document);
 const INDICES_SORT_STRINGS *document_indices_sort_strings (
diff --git a/tp/Texinfo/XS/texi2any.c b/tp/Texinfo/XS/texi2any.c
index 53b8a6fc47..6e519e9a5a 100644
--- a/tp/Texinfo/XS/texi2any.c
+++ b/tp/Texinfo/XS/texi2any.c
@@ -57,6 +57,8 @@
 #include "utils.h"
 #include "customization_options.h"
 #include "txi_config.h"
+/* set_document_options */
+#include "document.h"
 #include "convert_to_texinfo.h"
 #include "create_buttons.h"
 /* needed because commands are used to determine expanded regions names */
@@ -2104,6 +2106,9 @@ main (int argc, char *argv[], char *env[])
 
       errors_count = handle_errors (errors_nr, errors_count, &opened_files);
 
+      set_document_options (document, &program_options, &cmdline_options,
+                            init_files_options);
+
       macro_expand_option
         = GNUT_get_conf (program_options.options->MACRO_EXPAND.number);
       if (macro_expand_option && macro_expand_option->o.string && i == 0)



reply via email to

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