texinfo-commits
[Top][All Lists]
Advanced

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

[no subject]


From: Patrice Dumas
Date: Sat, 11 Nov 2023 10:50:15 -0500 (EST)

branch: master
commit ce2163c1be77cbc404089d9e694bc9d5510398b6
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Nov 11 15:51:56 2023 +0100

    * tp/Texinfo/XS/main/converter_types.h (HCC_CONTEXT_TYPES_LIST),
    tp/Texinfo/XS/main/utils.h: move definition of HCC_CONTEXT_TYPES_LIST
    to main/converter_types.h.
    
    * tp/Texinfo/XS/convert/build_html_perl_state.c
    (build_html_translated_names), tp/Texinfo/XS/convert/convert_html.c
    (reset_unset_no_arg_commands_formatting_context)
    (html_translate_names), tp/Texinfo/XS/convert/get_html_perl_info.c
    (html_converter_initialize_sv), tp/Texinfo/XS/main/converter_types.h
    (CONVERTER): change html_command_conversion in converter to be a two
    dimension array with known size.
---
 ChangeLog                                     | 14 +++++++
 tp/Texinfo/XS/convert/build_html_perl_state.c | 55 +++++++++++++--------------
 tp/Texinfo/XS/convert/convert_html.c          | 18 ++-------
 tp/Texinfo/XS/convert/get_html_perl_info.c    | 24 +-----------
 tp/Texinfo/XS/main/converter_types.h          | 16 +++++++-
 tp/Texinfo/XS/main/utils.h                    | 14 -------
 6 files changed, 61 insertions(+), 80 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b6d61e5cdd..88cd170c0e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2023-11-11  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/main/converter_types.h (HCC_CONTEXT_TYPES_LIST),
+       tp/Texinfo/XS/main/utils.h: move definition of HCC_CONTEXT_TYPES_LIST
+       to main/converter_types.h.
+
+       * tp/Texinfo/XS/convert/build_html_perl_state.c
+       (build_html_translated_names), tp/Texinfo/XS/convert/convert_html.c
+       (reset_unset_no_arg_commands_formatting_context)
+       (html_translate_names), tp/Texinfo/XS/convert/get_html_perl_info.c
+       (html_converter_initialize_sv), tp/Texinfo/XS/main/converter_types.h
+       (CONVERTER): change html_command_conversion in converter to be a two
+       dimension array with known size.
+
 2023-11-11  Gavin Smith <gavinsmith0123@gmail.com>
 
        Remove hevea support from texi2dvi
diff --git a/tp/Texinfo/XS/convert/build_html_perl_state.c 
b/tp/Texinfo/XS/convert/build_html_perl_state.c
index c800ed83fe..bd0f0bc4fe 100644
--- a/tp/Texinfo/XS/convert/build_html_perl_state.c
+++ b/tp/Texinfo/XS/convert/build_html_perl_state.c
@@ -462,7 +462,7 @@ build_html_translated_names (HV *hv, CONVERTER *converter)
           int k;
           enum command_id cmd
             = converter->no_arg_formatted_cmd_translated.list[j];
-          HTML_COMMAND_CONVERSION **conversion_contexts
+          HTML_COMMAND_CONVERSION *conversion_contexts
                 = converter->html_command_conversion[cmd];
           char *cmdname = builtin_command_data[cmd].cmdname;
           SV **no_arg_command_sv
