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


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/XS/convert/converter.c (set_converter_init_information) (free_generic_converter), tp/Texinfo/XS/main/converter_types.h (CONVERTER): add format_defaults_conf OPTIONS field to converter. Set format_defaults_conf OPTIONS structure based on format_defaults options list in set_converter_init_information.
Date: Sat, 05 Oct 2024 02:28:14 -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 d8be5cc7ce * tp/Texinfo/XS/convert/converter.c 
(set_converter_init_information) (free_generic_converter), 
tp/Texinfo/XS/main/converter_types.h (CONVERTER):  add format_defaults_conf 
OPTIONS field to converter. Set format_defaults_conf OPTIONS structure based on 
format_defaults options list in set_converter_init_information.
d8be5cc7ce is described below

commit d8be5cc7ce35742624ecfa3c5c0763a6bc1a76a6
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Aug 18 16:43:45 2024 +0200

    * tp/Texinfo/XS/convert/converter.c (set_converter_init_information)
    (free_generic_converter), tp/Texinfo/XS/main/converter_types.h
    (CONVERTER):  add format_defaults_conf OPTIONS field to converter.
    Set format_defaults_conf OPTIONS structure based on format_defaults
    options list in set_converter_init_information.
    
    * tp/Texinfo/XS/convert/html_prepare_converter.c
    (html_converter_initialize_beginning): use self->format_defaults_conf
    to set MAX_HEADER_LEVEL if < 0.
    
    * tp/Texinfo/XS/convert/html_prepare_converter.c (html_setup_output):
    use txi_base_options to set HANDLER_FATAL_ERROR_LEVEL if < 0.
    
    * tp/Texinfo/XS/convert/format_html.c
    (html_default_format_heading_text): simplify setting heading level,
    doing as in Perl.
    
    * tp/Texinfo/XS/convert/converter.c (converter_converter): assume that
    format_defaults is always set.
---
 ChangeLog                                      | 22 ++++++++++++++
 tp/Texinfo/XS/convert/converter.c              | 41 ++++++++++++++++++--------
 tp/Texinfo/XS/convert/format_html.c            | 17 ++---------
 tp/Texinfo/XS/convert/html_prepare_converter.c |  7 +++--
 tp/Texinfo/XS/main/converter_types.h           |  3 +-
 tp/Texinfo/XS/main/customization_options.h     |  5 ++--
 6 files changed, 61 insertions(+), 34 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b3deee7a2b..2738342f90 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2024-08-18  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/convert/converter.c (set_converter_init_information)
+       (free_generic_converter), tp/Texinfo/XS/main/converter_types.h
+       (CONVERTER):  add format_defaults_conf OPTIONS field to converter.
+       Set format_defaults_conf OPTIONS structure based on format_defaults
+       options list in set_converter_init_information.
+
+       * tp/Texinfo/XS/convert/html_prepare_converter.c
+       (html_converter_initialize_beginning): use self->format_defaults_conf
+       to set MAX_HEADER_LEVEL if < 0.
+
+       * tp/Texinfo/XS/convert/html_prepare_converter.c (html_setup_output):
+       use txi_base_options to set HANDLER_FATAL_ERROR_LEVEL if < 0.
+
+       * tp/Texinfo/XS/convert/format_html.c
+       (html_default_format_heading_text): simplify setting heading level,
+       doing as in Perl.
+
+       * tp/Texinfo/XS/convert/converter.c (converter_converter): assume that
+       format_defaults is always set.
+
 2024-08-18  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/Makefile.am (BUILT_SOURCES, options_init_free.c),
