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, 25 Feb 2024 14:51:56 -0500 (EST)

branch: master
commit d4a795816345f334cc0c0e7e03a27dfa64c44551
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Feb 25 20:50:34 2024 +0100

    * tp/Texinfo/XS/main/errors.c (message_list_line_formatted_message)
    (message_list_document_formatted_message)
    (vmessage_list_line_error, message_list_document_error_internal):
    call strdup in message_list_line_formatted_message and
    message_list_document_formatted_message directly when registering the
    message, and set const on the argument.  Free the messages in
    vmessage_list_line_error and message_list_document_error_internal
    after registering them.  This is so directly calling
    message_list_*_formatted_message does not require calling strdup.
    
    Add const.
---
 ChangeLog                                     |  14 +++
 tp/Texinfo/XS/convert/ConvertXS.xs            | 153 +++++++++++++-------------
 tp/Texinfo/XS/convert/build_html_perl_state.c |   6 +-
 tp/Texinfo/XS/convert/build_html_perl_state.h |   2 +-
 tp/Texinfo/XS/convert/convert_html.c          |  84 +++++++-------
 tp/Texinfo/XS/convert/convert_html.h          |  27 +++--
 tp/Texinfo/XS/convert/get_html_perl_info.c    |   4 +-
 tp/Texinfo/XS/main/build_perl_info.c          |   6 +-
 tp/Texinfo/XS/main/convert_utils.c            |  15 ++-
 tp/Texinfo/XS/main/convert_utils.h            |  15 +--
 tp/Texinfo/XS/main/document_types.h           |   4 +-
 tp/Texinfo/XS/main/errors.c                   |  13 ++-
 tp/Texinfo/XS/main/errors.h                   |   4 +-
 tp/Texinfo/XS/main/get_perl_info.c            |   6 +-
 tp/Texinfo/XS/main/get_perl_info.h            |   2 +-
 tp/Texinfo/XS/main/utils.c                    |   3 +-
 16 files changed, 195 insertions(+), 163 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index ea3a5d270b..dcf4761e33 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2024-02-25  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/main/errors.c (message_list_line_formatted_message)
+       (message_list_document_formatted_message)
+       (vmessage_list_line_error, message_list_document_error_internal):
+       call strdup in message_list_line_formatted_message and
+       message_list_document_formatted_message directly when registering the
+       message, and set const on the argument.  Free the messages in
+       vmessage_list_line_error and message_list_document_error_internal
+       after registering them.  This is so directly calling
+       message_list_*_formatted_message does not require calling strdup.
+
+       Add const.
+
 2024-02-25  Gavin Smith <gavinsmith0123@gmail.com>
 
        Reset parsetexi counters
diff --git a/tp/Texinfo/XS/convert/ConvertXS.xs 
b/tp/Texinfo/XS/convert/ConvertXS.xs
index e3de677c83..91b3f016f5 100644
--- a/tp/Texinfo/XS/convert/ConvertXS.xs
+++ b/tp/Texinfo/XS/convert/ConvertXS.xs
@@ -74,7 +74,7 @@ converter_set_document (SV *converter_in, SV *document_in)
 
 void
 set_conf (SV *converter_in, conf, SV *value)
-         char *conf = (char *)SvPVbyte_nolen($arg);
+         const char *conf = (char *)SvPVbyte_nolen($arg);
       PREINIT:
          CONVERTER *self;
       CODE:
@@ -85,7 +85,7 @@ set_conf (SV *converter_in, conf, SV *value)
 
 void
 force_conf (SV *converter_in, conf, SV *value)
-         char *conf = (char *)SvPVbyte_nolen($arg);
+         const char *conf = (char *)SvPVbyte_nolen($arg);
       PREINIT:
          CONVERTER *self;
       CODE:
@@ -96,7 +96,7 @@ force_conf (SV *converter_in, conf, SV *value)
 
 SV *
 get_conf (SV *converter_in, conf)
-         char *conf = (char *)SvPVbyte_nolen($arg);
+         const char *conf = (char *)SvPVbyte_nolen($arg);
       PREINIT:
          CONVERTER *self;
       CODE:
@@ -110,7 +110,7 @@ get_conf (SV *converter_in, conf)
 
 void
 converter_line_error (SV *converter_in, text, SV *error_location_info, ...)
-          char *text = (char *)SvPVutf8_nolen($arg);
+          const char *text = (char *)SvPVutf8_nolen($arg);
       PROTOTYPE: $$$;$
       PREINIT:
          CONVERTER *self;
@@ -123,12 +123,12 @@ converter_line_error (SV *converter_in, text, SV 
*error_location_info, ...)
          if (self)
            {
              get_line_message (self, MSG_error, continuation,
-                               error_location_info, strdup (text));
+                               error_location_info, text);
            }
 
 void
 converter_line_warn (SV *converter_in, text, SV *error_location_info, ...)
-          char *text = (char *)SvPVutf8_nolen($arg);
+          const char *text = (char *)SvPVutf8_nolen($arg);
       PROTOTYPE: $$$;$
       PREINIT:
          CONVERTER *self;
@@ -141,12 +141,12 @@ converter_line_warn (SV *converter_in, text, SV 
*error_location_info, ...)
          if (self)
            {
              get_line_message (self, MSG_warning, continuation,
-                               error_location_info, strdup (text));
+                               error_location_info, text);
            }
 
 void
 converter_document_error (SV *converter_in, text, ...)
-          char *text = (char *)SvPVutf8_nolen($arg);
+          const char *text = (char *)SvPVutf8_nolen($arg);
       PROTOTYPE: $$;$
       PREINIT:
          CONVERTER *self;
@@ -158,12 +158,12 @@ converter_document_error (SV *converter_in, text, ...)
          if (self)
            {
              message_list_document_formatted_message (&self->error_messages,
-               self->conf, MSG_document_error, continuation, strdup (text));
+               self->conf, MSG_document_error, continuation, text);
            }
 
 void
 converter_document_warn (SV *converter_in, text, ...)
-          char *text = (char *)SvPVutf8_nolen($arg);
+          const char *text = (char *)SvPVutf8_nolen($arg);
       PROTOTYPE: $$;$
       PREINIT:
          CONVERTER *self;
@@ -175,14 +175,14 @@ converter_document_warn (SV *converter_in, text, ...)
          if (self)
            {
              message_list_document_formatted_message (&self->error_messages,
-                      self->conf, MSG_document_warning, continuation, strdup 
(text));
+                      self->conf, MSG_document_warning, continuation, text);
            }
 
 SV *
 get_converter_indices_sorted_by_index (SV *converter_sv)
      PREINIT:
         CONVERTER *self;
-        INDEX_SORTED_BY_INDEX *index_entries_by_index = 0;
+        const INDEX_SORTED_BY_INDEX *index_entries_by_index = 0;
         HV *converter_hv;
         SV **document_sv;
      CODE:
@@ -223,7 +223,7 @@ SV *
 get_converter_indices_sorted_by_letter (SV *converter_sv)
      PREINIT:
         CONVERTER *self;
-        INDEX_SORTED_BY_LETTER *index_entries_by_letter = 0;
+        const INDEX_SORTED_BY_LETTER *index_entries_by_letter = 0;
         HV *converter_hv;
         SV **document_sv;
      CODE:
@@ -265,7 +265,7 @@ get_converter_indices_sorted_by_letter (SV *converter_sv)
 # was an error with a missing type.
 FILE *
 get_unclosed_stream (SV *converter_in, file_path)