@@ -471,40 +471,37 @@ build_html_translated_names (HV *hv, CONVERTER *converter)
           HV *no_arg_command_hv = (HV *) SvRV (*no_arg_command_sv);
           for (k = 0; k < max_context; k++)
             {
-              if (conversion_contexts[k])
-                {
-                  HTML_COMMAND_CONVERSION *no_arg_cmd_context
-                      = conversion_contexts[k];
+              HTML_COMMAND_CONVERSION *no_arg_cmd_context
+                  = &conversion_contexts[k];
 
-                  char *context_name = html_conversion_context_type_names[k];
-                  SV **context_sv = hv_fetch (no_arg_command_hv,
-                                     context_name, strlen (context_name), 0);
-                  HV *context_hv = (HV *) SvRV (*context_sv);
+              char *context_name = html_conversion_context_type_names[k];
+              SV **context_sv = hv_fetch (no_arg_command_hv,
+                                 context_name, strlen (context_name), 0);
+              HV *context_hv = (HV *) SvRV (*context_sv);
 
  #define REPLACE_STR(key) \
-                  if (no_arg_cmd_context->key) \
-                    {               \
-                      hv_store (context_hv, #key, strlen (#key), \
-                                newSVpv_utf8 (no_arg_cmd_context->key, 0), 0); 
\
-                    }   \
-                  else if (hv_exists (context_hv, #key, strlen (#key))) \
-                    hv_delete (context_hv, #key, strlen (#key), G_DISCARD);
-
-                  REPLACE_STR(text)
-                  REPLACE_STR(translated_converted)
-                  REPLACE_STR(translated_to_convert)
+              if (no_arg_cmd_context->key) \
+                {               \
+                  hv_store (context_hv, #key, strlen (#key), \
+                            newSVpv_utf8 (no_arg_cmd_context->key, 0), 0); \
+                }   \
+              else if (hv_exists (context_hv, #key, strlen (#key))) \
+                hv_delete (context_hv, #key, strlen (#key), G_DISCARD);
+
+              REPLACE_STR(text)
+              REPLACE_STR(translated_converted)
+              REPLACE_STR(translated_to_convert)
  #undef REPLACE_STR
 
-                  if (no_arg_cmd_context->tree)
-                    {
-                      if (!no_arg_cmd_context->tree->hv)
-                        element_to_perl_hash (no_arg_cmd_context->tree);
-                      hv_store (context_hv, "tree", strlen ("tree"),
-                              newRV_inc ((SV *) no_arg_cmd_context->tree->hv), 
0);
-                    }
-                  else if (hv_exists (context_hv, "tree", strlen ("tree")))
-                    hv_delete (context_hv, "tree", strlen ("tree"), G_DISCARD);
+              if (no_arg_cmd_context->tree)
+                {
+                  if (!no_arg_cmd_context->tree->hv)
+                    element_to_perl_hash (no_arg_cmd_context->tree);
+                  hv_store (context_hv, "tree", strlen ("tree"),
+                          newRV_inc ((SV *) no_arg_cmd_context->tree->hv), 0);
                 }
+              else if (hv_exists (context_hv, "tree", strlen ("tree")))
+                hv_delete (context_hv, "tree", strlen ("tree"), G_DISCARD);
             }
         }
 
diff --git a/tp/Texinfo/XS/convert/convert_html.c 
b/tp/Texinfo/XS/convert/convert_html.c
index 252a6a1289..452f504f42 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -2732,25 +2732,15 @@ reset_unset_no_arg_commands_formatting_context 
(CONVERTER *self,
                enum conversion_context ref_context, int translate)
 {
   HTML_COMMAND_CONVERSION *no_arg_command_context;
-  HTML_COMMAND_CONVERSION **conversion_contexts
+  HTML_COMMAND_CONVERSION *conversion_contexts
     = self->html_command_conversion[cmd];
-  /* should never happen as unset is set at configuration */
-  if (!conversion_contexts[reset_context])
-    {
-      conversion_contexts[reset_context] =
-        (HTML_COMMAND_CONVERSION *) malloc (sizeof (HTML_COMMAND_CONVERSION));
-      memset (conversion_contexts[reset_context], 0,
-              sizeof (HTML_COMMAND_CONVERSION));
-
-      conversion_contexts[reset_context]->unset = 1;
-    }
-  no_arg_command_context = conversion_contexts[reset_context];
+  no_arg_command_context = &conversion_contexts[reset_context];
   if (ref_context >= 0)
     {
       if (no_arg_command_context->unset)
         {
           HTML_COMMAND_CONVERSION *no_arg_ref
-            = conversion_contexts[ref_context];
+            = &conversion_contexts[ref_context];
 
           /* TODO memory leaks possible for the other char * fields */
 
@@ -2948,7 +2938,7 @@ html_translate_names (CONVERTER *self)
           for (cctx = 0; cctx < HCC_type_css_string+1; cctx++)
             {
               HTML_COMMAND_CONVERSION *format_spec
-                = self->html_command_conversion[cmd][cctx];
+                = &self->html_command_conversion[cmd][cctx];
               if (format_spec->translated_converted
                   && !format_spec->unset)
                 {
diff --git a/tp/Texinfo/XS/convert/get_html_perl_info.c 
b/tp/Texinfo/XS/convert/get_html_perl_info.c
index f4cfb80453..d5b37443f6 100644
--- a/tp/Texinfo/XS/convert/get_html_perl_info.c
+++ b/tp/Texinfo/XS/convert/get_html_perl_info.c
@@ -548,11 +548,6 @@ html_converter_initialize_sv (SV *converter_sv,
                 {
                   I32 context_nr;
                   I32 j;
-                  converter->html_command_conversion[cmd] =
-                   (HTML_COMMAND_CONVERSION **) malloc ((max_context +1) *
-                     sizeof (HTML_COMMAND_CONVERSION *));
-                  memset (converter->html_command_conversion[cmd], 0,
-                     (max_context +1) * sizeof (HTML_COMMAND_CONVERSION *));
 
                   context_nr = hv_iterinit (context_hv);
                   for (j = 0; j < context_nr; j++)
@@ -587,14 +582,9 @@ html_converter_initialize_sv (SV *converter_sv,
 
                           HV *format_spec_hv = (HV *)SvRV (format_spec_sv);
 
-                          converter->html_command_conversion[cmd][context_idx]
-                           = (HTML_COMMAND_CONVERSION *)
-                               malloc (sizeof (HTML_COMMAND_CONVERSION));
                           format_spec
-                            = converter
+                            = &converter
                                ->html_command_conversion[cmd][context_idx];
-                          memset (format_spec, 0,
-                                  sizeof (HTML_COMMAND_CONVERSION));
 
                           spec_number = hv_iterinit (format_spec_hv);
                           for (s = 0; s < spec_number; s++)
@@ -669,11 +659,6 @@ html_converter_initialize_sv (SV *converter_sv,
                 {
                   I32 context_nr;
                   I32 j;
-                  converter->html_command_conversion[cmd] =
-                   (HTML_COMMAND_CONVERSION **) malloc ((max_context +1) *
-                     sizeof (HTML_COMMAND_CONVERSION *));
-                  memset (converter->html_command_conversion[cmd], 0,
-                     (max_context +1) * sizeof (HTML_COMMAND_CONVERSION *));
 
                   context_nr = hv_iterinit (context_hv);
                   for (j = 0; j < context_nr; j++)
@@ -708,14 +693,9 @@ html_converter_initialize_sv (SV *converter_sv,
 
                           HV *format_spec_hv = (HV *)SvRV (format_spec_sv);
 
-                          converter->html_command_conversion[cmd][context_idx]
-                           = (HTML_COMMAND_CONVERSION *)
-                               malloc (sizeof (HTML_COMMAND_CONVERSION));
                           format_spec
-                            = converter
+                            = &converter
                                ->html_command_conversion[cmd][context_idx];
-                          memset (format_spec, 0,
-                                  sizeof (HTML_COMMAND_CONVERSION));
 
                           spec_number = hv_iterinit (format_spec_hv);
                           for (s = 0; s < spec_number; s++)
diff --git a/tp/Texinfo/XS/main/converter_types.h 
b/tp/Texinfo/XS/main/converter_types.h
index a0f43b5822..587e54a179 100644
--- a/tp/Texinfo/XS/main/converter_types.h
+++ b/tp/Texinfo/XS/main/converter_types.h
@@ -50,6 +50,20 @@ enum monospace_context {
    MONO_ctx_on,
 };
 
+#define HCC_CONTEXT_TYPES_LIST \
+  cctx_type(normal) \
+  cctx_type(preformatted) \
+  cctx_type(string) \
+  cctx_type(css_string) \
+  cctx_type(code) \
+  cctx_type(math)
+
+enum conversion_context {
+  #define cctx_type(name) HCC_type_## name,
+   HCC_CONTEXT_TYPES_LIST
+  #undef cctx_type
+};
+
 #define SUI_TYPES_LIST \
   sui_type(class) \
   sui_type(direction) \
@@ -415,7 +429,7 @@ typedef struct CONVERTER {
     char **special_unit_info[SUI_type_heading+1];
 
     /* set for a converter, modified in a document */
-    HTML_COMMAND_CONVERSION **html_command_conversion[BUILTIN_CMD_NUMBER];
+    HTML_COMMAND_CONVERSION 
html_command_conversion[BUILTIN_CMD_NUMBER][HCC_type_css_string+1];
 
     /* set for a document */
     OUTPUT_UNIT **global_units_directions;
diff --git a/tp/Texinfo/XS/main/utils.h b/tp/Texinfo/XS/main/utils.h
index f046b59e66..15eb8fc03a 100644
--- a/tp/Texinfo/XS/main/utils.h
+++ b/tp/Texinfo/XS/main/utils.h
@@ -134,20 +134,6 @@ enum command_location {
    CL_preamble_or_first,
 };
 
-#define HCC_CONTEXT_TYPES_LIST \
-  cctx_type(normal) \
-  cctx_type(preformatted) \
-  cctx_type(string) \
-  cctx_type(css_string) \
-  cctx_type(code) \
-  cctx_type(math)
-
-enum conversion_context {
-  #define cctx_type(name) HCC_type_## name,
-   HCC_CONTEXT_TYPES_LIST
-  #undef cctx_type
-};
-
 /* HTML modified state flags */
 #define HMSF_current_root            0x0001
 #define HMSF_document_context        0x0002



reply via email to

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