diff --git a/tp/Texinfo/XS/convert/converter.c 
b/tp/Texinfo/XS/convert/converter.c
index 71c5f8c656..2444684fec 100644
--- a/tp/Texinfo/XS/convert/converter.c
+++ b/tp/Texinfo/XS/convert/converter.c
@@ -345,11 +345,18 @@ set_converter_init_information (CONVERTER *converter,
                             CONVERTER_INITIALIZATION_INFO *format_defaults,
                             CONVERTER_INITIALIZATION_INFO *user_conf)
 {
-  /* the case of format_defaults not set should correspond to
-     format_defaults C functions that sets the converter conf and return
-     0 */
-  if (format_defaults)
-    apply_converter_info (converter, format_defaults, 0);
+  OPTION **format_defaults_sorted_options;
+
+  apply_converter_info (converter, format_defaults, 0);
+
+  /* Also keep format_defaults options as an OPTIONS structure */
+  converter->format_defaults_conf = new_options ();
+  format_defaults_sorted_options
+    = new_sorted_options (converter->format_defaults_conf);
+  copy_numbered_options_list_options (converter->format_defaults_conf,
+                                      format_defaults_sorted_options,
+                                      &format_defaults->conf, 0);
+  free (format_defaults_sorted_options);
 
   if (user_conf)
     apply_converter_info (converter, user_conf, 1);
@@ -474,14 +481,12 @@ converter_converter (enum converter_format format,
 
   format_defaults = converter_defaults (converter->format, user_conf);
 
-  if (format_defaults)
-    number_options_list (&format_defaults->conf, converter->sorted_options);
+  number_options_list (&format_defaults->conf, converter->sorted_options);
 
   set_converter_init_information (converter, format, format_defaults,
                                   user_conf);
 
-  if (format_defaults)
-    destroy_converter_initialization_info (format_defaults);
+  destroy_converter_initialization_info (format_defaults);
 
   destroy_converter_initialization_info (user_conf);
 
@@ -1751,15 +1756,25 @@ free_generic_converter (CONVERTER *self)
   free (self->expanded_formats);
 
   if (self->init_conf)
-    free_options (self->init_conf);
-  free (self->init_conf);
+    {
+      free_options (self->init_conf);
+      free (self->init_conf);
+    }
 
   if (self->sorted_options)
     free (self->sorted_options);
 
   if (self->conf)
-    free_options (self->conf);
-  free (self->conf);
+    {
+      free_options (self->conf);
+      free (self->conf);
+    }
+
+  if (self->format_defaults_conf)
+    {
+      free_options (self->format_defaults_conf);
+      free (self->format_defaults_conf);
+    }
 
   if (self->convert_index_text_options)
     destroy_text_options (self->convert_index_text_options);
diff --git a/tp/Texinfo/XS/convert/format_html.c 
b/tp/Texinfo/XS/convert/format_html.c
index b7b8ff4e97..2800d04c50 100644
--- a/tp/Texinfo/XS/convert/format_html.c
+++ b/tp/Texinfo/XS/convert/format_html.c
@@ -2685,21 +2685,8 @@ html_default_format_heading_text (CONVERTER *self, const 
enum command_id cmd,
 
   if (level < 1)
     heading_level = 1;
-  else
-    {
-      /* TODO if defaults of converter options become more used in C code,
-         it could be relevant to predefine a table with code generated
-         by a specific Perl script with options defaults instead of
-         hardcoding */
-      int max_header_level = 4;
-      if (self->conf->MAX_HEADER_LEVEL.o.integer >= 1)
-        max_header_level = self->conf->MAX_HEADER_LEVEL.o.integer;
-      else if (self->conf->MAX_HEADER_LEVEL.o.integer == 0)
-        max_header_level = 1;
-
-      if (level > max_header_level)
-        heading_level = max_header_level;
-    }
+  else if (level > self->conf->MAX_HEADER_LEVEL.o.integer)
+    heading_level = self->conf->MAX_HEADER_LEVEL.o.integer;
   xasprintf (&heading_html_element, "h%d", heading_level);
 
   char *attribute_class
diff --git a/tp/Texinfo/XS/convert/html_prepare_converter.c 
b/tp/Texinfo/XS/convert/html_prepare_converter.c
index b56401bf44..130e843127 100644
--- a/tp/Texinfo/XS/convert/html_prepare_converter.c
+++ b/tp/Texinfo/XS/convert/html_prepare_converter.c
@@ -635,7 +635,8 @@ html_converter_initialize_beginning (CONVERTER *self)
     option_force_conf (&self->conf->SPLIT, 0, "node");
 
   if (max_header_level < 0)
-    option_force_conf (&self->conf->MAX_HEADER_LEVEL, 4, 0);
+    option_force_conf (&self->conf->MAX_HEADER_LEVEL,
+                  self->format_defaults_conf->MAX_HEADER_LEVEL.o.integer, 0);
   else if (max_header_level < 1)
     option_force_conf (&self->conf->MAX_HEADER_LEVEL, 1, 0);
 
@@ -2828,8 +2829,8 @@ html_setup_output (CONVERTER *self, char **paths)
   handler_fatal_error_level = self->conf->HANDLER_FATAL_ERROR_LEVEL.o.integer;
   if (handler_fatal_error_level < 0)
     {
-      handler_fatal_error_level = 100;
-      /* see options_data.txt. TODO automate? */
+      handler_fatal_error_level
+        = txi_base_options.HANDLER_FATAL_ERROR_LEVEL.o.integer;
       option_force_conf (&self->conf->HANDLER_FATAL_ERROR_LEVEL,
                          handler_fatal_error_level, 0);
     }
diff --git a/tp/Texinfo/XS/main/converter_types.h 
b/tp/Texinfo/XS/main/converter_types.h
index faa3a58ce9..e9016e1807 100644
--- a/tp/Texinfo/XS/main/converter_types.h
+++ b/tp/Texinfo/XS/main/converter_types.h
@@ -780,9 +780,10 @@ typedef struct CONVERTER {
        destroyed shortly after */
     CONVERTER_INITIALIZATION_INFO *format_defaults;
     OPTIONS *conf;
-    OPTIONS *init_conf;
     /* an array containing the fields of conf ordered by name */
     OPTION **sorted_options;
+    OPTIONS *init_conf;
+    OPTIONS *format_defaults_conf;
     char *output_format;
     char *converted_format;
     EXPANDED_FORMAT *expanded_formats;
diff --git a/tp/Texinfo/XS/main/customization_options.h 
b/tp/Texinfo/XS/main/customization_options.h
index 6eba37020f..ebe4a533e5 100644
--- a/tp/Texinfo/XS/main/customization_options.h
+++ b/tp/Texinfo/XS/main/customization_options.h
@@ -23,14 +23,15 @@
 #include "document_types.h"
 #include "converter_types.h"
 
+extern OPTIONS txi_base_options;
 extern OPTION *txi_base_sorted_options[TXI_OPTIONS_NR];
 
 /* in options_init_free.c */
 void initialize_options (OPTIONS *options);
-void setup_sortable_options (OPTION **to_sort, OPTIONS *options);
-void clear_options (OPTIONS *options);
 void free_options (OPTIONS *options);
+void clear_options (OPTIONS *options);
 void copy_options (OPTIONS *destination, const OPTIONS *source);
+void setup_sortable_options (OPTION **to_sort, OPTIONS *options);
 
 
 



reply via email to

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