texinfo-commits
[Top][All Lists]
Advanced

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

[no subject]


From: Patrice Dumas
Date: Sun, 19 Nov 2023 10:41:03 -0500 (EST)

branch: master
commit f5373d91378895888796daa1280ec23a37c6b1d9
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Nov 19 16:40:51 2023 +0100

    * tp/Texinfo/XS/convert/convert_html.c (command_conversion_external)
    (type_conversion_external, register_type_conversion_function)
    (register_command_conversion_function, html_converter_initialize)
    (html_destroy, html_convert_css_string, convert_to_html_internal),
    tp/Texinfo/XS/main/converter_types.h (CONVERTER): make
    type_conversion_function and command_conversion_function array
    of structures, not of pointers on structures.
---
 ChangeLog                            |  10 ++++
 tp/Texinfo/XS/convert/convert_html.c | 107 +++++++++++++----------------------
 tp/Texinfo/XS/main/converter_types.h |  17 ++----
 3 files changed, 54 insertions(+), 80 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 040c49cba5..28c0c4310a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2023-11-19  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/convert/convert_html.c (command_conversion_external)
+       (type_conversion_external, register_type_conversion_function)
+       (register_command_conversion_function, html_converter_initialize)
+       (html_destroy, html_convert_css_string, convert_to_html_internal),
+       tp/Texinfo/XS/main/converter_types.h (CONVERTER): make
+       type_conversion_function and command_conversion_function array
+       of structures, not of pointers on structures.
+
 2023-11-19  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/main/converter_types.h (TYPE_CONVERSION_FUNCTION)