-        char *file_path = (char *)SvPVbyte_nolen($arg);
+        const char *file_path = (char *)SvPVbyte_nolen($arg);
       PREINIT:
          CONVERTER *self;
          OUTPUT_FILES_INFORMATION *output_files_information;
@@ -318,7 +318,7 @@ reset_converter (SV *converter_in)
       PREINIT:
          CONVERTER *self = 0;
          HV *stash;
-         char *name;
+         const char *name;
       CODE:
          stash = SvSTASH (SvRV (converter_in));
          name = HvNAME (stash);
@@ -333,7 +333,7 @@ destroy (SV *converter_in)
       PREINIT:
          CONVERTER *self = 0;
          HV *stash;
-         char *name;
+         const char *name;
       CODE:
          stash = SvSTASH (SvRV (converter_in));
          name = HvNAME (stash);
@@ -442,7 +442,7 @@ html_conversion_finalization (SV *converter_in)
 
 void
 html_register_id (SV *converter_in, id)
-         char *id = (char *)SvPVutf8_nolen($arg);
+         const char *id = (char *)SvPVutf8_nolen($arg);
       PREINIT:
          CONVERTER *self;
       CODE:
@@ -453,7 +453,7 @@ html_register_id (SV *converter_in, id)
 
 
 int html_id_is_registered (SV *converter_in, id)
-         char *id = (char *)SvPVutf8_nolen($arg);
+         const char *id = (char *)SvPVutf8_nolen($arg);
       PREINIT:
          CONVERTER *self;
          int found = 0;
@@ -470,8 +470,8 @@ html_new_document_context (SV *converter_in, char 
*context_name, ...)
       PROTOTYPE: $$;$$
       PREINIT:
          CONVERTER *self;
-         char *document_global_context = 0;
-         char *block_command_name = 0;
+         const char *document_global_context = 0;
+         const char *block_command_name = 0;
          enum command_id block_command = 0;
       CODE:
          self = get_sv_converter (converter_in, "html_new_document_context");
@@ -617,7 +617,7 @@ html_unset_raw_context (SV *converter_in)
 SV *
 html_debug_print_html_contexts (SV *converter_in)
      PREINIT:
-         CONVERTER *self;
+         const CONVERTER *self;
      CODE:
          self = get_sv_converter (converter_in,
                                   "html_debug_print_html_contexts");
@@ -635,7 +635,7 @@ html_debug_print_html_contexts (SV *converter_in)
 int
 html_in_math (SV *converter_in)
      PREINIT:
-         CONVERTER *self;
+         const CONVERTER *self;
      CODE:
          self = get_sv_converter (converter_in,
                                   "html_in_math");
@@ -646,7 +646,7 @@ html_in_math (SV *converter_in)
 int
 html_in_preformatted_context (SV *converter_in)
      PREINIT:
-         CONVERTER *self;
+         const CONVERTER *self;
      CODE:
          self = get_sv_converter (converter_in,
                                   "html_in_preformatted_context");
@@ -657,7 +657,7 @@ html_in_preformatted_context (SV *converter_in)
 int
 html_inside_preformatted (SV *converter_in)
      PREINIT:
-         CONVERTER *self;
+         const CONVERTER *self;
      CODE:
          self = get_sv_converter (converter_in,
                                   "html_inside_preformatted");
@@ -668,7 +668,7 @@ html_inside_preformatted (SV *converter_in)
 int
 html_in_upper_case (SV *converter_in)
      PREINIT:
-         CONVERTER *self;
+         const CONVERTER *self;
      CODE:
          self = get_sv_converter (converter_in,
                                   "html_in_upper_case");
@@ -679,7 +679,7 @@ html_in_upper_case (SV *converter_in)
 int
 html_in_non_breakable_space (SV *converter_in)
      PREINIT:
-         CONVERTER *self;
+         const CONVERTER *self;
      CODE:
          self = get_sv_converter (converter_in,
                                   "html_in_non_breakable_space");
@@ -690,7 +690,7 @@ html_in_non_breakable_space (SV *converter_in)
 int
 html_in_space_protected (SV *converter_in)
      PREINIT:
-         CONVERTER *self;
+         const CONVERTER *self;
      CODE:
          self = get_sv_converter (converter_in,
                                   "html_in_space_protected");
@@ -701,7 +701,7 @@ html_in_space_protected (SV *converter_in)
 int
 html_in_code (SV *converter_in)
      PREINIT:
-         CONVERTER *self;
+         const CONVERTER *self;
      CODE:
          self = get_sv_converter (converter_in,
                                   "html_in_code");
@@ -712,7 +712,7 @@ html_in_code (SV *converter_in)
 int
 html_in_string (SV *converter_in)
      PREINIT:
-         CONVERTER *self;
+         const CONVERTER *self;
      CODE:
          self = get_sv_converter (converter_in,
                                   "html_in_string");
@@ -723,7 +723,7 @@ html_in_string (SV *converter_in)
 int
 html_in_verbatim (SV *converter_in)
      PREINIT:
-         CONVERTER *self;
+         const CONVERTER *self;
      CODE:
          self = get_sv_converter (converter_in,
                                   "html_in_verbatim");
@@ -734,7 +734,7 @@ html_in_verbatim (SV *converter_in)
 int
 html_in_raw (SV *converter_in)
      PREINIT:
-         CONVERTER *self;
+         const CONVERTER *self;
      CODE:
          self = get_sv_converter (converter_in,
                                   "html_in_raw");
@@ -745,7 +745,7 @@ html_in_raw (SV *converter_in)
 int
 html_paragraph_number (SV *converter_in)
      PREINIT:
-         CONVERTER *self;
+         const CONVERTER *self;
      CODE:
          self = get_sv_converter (converter_in,
                                   "html_paragraph_number");
@@ -756,7 +756,7 @@ html_paragraph_number (SV *converter_in)
 int
 html_preformatted_number (SV *converter_in)
      PREINIT:
-         CONVERTER *self;
+         const CONVERTER *self;
      CODE:
          self = get_sv_converter (converter_in,
                                   "html_preformatted_number");
@@ -767,7 +767,7 @@ html_preformatted_number (SV *converter_in)
 const char *
 html_top_block_command (SV *converter_in)
      PREINIT:
-         CONVERTER *self;
+         const CONVERTER *self;
          enum command_id cmd;
      CODE:
          self = get_sv_converter (converter_in,
@@ -780,8 +780,8 @@ html_top_block_command (SV *converter_in)
 SV *
 html_preformatted_classes_stack (SV *converter_in)
      PREINIT:
-         CONVERTER *self;
-         COMMAND_OR_TYPE_STACK *preformatted_classes_stack;
+         const CONVERTER *self;
+         const COMMAND_OR_TYPE_STACK *preformatted_classes_stack;
          AV *preformatted_classes_av;
          size_t i;
      CODE:
@@ -791,9 +791,9 @@ html_preformatted_classes_stack (SV *converter_in)
          preformatted_classes_av = newAV();
          for (i = 0; i < preformatted_classes_stack->top; i++)
            {
-             COMMAND_OR_TYPE *cmd_or_type
+             const COMMAND_OR_TYPE *cmd_or_type
                = &preformatted_classes_stack->stack[i];
-             char *pre_class = 0;
+             const char *pre_class = 0;
              if (cmd_or_type->variety == CTV_type_command)
                pre_class = builtin_command_data[cmd_or_type->cmd].cmdname;
              else if (cmd_or_type->variety == CTV_type_type)
@@ -809,7 +809,7 @@ html_preformatted_classes_stack (SV *converter_in)
 const char *
 html_in_align (SV *converter_in)
      PREINIT:
-         CONVERTER *self;
+         const CONVERTER *self;
          enum command_id cmd;
      CODE:
          self = get_sv_converter (converter_in, "html_in_align");
@@ -821,7 +821,7 @@ html_in_align (SV *converter_in)
 SV *
 html_current_filename (SV *converter_in)
      PREINIT:
-         CONVERTER *self;
+         const CONVERTER *self;
      CODE:
          self = get_sv_converter (converter_in, "html_current_filename");
          RETVAL = newSVpv_utf8 (self->current_filename.filename, 0);
@@ -831,7 +831,7 @@ html_current_filename (SV *converter_in)
 SV *
 html_current_output_unit (SV *converter_in)
      PREINIT:
-         CONVERTER *self;
+         const CONVERTER *self;
      CODE:
          self = get_sv_converter (converter_in, "html_current_output_unit");
          if (!self->current_output_unit)
@@ -842,11 +842,11 @@ html_current_output_unit (SV *converter_in)
          RETVAL
 
 SV *
-html_count_elements_in_filename (SV *converter_in, char *spec, filename)
-         char *filename = (char *)SvPVutf8_nolen($arg);
+html_count_elements_in_filename (SV *converter_in, const char *spec, filename)
+         const char *filename = (char *)SvPVutf8_nolen($arg);
      PREINIT:
          IV count = -1;
-         CONVERTER *self;
+         const CONVERTER *self;
      CODE:
          self = get_sv_converter (converter_in,
                                   "html_count_elements_in_filename");
@@ -888,7 +888,7 @@ html_register_file_information (SV *converter_in, key, int 
value)
 
 void
 html_get_file_information (SV *converter_in, key, ...)
-         char *key = (char *)SvPVutf8_nolen($arg);
+         const char *key = (char *)SvPVutf8_nolen($arg);
     PROTOTYPE: $$;$
      PREINIT:
          CONVERTER *self;
@@ -904,7 +904,7 @@ html_get_file_information (SV *converter_in, key, ...)
            filename_sv = ST(2);
          if (self)
            {
-             char *filename = 0;
+             const char *filename = 0;
              int status;
              if (filename_sv)
                filename = SvPVutf8_nolen (filename_sv);
@@ -942,7 +942,7 @@ html_get_target (SV *converter_in, SV *element_sv)
                                                   output_units_descriptor);
              if (element)
                {
-                 HTML_TARGET *target_info = html_get_target (self, element);
+                 const HTML_TARGET *target_info = html_get_target (self, 
element);
                  if (target_info)
                    html_target_hv = build_html_target (target_info);
                }
@@ -977,7 +977,7 @@ html_command_id (SV *converter_in, SV *element_sv)
 
 SV *
 html_command_contents_target (SV *converter_in, SV *element_sv, cmdname)
-         char *cmdname = (char *)SvPVutf8_nolen($arg);
+         const char *cmdname = (char *)SvPVutf8_nolen($arg);
      PREINIT:
          CONVERTER *self;
          const char *id = 0;
@@ -1218,7 +1218,7 @@ html_internal_command_tree (SV *converter_in, SV 
*element_sv, SV* no_number_sv)
          RETVAL
 
 SV *
-html_internal_command_text (SV *converter_in, SV *element_sv, char *type)
+html_internal_command_text (SV *converter_in, SV *element_sv, const char *type)
      PREINIT:
          CONVERTER *self;
          char *text = 0;
@@ -1354,7 +1354,7 @@ html_close_registered_sections_level (SV *converter_in, 
int level)
 
 SV *
 html_attribute_class (SV *converter_in, element, ...)
-         char *element = (char *)SvPVutf8_nolen($arg);
+         const char *element = (char *)SvPVutf8_nolen($arg);
     PROTOTYPE: $$;$
     PREINIT:
          CONVERTER *self;
@@ -1404,7 +1404,7 @@ html_get_css_elements_classes (SV *converter_in, ...)
          if (self)
            {
              STRING_LIST *result;
-             char *filename = 0;
+             const char *filename = 0;
              if (filename_sv)
                filename = SvPVutf8_nolen (filename_sv);
              result = html_get_css_elements_classes (self, filename);
@@ -1429,7 +1429,7 @@ html_get_css_elements_classes (SV *converter_in, ...)
 
 void
 html_css_add_info (SV *converter_in, char *spec, css_info)
-         char *css_info = (char *)SvPVutf8_nolen($arg);
+         const char *css_info = (char *)SvPVutf8_nolen($arg);
     PREINIT:
          CONVERTER *self;
     CODE:
@@ -1443,7 +1443,7 @@ html_css_add_info (SV *converter_in, char *spec, css_info)
 
 void
 html_css_set_selector_style (SV *converter_in, css_info, SV *css_style_sv)
-         char *css_info = (char *)SvPVutf8_nolen($arg);
+         const char *css_info = (char *)SvPVutf8_nolen($arg);
     PREINIT:
          CONVERTER *self;
     CODE:
@@ -1482,7 +1482,7 @@ html_css_get_info (SV *converter_in, char *spec)
 
 SV *
 html_css_get_selector_style (SV *converter_in, css_info)
-         char *css_info = (char *)SvPVutf8_nolen($arg);
+         const char *css_info = (char *)SvPVutf8_nolen($arg);
     PREINIT:
          CONVERTER *self;
          const char *css_style = 0;
@@ -1502,18 +1502,19 @@ html_css_get_selector_style (SV *converter_in, css_info)
 
 void
 html_register_footnote (SV *converter_in, SV *command, footid, docid, int 
number_in_doc, footnote_location_filename, ...)
-         char *footid = (char *)SvPVutf8_nolen($arg);
-         char *docid = (char *)SvPVutf8_nolen($arg);
-         char *footnote_location_filename = (char *)SvPVutf8_nolen($arg);
+         const char *footid = (char *)SvPVutf8_nolen($arg);
+         const char *docid = (char *)SvPVutf8_nolen($arg);
+         const char *footnote_location_filename = (char *)SvPVutf8_nolen($arg);
       PROTOTYPE: $$$$$$$
       PREINIT:
          CONVERTER *self;
-         char *multi_expanded_region = 0;
+         const char *multi_expanded_region = 0;
       CODE:
          self = get_sv_converter (converter_in,
                                   "html_register_footnote");
          if (self)
            {
+             /* TODO use functions used for other elements? */
              /* find footnote in XS.  First use index in global commands,
                 then number_in_doc, and if not effective, do a linear search */
              ELEMENT *footnote = 0;
@@ -1612,11 +1613,11 @@ html_get_pending_footnotes (SV *converter_in)
 
 void
 html_register_pending_formatted_inline_content (SV *converter_in, category, 
...)
-         char *category = (char *)SvPVutf8_nolen($arg);
+         const char *category = (char *)SvPVutf8_nolen($arg);
       PROTOTYPE: $$$
       PREINIT:
          CONVERTER *self;
-         char *inline_content = 0;
+         const char *inline_content = 0;
      CODE:
          self = get_sv_converter (converter_in,
                        "html_register_pending_formatted_inline_content");
@@ -1631,7 +1632,7 @@ html_register_pending_formatted_inline_content (SV 
*converter_in, category, ...)
 
 SV *
 html_cancel_pending_formatted_inline_content (SV *converter_in, category)
-         char *category = (char *)SvPVutf8_nolen($arg);
+         const char *category = (char *)SvPVutf8_nolen($arg);
       PREINIT:
          CONVERTER *self;
          char *inline_content = 0;
@@ -1677,7 +1678,7 @@ html_get_pending_formatted_inline_content (SV 
*converter_in)
 
 void
 html_associate_pending_formatted_inline_content (SV *converter_in, SV 
*element_sv, inline_content)
-         char *inline_content = (char *)SvPVutf8_nolen($arg);
+         const char *inline_content = (char *)SvPVutf8_nolen($arg);
       PREINIT:
          CONVERTER *self;
       CODE:
@@ -1759,7 +1760,7 @@ html_command_is_in_referred_command_stack (SV 
*converter_in, SV *element_sv)
 
 int
 html_check_htmlxref_already_warned (SV *converter_in, manual_name, SV 
*source_info_sv)
-         char *manual_name = (char *)SvPVutf8_nolen($arg);
+         const char *manual_name = (char *)SvPVutf8_nolen($arg);
       PREINIT:
          CONVERTER *self;
          SOURCE_INFO *source_info = 0;
@@ -1790,7 +1791,7 @@ html_prepare_conversion_units (SV *converter_in, ...)
       PROTOTYPE: $$$
       PREINIT:
          HV *converter_hv;
-         char *document_name = 0;
+         const char *document_name = 0;
          CONVERTER *self;
          int output_units_descriptor = 0;
          int special_units_descriptor = 0;
@@ -1840,10 +1841,10 @@ html_prepare_conversion_units (SV *converter_in, ...)
 
 SV *
 html_prepare_units_directions_files (SV *converter_in, SV *output_units_in, SV 
*special_units_in, SV *associated_special_units_in, output_file, 
destination_directory, output_filename, document_name)
-         char *output_file = (char *)SvPVutf8_nolen($arg);
-         char *destination_directory = (char *)SvPVutf8_nolen($arg);
-         char *output_filename = (char *)SvPVutf8_nolen($arg);
-         char *document_name = (char *)SvPVutf8_nolen($arg);
+         const char *output_file = (char *)SvPVutf8_nolen($arg);
+         const char *destination_directory = (char *)SvPVutf8_nolen($arg);
+         const char *output_filename = (char *)SvPVutf8_nolen($arg);
+         const char *document_name = (char *)SvPVutf8_nolen($arg);
   PREINIT:
          CONVERTER *self = 0;
          int output_units_descriptor = 0;
@@ -2003,8 +2004,8 @@ html_prepare_converted_output_info (SV *converter_in)
 
 void
 html_prepare_title_titlepage (SV *converter_in, SV *output_units_in, 
output_file, output_filename)
-         char *output_file = (char *)SvPVutf8_nolen($arg);
-         char *output_filename = (char *)SvPVutf8_nolen($arg);
+         const char *output_file = (char *)SvPVutf8_nolen($arg);
+         const char *output_filename = (char *)SvPVutf8_nolen($arg);
   PREINIT:
          CONVERTER *self = 0;
          int output_units_descriptor = 0;
@@ -2074,7 +2075,7 @@ html_convert_convert (SV *converter_in, SV *tree_in, SV 
*output_units_in, SV *sp
 # currently not used, convert_tree is not called on trees registered in XS
 SV *
 html_convert_tree (SV *converter_in, SV *tree_in, explanation)
-        char *explanation = (char *)SvPVbyte_nolen($arg);
+        const char *explanation = (char *)SvPVbyte_nolen($arg);
   PROTOTYPE: $$;$
   PREINIT:
         CONVERTER *self = 0;
@@ -2102,10 +2103,10 @@ html_convert_tree (SV *converter_in, SV *tree_in, 
explanation)
 
 SV *
 html_convert_output (SV *converter_in, SV *tree_in, SV *output_units_in, SV 
*special_units_in, output_file, destination_directory, output_filename, 
document_name)
-         char *output_file = (char *)SvPVutf8_nolen($arg);
-         char *destination_directory = (char *)SvPVutf8_nolen($arg);
-         char *output_filename = (char *)SvPVutf8_nolen($arg);
-         char *document_name = (char *)SvPVutf8_nolen($arg);
+         const char *output_file = (char *)SvPVutf8_nolen($arg);
+         const char *destination_directory = (char *)SvPVutf8_nolen($arg);
+         const char *output_filename = (char *)SvPVutf8_nolen($arg);
+         const char *document_name = (char *)SvPVutf8_nolen($arg);
   PREINIT:
          CONVERTER *self = 0;
          DOCUMENT *document = 0;
@@ -2157,7 +2158,7 @@ html_convert_output (SV *converter_in, SV *tree_in, SV 
*output_units_in, SV *spe
 
 SV *
 html_prepare_node_redirection_page (SV *converter_in, SV *element_sv, 
redirection_filename)
-         char *redirection_filename = (char *)SvPVutf8_nolen($arg);
+         const char *redirection_filename = (char *)SvPVutf8_nolen($arg);
      PREINIT:
          CONVERTER *self;
          char *redirection_page = 0;
diff --git a/tp/Texinfo/XS/convert/build_html_perl_state.c 
b/tp/Texinfo/XS/convert/build_html_perl_state.c
index 182b2dec04..5d32e9de8c 100644
--- a/tp/Texinfo/XS/convert/build_html_perl_state.c
+++ b/tp/Texinfo/XS/convert/build_html_perl_state.c
@@ -60,7 +60,7 @@
 
 #define STORE(key, sv) hv_store (html_target_hv, key, strlen (key), sv, 0)
 HV *
-build_html_target (HTML_TARGET *html_target)
+build_html_target (const HTML_TARGET *html_target)
 {
   HV *html_target_hv;
   SV *target_sv;
@@ -155,7 +155,7 @@ build_html_global_units_directions (const OUTPUT_UNIT 
**global_units_directions,
     {
       if (global_units_directions[i])
         {
-          char *direction_name = html_global_unit_direction_names[i];
+          const char *direction_name = html_global_unit_direction_names[i];
           hv_store (hv, direction_name, strlen (direction_name),
                     newRV_inc ((SV *) global_units_directions[i]->hv), 0);
         }
@@ -319,7 +319,7 @@ build_html_translated_names (HV *hv, CONVERTER *converter)
               HTML_COMMAND_CONVERSION *no_arg_cmd_context
                   = &conversion_contexts[k];
 
-              char *context_name = html_conversion_context_type_names[k];
+              const 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);
diff --git a/tp/Texinfo/XS/convert/build_html_perl_state.h 
b/tp/Texinfo/XS/convert/build_html_perl_state.h
index 755df68907..f7dbb971b9 100644
--- a/tp/Texinfo/XS/convert/build_html_perl_state.h
+++ b/tp/Texinfo/XS/convert/build_html_perl_state.h
@@ -12,7 +12,7 @@
 /* for NAMED_STRING_ELEMENT_LIST */
 #include "translations.h"
 
-HV *build_html_target (HTML_TARGET *html_target);
+HV *build_html_target (const HTML_TARGET *html_target);
 void build_html_translated_names (HV *hv, CONVERTER *converter);
 
 SV *build_html_files_source_info
diff --git a/tp/Texinfo/XS/convert/convert_html.c 
b/tp/Texinfo/XS/convert/convert_html.c
index 50d9c6ed6d..475359e467 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -58,9 +58,6 @@
 #include "api_to_perl.h"
 #include "convert_html.h"
 
-char *count_elements_in_filename_type_names[] = {
- "total", "remaining", "current"};
-
 typedef struct ROOT_AND_UNIT {
     const OUTPUT_UNIT *output_unit;
     const ELEMENT *root;
@@ -116,20 +113,23 @@ typedef struct SPECIAL_UNIT_BODY_INTERNAL_CONVERSION {
                                TEXT *result);
 } SPECIAL_UNIT_BODY_INTERNAL_CONVERSION;
 
-char *html_global_unit_direction_names[] = {
+const char *count_elements_in_filename_type_names[] = {
+ "total", "remaining", "current"};
+
+const char *html_global_unit_direction_names[] = {
   #define hgdt_name(name) #name,
    HTML_GLOBAL_DIRECTIONS_LIST
   #undef hgdt_name
    " ",
 };
 
-char *html_conversion_context_type_names[] = {
+const char *html_conversion_context_type_names[] = {
   #define cctx_type(name) #name,
    HCC_CONTEXT_TYPES_LIST
   #undef cctx_type
 };
 
-char *html_formatting_reference_names[] = {
+const char *html_formatting_reference_names[] = {
   #define html_fr_reference(name) #name,
    HTML_FORMATTING_REFERENCES_LIST
   #undef html_fr_reference
@@ -171,7 +171,7 @@ const char *css_info_type_names[] =
   "element_classes", "imports", "rules"
 };
 
-enum htmlxref_split_type htmlxref_entries[htmlxref_split_type_chapter + 
1][htmlxref_split_type_chapter + 1] = {
+const enum htmlxref_split_type htmlxref_entries[htmlxref_split_type_chapter + 
1][htmlxref_split_type_chapter + 1] = {
  { htmlxref_split_type_mono, htmlxref_split_type_chapter, 
htmlxref_split_type_section, htmlxref_split_type_node },
  { htmlxref_split_type_node, htmlxref_split_type_section, 
htmlxref_split_type_chapter, htmlxref_split_type_mono },
  { htmlxref_split_type_section, htmlxref_split_type_chapter, 
htmlxref_split_type_node, htmlxref_split_type_mono },
@@ -179,7 +179,7 @@ enum htmlxref_split_type 
htmlxref_entries[htmlxref_split_type_chapter + 1][htmlx
 };
 
 
-TRANSLATED_SUI_ASSOCIATION translated_special_unit_info[] = {
+const TRANSLATED_SUI_ASSOCIATION translated_special_unit_info[] = {
   {SUIT_type_heading, SUI_type_heading},
   /* these special types end the list */
   {SUIT_type_none, SUI_type_none},
@@ -308,7 +308,7 @@ unit_is_top_output_unit (CONVERTER *self, const OUTPUT_UNIT 
*output_unit)
 }
 
 int
-html_special_unit_variety_direction_index (CONVERTER *self,
+html_special_unit_variety_direction_index (const CONVERTER *self,
                                       const char *special_unit_variety)
 {
   /* number is index +1 */
@@ -811,7 +811,7 @@ html_top_block_command (const CONVERTER *self)
   return top_command (&top_document_ctx->block_commands);
 }
 
-COMMAND_OR_TYPE_STACK *
+const COMMAND_OR_TYPE_STACK *
 html_preformatted_classes_stack (const CONVERTER *self)
 {
   HTML_DOCUMENT_CONTEXT *top_document_ctx;
@@ -903,7 +903,7 @@ compare_page_name_number (const void *a, const void *b)
 
 size_t
 find_page_name_number
-     (const PAGE_NAME_NUMBER_LIST *page_name_number,
+            (const PAGE_NAME_NUMBER_LIST *page_name_number,
                                           const char *page_name)
 {
   PAGE_NAME_NUMBER *result = 0;
@@ -928,12 +928,12 @@ find_page_name_number
 }
 
 size_t
-count_elements_in_file_number (CONVERTER *self,
+count_elements_in_file_number (const CONVERTER *self,
                  enum count_elements_in_filename_type type,
                  size_t file_number)
 {
   size_t i = file_number - 1;
-  FILE_NAME_PATH_COUNTER *file_counter
+  const FILE_NAME_PATH_COUNTER *file_counter
             = &self->output_unit_files.list[i];
 
   if (type == CEFT_total)
@@ -946,7 +946,7 @@ count_elements_in_file_number (CONVERTER *self,
 
 /* called from perl */
 size_t
-html_count_elements_in_filename (CONVERTER *self,
+html_count_elements_in_filename (const CONVERTER *self,
                  enum count_elements_in_filename_type type,
                  const char *filename)
 {
@@ -1193,13 +1193,13 @@ html_get_pending_formatted_inline_content (CONVERTER 
*self)
 
 static size_t
 get_associated_inline_content_number (
-     HTML_ASSOCIATED_INLINE_CONTENT_LIST *associated_content_list,
+     const HTML_ASSOCIATED_INLINE_CONTENT_LIST *associated_content_list,
      const ELEMENT *element, const void *hv)
 {
   size_t i;
   for (i = 0; i < associated_content_list->number; i++)
     {
-      HTML_ASSOCIATED_INLINE_CONTENT *element_associated_content
+      const HTML_ASSOCIATED_INLINE_CONTENT *element_associated_content
         = &associated_content_list->list[i];
       if ((element && (element_associated_content->element == element
                        || (element->hv
@@ -1280,7 +1280,7 @@ html_associate_pending_formatted_inline_content 
(CONVERTER *self,
 char *
 html_get_associated_formatted_inline_content (CONVERTER *self,
                                               const ELEMENT *element,
-                                              void *hv)
+                                              const void *hv)
 {
   HTML_ASSOCIATED_INLINE_CONTENT_LIST *associated_content_list
     = &self->associated_inline_content;
@@ -1322,11 +1322,11 @@ html_register_file_information (CONVERTER *self, const 
char *key,
 }
 
 int
-html_get_file_information (CONVERTER *self, const char *key,
+html_get_file_information (const CONVERTER *self, const char *key,
                            const char *filename, int *status)
 {
   size_t page_number;
-  ASSOCIATED_INFO *associated_info;
+  const ASSOCIATED_INFO *associated_info;
   const KEY_PAIR *k;
 
   *status = 0;
@@ -3135,12 +3135,13 @@ external_node_href (CONVERTER *self, const ELEMENT 
*external_node,
 
       if (htmlxref_manual)
         {
-          enum htmlxref_split_type *ordered_split_types
+          const enum htmlxref_split_type *ordered_split_types
              = htmlxref_entries[self->document_htmlxref_split_type];
           int i;
           for (i = 0; i < htmlxref_split_type_chapter +1; i++)
             {
-              enum htmlxref_split_type split_ordered = ordered_split_types[i];
+              const enum htmlxref_split_type split_ordered
+                = ordered_split_types[i];
               if (htmlxref_manual->urlprefix[split_ordered])
                 {
                   split_found = split_ordered;
@@ -4483,11 +4484,11 @@ html_get_css_elements_classes (CONVERTER *self, const 
char *filename)
   for (j = 0; j < selector_nr; j++)
     {
       if (!strcmp ("a.copiable-link", selectors[j]))
-         {
-           selectors[selector_nr] = "span:hover a.copiable-link";
-           selector_nr++;
-           break;
-         }
+        {
+          selectors[selector_nr] = "span:hover a.copiable-link";
+          selector_nr++;
+          break;
+        }
     }
 
   qsort (selectors, selector_nr, sizeof (char *), compare_strings);
@@ -11790,12 +11791,12 @@ convert_item_command (CONVERTER *self, const enum 
command_id cmd,
 
           if (html_in_preformatted_context (self))
             {
-              COMMAND_OR_TYPE_STACK *pre_classes
+              const COMMAND_OR_TYPE_STACK *pre_classes
                 = html_preformatted_classes_stack (self);
               size_t i;
               for (i = 0; i < pre_classes->top; i++)
                 {
-                  COMMAND_OR_TYPE *cmd_or_type
+                  const COMMAND_OR_TYPE *cmd_or_type
                    = &pre_classes->stack[i];
                   if (cmd_or_type->variety == CTV_type_command)
                     {
@@ -17900,9 +17901,6 @@ convert_to_html_internal (CONVERTER *self, const 
ELEMENT *element,
                     {
                       char *explanation;
                       unsigned long arg_flags = 0;
-                      /* actually const, but cannot be marked as such because
-                         the argument of call_latex_convert_to_latex_math
-                         cannot be const in case perl element has to be built 
*/
                       const ELEMENT *arg = element->args.list[arg_idx];
                       HTML_ARG_FORMATTED *arg_formatted
                          = &args_formatted->args[arg_idx];
@@ -18239,7 +18237,7 @@ convert_to_html_internal (CONVERTER *self, const 
ELEMENT *element,
 
 void
 convert_output_unit (CONVERTER *self, const OUTPUT_UNIT *output_unit,
-                     char *explanation, TEXT *result)
+                     const char *explanation, TEXT *result)
 {
   TEXT content_formatted;
   /* store this to be able to show only what was added in debug message */
@@ -18277,12 +18275,12 @@ convert_output_unit (CONVERTER *self, const 
OUTPUT_UNIT *output_unit,
            content_idx++)
        {
          const ELEMENT *content = output_unit->unit_contents.list[content_idx];
-         char *explanation;
-         xasprintf (&explanation, "%s c[%d]",
+         char *content_explanation;
+         xasprintf (&content_explanation, "%s c[%d]",
                     output_unit_type_names[unit_type], content_idx);
          convert_to_html_internal (self, content, &content_formatted,
-                                   explanation);
-         free (explanation);
+                                   content_explanation);
+         free (content_explanation);
        }
     }
 
@@ -18310,7 +18308,7 @@ convert_output_unit (CONVERTER *self, const OUTPUT_UNIT 
*output_unit,
 void
 convert_convert_output_unit_internal (CONVERTER *self, TEXT *result,
                                    const OUTPUT_UNIT *output_unit, int unit_nr,
-                                   char *debug_str, char *explanation_str)
+                                   const char *debug_str, const char 
*explanation_str)
 {
   char *explanation;
 
@@ -18366,7 +18364,7 @@ html_convert_convert (CONVERTER *self, const ELEMENT 
*root,
 
 int
 convert_output_output_unit_internal (CONVERTER *self,
-                                     ENCODING_CONVERSION *conversion,
+                                     const ENCODING_CONVERSION *conversion,
                                      TEXT *text,
                                      const OUTPUT_UNIT *output_unit,
                                      int unit_nr)
@@ -18384,7 +18382,7 @@ convert_output_output_unit_internal (CONVERTER *self,
   if (output_unit->unit_type == OU_special_unit)
     {
       char *debug_str;
-      char *special_unit_variety = output_unit->special_unit_variety;
+      const char *special_unit_variety = output_unit->special_unit_variety;
 
       file_index = self->special_unit_file_indices[output_unit->index];
       self->current_filename.file_number = file_index +1;
@@ -18526,7 +18524,7 @@ html_prepare_title_titlepage (CONVERTER *self, int 
output_units_descriptor,
                               const char *output_file,
                               const char *output_filename)
 {
-  OUTPUT_UNIT_LIST *output_units
+  const OUTPUT_UNIT_LIST *output_units
     = retrieve_output_units (output_units_descriptor);
 
   if (strlen (output_file))
@@ -18552,8 +18550,8 @@ char *
 html_convert_output (CONVERTER *self, const ELEMENT *root,
                      int output_units_descriptor,
                      int special_units_descriptor,
-                     char *output_file, char *destination_directory,
-                     char *output_filename, char *document_name)
+                     const char *output_file, const char 
*destination_directory,
+                     const char *output_filename, const char *document_name)
 {
   int status = 1;
   TEXT result;
@@ -18646,7 +18644,7 @@ html_convert_output (CONVERTER *self, const ELEMENT 
*root,
     {
       int unit_nr = 0;
       int i;
-      ENCODING_CONVERSION *conversion = 0;
+      const ENCODING_CONVERSION *conversion = 0;
 
       if (self->conf->OUTPUT_ENCODING_NAME.string
           && strcmp (self->conf->OUTPUT_ENCODING_NAME.string, "utf-8"))
diff --git a/tp/Texinfo/XS/convert/convert_html.h 
b/tp/Texinfo/XS/convert/convert_html.h
index b4aadfbe74..b9f6bf00e3 100644
--- a/tp/Texinfo/XS/convert/convert_html.h
+++ b/tp/Texinfo/XS/convert/convert_html.h
@@ -20,12 +20,12 @@ enum css_info_type {
    CI_css_info_rules,
 };
 
-extern char *html_conversion_context_type_names[];
-extern char *html_global_unit_direction_names[];
+extern const char *html_conversion_context_type_names[];
+extern const char *html_global_unit_direction_names[];
 
-extern char *html_formatting_reference_names[];
+extern const char *html_formatting_reference_names[];
 
-extern TRANSLATED_SUI_ASSOCIATION translated_special_unit_info[];
+extern const TRANSLATED_SUI_ASSOCIATION translated_special_unit_info[];
 extern const char *special_unit_info_type_names[SUI_type_heading + 1];
 extern const char *htmlxref_split_type_names[htmlxref_split_type_chapter + 1];
 
@@ -34,7 +34,7 @@ extern const char *css_info_type_names[];
 extern const char *direction_string_type_names[];
 extern const char *direction_string_context_names[];
 
-extern char *count_elements_in_filename_type_names[];
+extern const char *count_elements_in_filename_type_names[];
 
 void html_format_init (void);
 
@@ -76,21 +76,22 @@ int html_in_raw (const CONVERTER *self);
 int html_paragraph_number (const CONVERTER *self);
 int html_preformatted_number (const CONVERTER *self);
 enum command_id html_top_block_command (const CONVERTER *self);
-COMMAND_OR_TYPE_STACK *html_preformatted_classes_stack (const CONVERTER *self);
+const COMMAND_OR_TYPE_STACK *html_preformatted_classes_stack
+                                    (const CONVERTER *self);
 enum command_id html_in_align (const CONVERTER *self);
 
 char *debug_print_html_contexts (const CONVERTER *self);
 
-size_t html_count_elements_in_filename (CONVERTER *self,
+size_t html_count_elements_in_filename (const CONVERTER *self,
                  enum count_elements_in_filename_type type,
                  const char *filename);
 
 void html_register_file_information (CONVERTER *self, const char *key,
                                      int value);
-int html_get_file_information (CONVERTER *self, const char *key,
+int html_get_file_information (const CONVERTER *self, const char *key,
                                const char *filename, int *status);
 
-int html_special_unit_variety_direction_index (CONVERTER *self,
+int html_special_unit_variety_direction_index (const CONVERTER *self,
                                         const char *special_unit_variety);
 
 HTML_TARGET *html_get_target (const CONVERTER *self, const ELEMENT *element);
@@ -165,7 +166,7 @@ void html_associate_pending_formatted_inline_content 
(CONVERTER *self,
                                             const char *inline_content);
 char *html_get_associated_formatted_inline_content (CONVERTER *self,
                                               const ELEMENT *element,
-                                              void *hv);
+                                              const void *hv);
 
 size_t html_check_htmlxref_already_warned (CONVERTER *self,
                                            const char *manual_name,
@@ -210,8 +211,10 @@ char *html_convert_tree (CONVERTER *self, const ELEMENT 
*tree,
 char *html_convert_output (CONVERTER *self, const ELEMENT *root,
                            int output_units_descriptor,
                            int special_units_descriptor,
-                           char *output_file, char *destination_directory,
-                           char *output_filename, char *document_name);
+                           const char *output_file,
+                           const char *destination_directory,
+                           const char *output_filename,
+                           const char *document_name);
 
 char *html_prepare_node_redirection_page (CONVERTER *self,
                                           const ELEMENT *element,
diff --git a/tp/Texinfo/XS/convert/get_html_perl_info.c 
b/tp/Texinfo/XS/convert/get_html_perl_info.c
index 4777da5af0..b9929a7976 100644
--- a/tp/Texinfo/XS/convert/get_html_perl_info.c
+++ b/tp/Texinfo/XS/convert/get_html_perl_info.c
@@ -235,7 +235,7 @@ html_converter_initialize_sv (SV *converter_sv,
 
   for (i = 0; i < FR_format_translate_message+1; i++)
     {
-      char *ref_name = html_formatting_reference_names[i];
+      const char *ref_name = html_formatting_reference_names[i];
       FORMATTING_REFERENCE *formatting_reference
         = &converter->formatting_references[i];
       SV **default_formatting_reference_sv
@@ -273,7 +273,7 @@ html_converter_initialize_sv (SV *converter_sv,
 
   for (i = 0; i < FR_format_translate_message+1; i++)
     {
-      char *ref_name = html_formatting_reference_names[i];
+      const char *ref_name = html_formatting_reference_names[i];
       SV **default_formatting_reference_sv
         = hv_fetch (default_css_string_formatting_references_hv, ref_name,
                     strlen (ref_name), 0);
diff --git a/tp/Texinfo/XS/main/build_perl_info.c 
b/tp/Texinfo/XS/main/build_perl_info.c
index 99830b7cad..3fff0a4b74 100644
--- a/tp/Texinfo/XS/main/build_perl_info.c
+++ b/tp/Texinfo/XS/main/build_perl_info.c
@@ -135,6 +135,8 @@ build_perl_array (ELEMENT_LIST *e, int avoid_recursion)
               text_init (&message);
               text_printf (&message,
                 "BUG: build_perl_array oot %d: %s\n", i, debug_str);
+      /* Calling free in this file on data possibly allocated with gnulib
+         is not ok in general, but ok here, as it should never be called */
               free (debug_str);
               fprintf (stderr, "%s", message.text);
               free (message.text);
@@ -196,6 +198,8 @@ build_perl_directions (const ELEMENT_LIST *e, int 
avoid_recursion)
                   text_init (&message);
                   text_printf (&message,
                     "BUG: build_perl_directions oot %s: %s\n", key, debug_str);
+      /* Calling free in this file on data possibly allocated with gnulib
+         is not ok in general, but ok here, as it should never be called */
                   free (debug_str);
                   fprintf (stderr, "%s", message.text);
                   free (message.text);
@@ -550,8 +554,8 @@ element_to_perl_hash (ELEMENT *e, int avoid_recursion)
           text_init (&message);
           text_printf (&message, "parent %p hv not set in %s '%s'\n",
                             e->parent, debug_str, convert_to_texinfo (e));
-          free (debug_str);
           fatal (message.text);
+          free (debug_str);
         }
       sv = newRV_inc ((SV *) e->parent->hv);
       hv_store (e->hv, "parent", strlen ("parent"), sv, HSH_parent);
diff --git a/tp/Texinfo/XS/main/convert_utils.c 
b/tp/Texinfo/XS/main/convert_utils.c
index bdf8a6776c..23a453a560 100644
--- a/tp/Texinfo/XS/main/convert_utils.c
+++ b/tp/Texinfo/XS/main/convert_utils.c
@@ -270,9 +270,9 @@ convert_to_utf8_verbatiminclude (char *s, 
ENCODING_CONVERSION *conversion,
   The caller should free the return value and FILE_NAME_ENCODING.
 */
 char *
-encoded_input_file_name (OPTIONS *options,
-                         GLOBAL_INFO *global_information,
-                         char *file_name, char *input_file_encoding,
+encoded_input_file_name (const OPTIONS *options,
+                         const GLOBAL_INFO *global_information,
+                         char *file_name, const char *input_file_encoding,
                          char **file_name_encoding,
                          const SOURCE_INFO *source_info)
 {
@@ -302,13 +302,16 @@ encoded_input_file_name (OPTIONS *options,
   return result;
 }
 
+/* NOTE it would have been better to have FILE_NAME const, but iconv
+   argument may not be const, so no const here either */
 char *
-encoded_output_file_name (OPTIONS *options, GLOBAL_INFO *global_information,
+encoded_output_file_name (const OPTIONS *options,
+                          const GLOBAL_INFO *global_information,
                           char *file_name, char **file_name_encoding,
-                          SOURCE_INFO *source_info)
+                          const SOURCE_INFO *source_info)
 {
   char *result;
-  char *encoding = 0;
+  const char *encoding = 0;
   int status;
 
   if (options && options->OUTPUT_FILE_NAME_ENCODING.string)
diff --git a/tp/Texinfo/XS/main/convert_utils.h 
b/tp/Texinfo/XS/main/convert_utils.h
index dbbbd27eda..d5028df204 100644
--- a/tp/Texinfo/XS/main/convert_utils.h
+++ b/tp/Texinfo/XS/main/convert_utils.h
@@ -42,15 +42,16 @@ ELEMENT *cdt_tree (const char * string, CONVERTER *self,
 ELEMENT *translated_command_tree (CONVERTER *self, enum command_id cmd);
 void destroy_translated_commands (TRANSLATED_COMMAND *translated_commands);
 
-char *encoded_input_file_name (OPTIONS *options,
-                         GLOBAL_INFO *global_information,
-                         char *file_name, char *input_file_encoding,
+char *encoded_input_file_name (const OPTIONS *options,
+                         const GLOBAL_INFO *global_information,
+                         char *file_name, const char *input_file_encoding,
                          char **file_name_encoding,
                          const SOURCE_INFO *source_info);
-char *encoded_output_file_name (OPTIONS *options,
-                                GLOBAL_INFO *global_information,
-                                char *file_name, char **file_name_encoding,
-                                SOURCE_INFO *source_info);
+char *encoded_output_file_name (const OPTIONS *options,
+                                const GLOBAL_INFO *global_information,
+                                char *file_name,
+                                char **file_name_encoding,
+                                const SOURCE_INFO *source_info);
 
 FILE *output_files_open_out (OUTPUT_FILES_INFORMATION *self,
                              const char *file_path,
diff --git a/tp/Texinfo/XS/main/document_types.h 
b/tp/Texinfo/XS/main/document_types.h
index 984c6c9b76..3ca7b488d8 100644
--- a/tp/Texinfo/XS/main/document_types.h
+++ b/tp/Texinfo/XS/main/document_types.h
@@ -35,7 +35,7 @@ struct TEXT_OPTIONS;
 enum error_type { MSG_error, MSG_warning,
                   MSG_document_error, MSG_document_warning };
 
-typedef struct {
+typedef struct ERROR_MESSAGE {
     char *message;
     char *error_line;
     enum error_type type;
@@ -43,7 +43,7 @@ typedef struct {
     SOURCE_INFO source_info;
 } ERROR_MESSAGE;
 
-typedef struct {
+typedef struct ERROR_MESSAGE_LIST {
     ERROR_MESSAGE *list;
     size_t number;
     size_t space;
diff --git a/tp/Texinfo/XS/main/errors.c b/tp/Texinfo/XS/main/errors.c
index 241cfa20fc..b2de7edcc6 100644
--- a/tp/Texinfo/XS/main/errors.c
+++ b/tp/Texinfo/XS/main/errors.c
@@ -57,14 +57,14 @@ void
 message_list_line_formatted_message (ERROR_MESSAGE_LIST *error_messages,
                            enum error_type type, int continuation,
                            const SOURCE_INFO *cmd_source_info,
-                           char *message, int warn)
+                           const char *message, int warn)
 {
   TEXT error_line;
   ERROR_MESSAGE *error_message;
 
   error_message = reallocate_error_messages (error_messages);
 
-  error_message->message = message;
+  error_message->message = strdup (message);
   error_message->type = type;
   error_message->continuation = continuation;
 
@@ -145,20 +145,21 @@ vmessage_list_line_error (ERROR_MESSAGE_LIST 
*error_messages,
   message_list_line_formatted_message (error_messages,
                              type, continuation,
                              cmd_source_info, message, warn);
+  free (message);
 }
 
 void
 message_list_document_formatted_message (ERROR_MESSAGE_LIST *error_messages,
                                          const OPTIONS *conf,
                                          enum error_type type, int 
continuation,
-                                         char *message)
+                                         const char *message)
 {
   TEXT error_line;
   ERROR_MESSAGE *error_message;
 
   error_message = reallocate_error_messages (error_messages);
 
-  error_message->message = message;
+  error_message->message = strdup (message);
   error_message->type = type;
   error_message->continuation = continuation;
 
@@ -228,7 +229,9 @@ message_list_document_error_internal (ERROR_MESSAGE_LIST 
*error_messages,
   if (!message) fatal ("vasprintf failed");
 
   message_list_document_formatted_message (error_messages, conf, type,
-                                            continuation, message);
+                                           continuation, message);
+
+  free (message);
 }
 
 void
diff --git a/tp/Texinfo/XS/main/errors.h b/tp/Texinfo/XS/main/errors.h
index 5c5411ae21..36231249ab 100644
--- a/tp/Texinfo/XS/main/errors.h
+++ b/tp/Texinfo/XS/main/errors.h
@@ -13,7 +13,7 @@ void clear_error_message_list (ERROR_MESSAGE_LIST 
*error_messages);
 void message_list_line_formatted_message (ERROR_MESSAGE_LIST *error_messages,
                            enum error_type type, int continuation,
                            const SOURCE_INFO *cmd_source_info,
-                           char *message, int warn);
+                           const char *message, int warn);
 void vmessage_list_line_error (ERROR_MESSAGE_LIST *error_messages,
                           enum error_type type, int continuation,
                           int warn,
@@ -33,7 +33,7 @@ void message_list_command_warn (ERROR_MESSAGE_LIST 
*error_messages,
 void message_list_document_formatted_message (ERROR_MESSAGE_LIST 
*error_messages,
                                          const OPTIONS *conf,
                                          enum error_type type, int 
continuation,
-                                         char *message);
+                                         const char *message);
 void message_list_document_error (ERROR_MESSAGE_LIST *error_messages,
                                   const OPTIONS *conf, int continuation,
                                   const char *format, ...);
diff --git a/tp/Texinfo/XS/main/get_perl_info.c 
b/tp/Texinfo/XS/main/get_perl_info.c
index bd8f796f86..ba986dc450 100644
--- a/tp/Texinfo/XS/main/get_perl_info.c
+++ b/tp/Texinfo/XS/main/get_perl_info.c
@@ -53,6 +53,9 @@
 
 #define FETCH(key) key##_sv = hv_fetch (element_hv, #key, strlen(#key), 0);
 
+/* used for debugging only */
+/* This function mixes Perl and gnulib allocation functions, but since it is
+   only used for debugging it is ok */
 static void
 debug_print_element_hv (HV *element_hv)
 {
@@ -91,6 +94,7 @@ debug_print_element_hv (HV *element_hv)
   free (msg.text);
 }
 
+/* used for debugging only */
 void
 debug_print_element_sv (SV *element_sv)
 {
@@ -305,7 +309,7 @@ get_source_info (SV *source_info_sv)
 
 void
 get_line_message (CONVERTER *self, enum error_type type, int continuation,
-                  SV *error_location_info, char *message)
+                  SV *error_location_info, const char *message)
 {
   int do_warn = (self->conf->DEBUG.integer > 1);
   SOURCE_INFO *source_info = get_source_info (error_location_info);
diff --git a/tp/Texinfo/XS/main/get_perl_info.h 
b/tp/Texinfo/XS/main/get_perl_info.h
index d820963e4e..af3bf0e27a 100644
--- a/tp/Texinfo/XS/main/get_perl_info.h
+++ b/tp/Texinfo/XS/main/get_perl_info.h
@@ -31,7 +31,7 @@ void add_svav_to_string_list (const SV *sv, STRING_LIST 
*string_list,
 
 SOURCE_INFO *get_source_info (SV *source_info_sv);
 void get_line_message (CONVERTER *self, enum error_type type, int continuation,
-                       SV *error_location_info, char *message);
+                       SV *error_location_info, const char *message);
 OPTIONS *init_copy_sv_options (SV *sv_in, CONVERTER *converter, int force);
 void get_sv_configured_options (SV *configured_sv_in, OPTIONS *options);
 void copy_converter_conf_sv (HV *hv, CONVERTER *converter,
diff --git a/tp/Texinfo/XS/main/utils.c b/tp/Texinfo/XS/main/utils.c
index b8d2c57e3f..6c24db12f5 100644
--- a/tp/Texinfo/XS/main/utils.c
+++ b/tp/Texinfo/XS/main/utils.c
@@ -400,7 +400,8 @@ text_buffer_iconv (TEXT *buf, iconv_t iconv_state,
 }
 
 char *
-encode_with_iconv (iconv_t our_iconv, char *s, const SOURCE_INFO *source_info)
+encode_with_iconv (iconv_t our_iconv, char *s,
+                   const SOURCE_INFO *source_info)
 {
   static TEXT t;
   ICONV_CONST char *inptr; size_t bytes_left;



reply via email to

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