diff --git a/tp/Texinfo/XS/convert/convert_html.c 
b/tp/Texinfo/XS/convert/convert_html.c
index bb1315643e..7db366d8a5 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -2640,7 +2640,7 @@ command_conversion_external (CONVERTER *self, const enum 
command_id cmd,
    */
 
   FORMATTING_REFERENCE *formatting_reference
-    = self->current_commands_conversion_function[cmd]->formatting_reference;
+    = self->current_commands_conversion_function[cmd].formatting_reference;
 
   if (formatting_reference->status > 0)
     call_commands_conversion (self, cmd, formatting_reference,
@@ -2664,7 +2664,7 @@ type_conversion_external (CONVERTER *self, const enum 
element_type type,
                           TEXT *result)
 {
   FORMATTING_REFERENCE *formatting_reference
-    = self->current_types_conversion_function[type]->formatting_reference;
+    = self->current_types_conversion_function[type].formatting_reference;
 
   if (formatting_reference->status > 0)
     call_types_conversion (self, type, formatting_reference,
@@ -2874,52 +2874,36 @@ html_format_init (void)
   html_commands_data[CM_float].flags |= HF_composition_context;
 }
 
-TYPE_CONVERSION_FUNCTION *
-register_type_conversion_function (enum element_type type,
-                         FORMATTING_REFERENCE *formatting_reference)
+void
+register_type_conversion_function (TYPE_CONVERSION_FUNCTION *result,
+                                   enum element_type type,
+                                   FORMATTING_REFERENCE *formatting_reference)
 {
-  TYPE_CONVERSION_FUNCTION *result = 0;
   if (formatting_reference->status > 0)
     {
-      result = (TYPE_CONVERSION_FUNCTION *)
-        malloc (sizeof (TYPE_CONVERSION_FUNCTION));
       result->status = formatting_reference->status;
       if (formatting_reference->status != FRS_status_ignored)
         {
           result->type_conversion = &type_conversion_external;
           result->formatting_reference = formatting_reference;
         }
-      else
-        {
-          result->type_conversion = 0;
-          result->formatting_reference = 0;
-        }
     }
-  return result;
 }
 
-COMMAND_CONVERSION_FUNCTION *
-register_command_conversion_function (enum command_id cmd,
+void
+register_command_conversion_function (COMMAND_CONVERSION_FUNCTION *result,
+                         enum command_id cmd,
                          FORMATTING_REFERENCE *formatting_reference)
 {
-  COMMAND_CONVERSION_FUNCTION *result = 0;
   if (formatting_reference->status > 0)
     {
-       result = (COMMAND_CONVERSION_FUNCTION *)
-         malloc (sizeof (COMMAND_CONVERSION_FUNCTION));
-       result->status = formatting_reference->status;
-       if (formatting_reference->status != FRS_status_ignored)
-         {
-           result->command_conversion = &command_conversion_external;
-           result->formatting_reference = formatting_reference;
-         }
-       else
-         {
-           result->command_conversion = 0;
-           result->formatting_reference = 0;
-         }
+      result->status = formatting_reference->status;
+      if (formatting_reference->status != FRS_status_ignored)
+        {
+          result->command_conversion = &command_conversion_external;
+          result->formatting_reference = formatting_reference;
+        }
     }
-  return result;
 }
 
 /* most of the initialization is done by html_converter_initialize_sv
@@ -3010,10 +2994,10 @@ html_converter_initialize (CONVERTER *self)
 
   for (i = 0; i < TXI_TREE_TYPES_NUMBER; i++)
     {
-      self->type_conversion_function[i]
-        = register_type_conversion_function(i, &self->types_conversion[i]);
-      self->css_string_type_conversion_function[i]
-        = register_type_conversion_function(i,
+      register_type_conversion_function (&self->type_conversion_function[i],
+                                        i, &self->types_conversion[i]);
+      register_type_conversion_function (
+             &self->css_string_type_conversion_function[i], i,
              &self->css_string_types_conversion[i]);
     }
 
@@ -3021,9 +3005,8 @@ html_converter_initialize (CONVERTER *self)
     {
       enum element_type type = types_internal_conversion_table[i].type;
       TYPE_CONVERSION_FUNCTION *type_conversion
-         = self->type_conversion_function[type];
-      if (type_conversion
-          && type_conversion->status == FRS_status_default_set)
+         = &self->type_conversion_function[type];
+      if (type_conversion->status == FRS_status_default_set)
         {
           type_conversion->formatting_reference = 0;
           type_conversion->status = FRS_status_internal;
@@ -3034,10 +3017,11 @@ html_converter_initialize (CONVERTER *self)
 
   for (i = 0; i < BUILTIN_CMD_NUMBER; i++)
     {
-      self->command_conversion_function[i]
-        = register_command_conversion_function(i, 
&self->commands_conversion[i]);
-      self->css_string_command_conversion_function[i]
-        = register_command_conversion_function(i,
+      register_command_conversion_function (
+           &self->command_conversion_function[i],
+           i, &self->commands_conversion[i]);
+      register_command_conversion_function (
+            &self->css_string_command_conversion_function[i], i,
              &self->css_string_commands_conversion[i]);
     }
 }
@@ -3216,18 +3200,6 @@ html_destroy (CONVERTER *self)
         }
     }
 
-  for (i = 0; i < TXI_TREE_TYPES_NUMBER; i++)
-    {
-      free (self->type_conversion_function[i]);
-      free (self->css_string_type_conversion_function[i]);
-    }
-
-  for (i = 0; i < BUILTIN_CMD_NUMBER; i++)
-    {
-      free (self->command_conversion_function[i]);
-      free (self->css_string_command_conversion_function[i]);
-    }
-
   free (self->no_arg_formatted_cmd.list);
 
   free (self->no_arg_formatted_cmd_translated.list);
@@ -3311,9 +3283,9 @@ html_convert_css_string (CONVERTER *self, const ELEMENT 
*element, char *explanat
 
   FORMATTING_REFERENCE *saved_formatting_references
      = self->current_formatting_references;
-  COMMAND_CONVERSION_FUNCTION **saved_commands_conversion_function
+  COMMAND_CONVERSION_FUNCTION *saved_commands_conversion_function
      = self->current_commands_conversion_function;
-  TYPE_CONVERSION_FUNCTION **saved_types_conversion_function
+  TYPE_CONVERSION_FUNCTION *saved_types_conversion_function
      = self->current_types_conversion_function;
 
   self->current_formatting_references
@@ -3980,12 +3952,10 @@ convert_to_html_internal (CONVERTER *self, const 
ELEMENT *element,
     }
 
   if ((element->type
-       && self->current_types_conversion_function[element->type]
-       && self->current_types_conversion_function[element->type]->status
+       && self->current_types_conversion_function[element->type].status
                                                          == FRS_status_ignored)
       || (cmd
-          && self->current_commands_conversion_function[cmd]
-          && self->current_commands_conversion_function[cmd]->status
+          && self->current_commands_conversion_function[cmd].status
                                                          == 
FRS_status_ignored))
     {
       if (self->conf->DEBUG > 0)
@@ -4019,7 +3989,7 @@ convert_to_html_internal (CONVERTER *self, const ELEMENT 
*element,
         }
       else
         {
-          (*self->current_types_conversion_function[ET_text]->type_conversion)
+          (*(self->current_types_conversion_function[ET_text].type_conversion))
                     (self, ET_text, element, element->text.text, &text_result);
         }
 
@@ -4053,7 +4023,7 @@ convert_to_html_internal (CONVERTER *self, const ELEMENT 
*element,
           self->modified_state |= HMSF_current_root;
         }
 
-      if (self->current_commands_conversion_function[cmd])
+      if (self->current_commands_conversion_function[cmd].command_conversion)
         {
           TEXT content_formatted;
           HTML_ARGS_FORMATTED *args_formatted = 0;
@@ -4323,9 +4293,9 @@ convert_to_html_internal (CONVERTER *self, const ELEMENT 
*element,
             }
 
           /* args are formatted, now format the command itself */
-          if (self->current_commands_conversion_function[cmd])
+          if 
(self->current_commands_conversion_function[cmd].command_conversion)
             {
-       (*self->current_commands_conversion_function[cmd]->command_conversion)
+       (*self->current_commands_conversion_function[cmd].command_conversion)
                    (self, cmd, element, args_formatted,
                     content_formatted.text, result);
             }
@@ -4404,9 +4374,9 @@ convert_to_html_internal (CONVERTER *self, const ELEMENT 
*element,
 
       html_convert_type_update_context (self, type);
 
-      if (self->current_types_conversion_function[type])
+      if (self->current_types_conversion_function[type].type_conversion)
         {
-          (*self->current_types_conversion_function[type]->type_conversion)
+          (*self->current_types_conversion_function[type].type_conversion)
                (self, type, element, content_formatted.text, &type_result);
         }
       else if (content_formatted.end > 0)
@@ -4456,10 +4426,9 @@ convert_to_html_internal (CONVERTER *self, const ELEMENT 
*element,
     {
       if (self->conf->DEBUG > 0)
         fprintf (stderr, "UNNAMED empty\n");
-      if (self->current_types_conversion_function[0]
-          && self->current_types_conversion_function[0]->type_conversion)
+      if (self->current_types_conversion_function[0].type_conversion)
         {
-          (*self->current_types_conversion_function[0]->type_conversion)
+          (*self->current_types_conversion_function[0].type_conversion)
                            (self, 0, element, "", result);
           goto out;
         }
diff --git a/tp/Texinfo/XS/main/converter_types.h 
b/tp/Texinfo/XS/main/converter_types.h
index 37206b9390..8de47b7269 100644
--- a/tp/Texinfo/XS/main/converter_types.h
+++ b/tp/Texinfo/XS/main/converter_types.h
@@ -449,15 +449,10 @@ typedef struct CONVERTER {
     FORMATTING_REFERENCE output_units_conversion[OU_special_unit+1];
     STRING_LIST special_unit_varieties;
     char **special_unit_info[SUI_type_heading+1];
-    /* in the next line we use a pointer and not directly the structure
-       because the type is incomplete, the structure is defined after the
-       CONVERTER because it uses the CONVERTER in a function pointer
-       argument prototype, which does not seems to be possible with
-       incomplete types */
-    struct TYPE_CONVERSION_FUNCTION 
*type_conversion_function[TXI_TREE_TYPES_NUMBER];
-    struct TYPE_CONVERSION_FUNCTION 
*css_string_type_conversion_function[TXI_TREE_TYPES_NUMBER];
-    struct COMMAND_CONVERSION_FUNCTION 
*command_conversion_function[BUILTIN_CMD_NUMBER];
-    struct COMMAND_CONVERSION_FUNCTION 
*css_string_command_conversion_function[BUILTIN_CMD_NUMBER];
+    TYPE_CONVERSION_FUNCTION type_conversion_function[TXI_TREE_TYPES_NUMBER];
+    TYPE_CONVERSION_FUNCTION 
css_string_type_conversion_function[TXI_TREE_TYPES_NUMBER];
+    COMMAND_CONVERSION_FUNCTION 
command_conversion_function[BUILTIN_CMD_NUMBER];
+    COMMAND_CONVERSION_FUNCTION 
css_string_command_conversion_function[BUILTIN_CMD_NUMBER];
     /* set for a converter, modified in a document */
     HTML_COMMAND_CONVERSION 
html_command_conversion[BUILTIN_CMD_NUMBER][HCC_type_css_string+1];
 
@@ -494,8 +489,8 @@ typedef struct CONVERTER {
     /* next three allow to switch from normal HTML formatting to css strings
        formatting */
     FORMATTING_REFERENCE *current_formatting_references;
-    struct TYPE_CONVERSION_FUNCTION **current_types_conversion_function;
-    struct COMMAND_CONVERSION_FUNCTION **current_commands_conversion_function;
+    TYPE_CONVERSION_FUNCTION *current_types_conversion_function;
+    COMMAND_CONVERSION_FUNCTION *current_commands_conversion_function;
 
     /* state common with perl converter */
     int document_global_context;



reply via email to

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