texinfo-commits
[Top][All Lists]
Advanced

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

[no subject]


From: Patrice Dumas
Date: Mon, 13 Nov 2023 09:05:19 -0500 (EST)

branch: master
commit 62deacdc55baf78bcf6ab513820b3b1a398ee9ae
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Mon Nov 13 15:05:04 2023 +0100

    * tp/Texinfo/XS/convert/indices_in_conversion.c
    (index_content_element), tp/Texinfo/XS/main/builtin_commands.c
    (element_command_name, element_builtin_cmd),
    tp/Texinfo/XS/main/convert_to_texinfo.c (expand_cmd_args_to_texi)
    (convert_to_texinfo_internal, convert_to_texinfo)
    (link_element_to_texi, target_element_to_texi_label),
    tp/Texinfo/XS/main/debug.c (debug_element_command_name)
    (print_element_debug, debug_print_element), tp/Texinfo/XS/main/extra.c
    (lookup*), tp/Texinfo/XS/main/utils.c (get_label_element): add const
    to elements in input of soe functions, especially for conversion to
    Texinfo, to make sure that the tree is not modified by the conversion.
---
 ChangeLog                                     | 14 ++++++++++++++
 tp/Texinfo/XS/convert/indices_in_conversion.c |  2 +-
 tp/Texinfo/XS/convert/indices_in_conversion.h |  2 +-
 tp/Texinfo/XS/main/builtin_commands.c         |  4 ++--
 tp/Texinfo/XS/main/builtin_commands.h         |  4 ++--
 tp/Texinfo/XS/main/convert_to_texinfo.c       | 14 +++++++-------
 tp/Texinfo/XS/main/convert_to_texinfo.h       |  6 +++---
 tp/Texinfo/XS/main/debug.c                    |  6 +++---
 tp/Texinfo/XS/main/debug.h                    |  4 ++--
 tp/Texinfo/XS/main/extra.c                    | 26 +++++++++++++-------------
 tp/Texinfo/XS/main/extra.h                    | 16 ++++++++--------
 tp/Texinfo/XS/main/utils.c                    |  2 +-
 tp/Texinfo/XS/main/utils.h                    |  2 +-
 13 files changed, 58 insertions(+), 44 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 56e1de8c63..f116f1ab00 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2023-11-13  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/convert/indices_in_conversion.c
+       (index_content_element), tp/Texinfo/XS/main/builtin_commands.c
+       (element_command_name, element_builtin_cmd),
+       tp/Texinfo/XS/main/convert_to_texinfo.c (expand_cmd_args_to_texi)
+       (convert_to_texinfo_internal, convert_to_texinfo)
+       (link_element_to_texi, target_element_to_texi_label),
+       tp/Texinfo/XS/main/debug.c (debug_element_command_name)
+       (print_element_debug, debug_print_element), tp/Texinfo/XS/main/extra.c
+       (lookup*), tp/Texinfo/XS/main/utils.c (get_label_element): add const
+       to elements in input of soe functions, especially for conversion to
+       Texinfo, to make sure that the tree is not modified by the conversion.
+
 2023-11-13  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/main/node_name_normalization.c (normalize_top_name)
diff --git a/tp/Texinfo/XS/convert/indices_in_conversion.c 
b/tp/Texinfo/XS/convert/indices_in_conversion.c
index dccb185122..2c9018c35e 100644
--- a/tp/Texinfo/XS/convert/indices_in_conversion.c
+++ b/tp/Texinfo/XS/convert/indices_in_conversion.c
@@ -138,7 +138,7 @@ destroy_indices_sorted_by_letter (
 /* corresponding perl code in Texinfo::Common */
 
 ELEMENT *
-index_content_element (ELEMENT *element, int prefer_reference_element)
+index_content_element (const ELEMENT *element, int prefer_reference_element)
 {
   ELEMENT *def_command = lookup_extra_element (element, "def_command");
   if (def_command)
diff --git a/tp/Texinfo/XS/convert/indices_in_conversion.h 
b/tp/Texinfo/XS/convert/indices_in_conversion.h
index 101a34e5e3..f516695632 100644
--- a/tp/Texinfo/XS/convert/indices_in_conversion.h
+++ b/tp/Texinfo/XS/convert/indices_in_conversion.h
@@ -11,7 +11,7 @@ void destroy_merged_indices (MERGED_INDEX *merged_indices);
 void destroy_indices_sorted_by_letter (
          INDEX_SORTED_BY_LETTER *indices_entries_by_letter);
 
-ELEMENT *index_content_element (ELEMENT *element,
+ELEMENT *index_content_element (const ELEMENT *element,
                                 int prefer_reference_element);
 
 #endif
diff --git a/tp/Texinfo/XS/main/builtin_commands.c 
b/tp/Texinfo/XS/main/builtin_commands.c
index 65e0cd1ec5..f213d2d835 100644
--- a/tp/Texinfo/XS/main/builtin_commands.c
+++ b/tp/Texinfo/XS/main/builtin_commands.c
@@ -63,7 +63,7 @@ lookup_builtin_command (char *cmdname)
 /* this should be used when the user-defined commands are not available,
    ie outside of the parser */
 char *
-element_command_name (ELEMENT *e)
+element_command_name (const ELEMENT *e)
 {
   if (e->cmd && e->cmd < BUILTIN_CMD_NUMBER)
     return builtin_command_data[e->cmd].cmdname;
@@ -81,7 +81,7 @@ element_command_name (ELEMENT *e)
 /* map user-defined element commands to internal commands */
 
 enum command_id
-element_builtin_cmd (ELEMENT *e)
+element_builtin_cmd (const ELEMENT *e)
 {
   if (e->cmd && e->cmd < BUILTIN_CMD_NUMBER)
     return e->cmd;
diff --git a/tp/Texinfo/XS/main/builtin_commands.h 
b/tp/Texinfo/XS/main/builtin_commands.h
index 3621f35b29..cd4847ce7e 100644
--- a/tp/Texinfo/XS/main/builtin_commands.h
+++ b/tp/Texinfo/XS/main/builtin_commands.h
@@ -36,8 +36,8 @@ extern COMMAND builtin_command_data[];
    (!(e) ? 0 : (builtin_command_data[(e)->cmd].other_flags))
 
 enum command_id lookup_builtin_command (char *cmdname);
-char *element_command_name (ELEMENT *e);
-enum command_id element_builtin_cmd (ELEMENT *e);
+char *element_command_name (const ELEMENT *e);
+enum command_id element_builtin_cmd (const ELEMENT *e);
 enum command_id element_builtin_data_cmd (ELEMENT *e);
 
 /* Base command flags, .flags in COMMAND */
diff --git a/tp/Texinfo/XS/main/convert_to_texinfo.c 
b/tp/Texinfo/XS/main/convert_to_texinfo.c
index 93759b5955..b9492c71eb 100644
--- a/tp/Texinfo/XS/main/convert_to_texinfo.c
+++ b/tp/Texinfo/XS/main/convert_to_texinfo.c
@@ -35,14 +35,14 @@
 #include "convert_to_texinfo.h"
 
 
-static void expand_cmd_args_to_texi (ELEMENT *e, TEXT *result);
-static void convert_to_texinfo_internal (ELEMENT *e, TEXT *result);
+static void expand_cmd_args_to_texi (const ELEMENT *e, TEXT *result);
+static void convert_to_texinfo_internal (const ELEMENT *e, TEXT *result);
 
 
 #define ADD(x) text_append (result, x)
 
 static void
-expand_cmd_args_to_texi (ELEMENT *e, TEXT *result)
+expand_cmd_args_to_texi (const ELEMENT *e, TEXT *result)
 {
   enum command_id cmd = element_builtin_cmd (e);
   KEY_PAIR *arg_line;
@@ -135,7 +135,7 @@ expand_cmd_args_to_texi (ELEMENT *e, TEXT *result)
 }
 
 static void
-convert_to_texinfo_internal (ELEMENT *e, TEXT *result)
+convert_to_texinfo_internal (const ELEMENT *e, TEXT *result)
 {
   ELEMENT *elt;
 
@@ -190,7 +190,7 @@ convert_to_texinfo_internal (ELEMENT *e, TEXT *result)
 
 /* Return value to be freed by caller. */
 char *
-convert_to_texinfo (ELEMENT *e)
+convert_to_texinfo (const ELEMENT *e)
 {
   TEXT result;
 
@@ -220,7 +220,7 @@ convert_contents_to_texinfo (ELEMENT *e)
 
 /* Return value to be freed by caller. */
 char *
-link_element_to_texi (ELEMENT *element)
+link_element_to_texi (const ELEMENT *element)
 {
   TEXT result;
   ELEMENT *element_link;
@@ -250,7 +250,7 @@ link_element_to_texi (ELEMENT *element)
 
 /* Return value to be freed by caller. */
 char *
-target_element_to_texi_label (ELEMENT *element)
+target_element_to_texi_label (const ELEMENT *element)
 {
   ELEMENT *label_element = get_label_element (element);
   return convert_contents_to_texinfo (label_element);
diff --git a/tp/Texinfo/XS/main/convert_to_texinfo.h 
b/tp/Texinfo/XS/main/convert_to_texinfo.h
index 87d9baa5ee..bd347c84c1 100644
--- a/tp/Texinfo/XS/main/convert_to_texinfo.h
+++ b/tp/Texinfo/XS/main/convert_to_texinfo.h
@@ -4,10 +4,10 @@
 
 #include "tree_types.h"
 
-char *convert_to_texinfo (ELEMENT *e);
+char *convert_to_texinfo (const ELEMENT *e);
 char *convert_contents_to_texinfo (ELEMENT *e);
-char *link_element_to_texi (ELEMENT *element);
-char *target_element_to_texi_label (ELEMENT *element);
+char *link_element_to_texi (const ELEMENT *element);
+char *target_element_to_texi_label (const ELEMENT *element);
 
 int check_node_same_texinfo_code(ELEMENT *reference_node,
                                  ELEMENT *node_content);
diff --git a/tp/Texinfo/XS/main/debug.c b/tp/Texinfo/XS/main/debug.c
index f13f14b8ee..28edb24a97 100644
--- a/tp/Texinfo/XS/main/debug.c
+++ b/tp/Texinfo/XS/main/debug.c
@@ -59,7 +59,7 @@ debug_nonl (char *s, ...)
 }
 
 char *
-debug_element_command_name (ELEMENT *e)
+debug_element_command_name (const ELEMENT *e)
 {
   if (e->cmd == CM_TAB)
     return "\\t";
@@ -89,7 +89,7 @@ debug_protect_eol (char *input_string, int *allocated)
 }
 
 char *
-print_element_debug (ELEMENT *e, int print_parent)
+print_element_debug (const ELEMENT *e, int print_parent)
 {
   TEXT text;
   char *result;
@@ -235,7 +235,7 @@ print_element_debug_details (ELEMENT *e, int print_parent)
 }
 
 void
-debug_print_element (ELEMENT *e, int print_parent)
+debug_print_element (const ELEMENT *e, int print_parent)
 {
   if (debug_output)
     {
diff --git a/tp/Texinfo/XS/main/debug.h b/tp/Texinfo/XS/main/debug.h
index 0d69eab7c2..e18b41f302 100644
--- a/tp/Texinfo/XS/main/debug.h
+++ b/tp/Texinfo/XS/main/debug.h
@@ -12,8 +12,8 @@ extern int debug_output;
 void debug (char *s, ...);
 void debug_nonl (char *s, ...);
 void set_debug_output (int value);
-void debug_print_element (ELEMENT *e, int print_parent);
-char *print_element_debug (ELEMENT *e, int print_parent);
+void debug_print_element (const ELEMENT *e, int print_parent);
+char *print_element_debug (const ELEMENT *e, int print_parent);
 char *print_element_debug_details (ELEMENT *e, int print_parent);
 void debug_print_protected_string (char *input_string);
 char *debug_protect_eol (char *input_string, int *allocated);
diff --git a/tp/Texinfo/XS/main/extra.c b/tp/Texinfo/XS/main/extra.c
index 53b7d91ec7..bee68d017e 100644
--- a/tp/Texinfo/XS/main/extra.c
+++ b/tp/Texinfo/XS/main/extra.c
@@ -159,7 +159,7 @@ add_extra_integer (ELEMENT *e, char *key, long value)
 }
 
 KEY_PAIR *
-lookup_associated_info (ASSOCIATED_INFO *a, char *key)
+lookup_associated_info (const ASSOCIATED_INFO *a, char *key)
 {
   int i;
   for (i = 0; i < a->info_number; i++)
@@ -174,9 +174,9 @@ lookup_associated_info (ASSOCIATED_INFO *a, char *key)
 }
 
 ELEMENT *
-lookup_extra_element (ELEMENT *e, char *key)
+lookup_extra_element (const ELEMENT *e, char *key)
 {
-  KEY_PAIR *k;
+  const KEY_PAIR *k;
   k = lookup_associated_info (&e->extra_info, key);
   if (!k)
     return 0;
@@ -184,9 +184,9 @@ lookup_extra_element (ELEMENT *e, char *key)
 }
 
 char *
-lookup_extra_string (ELEMENT *e, char *key)
+lookup_extra_string (const ELEMENT *e, char *key)
 {
-  KEY_PAIR *k;
+  const KEY_PAIR *k;
   k = lookup_associated_info (&e->extra_info, key);
   if (!k || !k->value)
     return 0;
@@ -194,16 +194,16 @@ lookup_extra_string (ELEMENT *e, char *key)
 }
 
 KEY_PAIR *
-lookup_extra (ELEMENT *e, char *key)
+lookup_extra (const ELEMENT *e, char *key)
 {
   return lookup_associated_info (&e->extra_info, key);
 }
 
 /* *ret is negative if not found or not an integer */
 int
-lookup_extra_integer (ELEMENT *e, char *key, int *ret)
+lookup_extra_integer (const ELEMENT *e, char *key, int *ret)
 {
-  KEY_PAIR *k;
+  const KEY_PAIR *k;
   k = lookup_associated_info (&e->extra_info, key);
   if (!k)
     {
@@ -248,9 +248,9 @@ lookup_extra_directions (ELEMENT *e, char *key, int create)
 }
 
 ELEMENT *
-lookup_info_element (ELEMENT *e, char *key)
+lookup_info_element (const ELEMENT *e, char *key)
 {
-  KEY_PAIR *k;
+  const KEY_PAIR *k;
   k = lookup_associated_info (&e->info_info, key);
   if (!k)
     return 0;
@@ -259,14 +259,14 @@ lookup_info_element (ELEMENT *e, char *key)
 
 
 KEY_PAIR *
-lookup_info (ELEMENT *e, char *key)
+lookup_info (const ELEMENT *e, char *key)
 {
   return lookup_associated_info (&e->info_info, key);
 }
 
 /* only called in tree copy to optimize for speed */
 KEY_PAIR *
-lookup_associated_info_by_index (ASSOCIATED_INFO *a, char *key, int index)
+lookup_associated_info_by_index (const ASSOCIATED_INFO *a, char *key, int 
index)
 {
   if (index < 0)
     index = a->info_number + index;
@@ -281,7 +281,7 @@ lookup_associated_info_by_index (ASSOCIATED_INFO *a, char 
*key, int index)
 }
 
 KEY_PAIR *
-lookup_extra_by_index (ELEMENT *e, char *key, int index)
+lookup_extra_by_index (const ELEMENT *e, char *key, int index)
 {
   return lookup_associated_info_by_index (&e->extra_info, key, index);
 }
diff --git a/tp/Texinfo/XS/main/extra.h b/tp/Texinfo/XS/main/extra.h
index e2d7816392..374d9e4289 100644
--- a/tp/Texinfo/XS/main/extra.h
+++ b/tp/Texinfo/XS/main/extra.h
@@ -31,20 +31,20 @@ void add_extra_integer (ELEMENT *e, char *key, long value);
 void add_info_string (ELEMENT *e, char *key, char *value);
 void add_info_string_dup (ELEMENT *e, char *key, char *value);
 void add_info_element_oot (ELEMENT *e, char *key, ELEMENT *value);
-KEY_PAIR *lookup_extra (ELEMENT *e, char *key);
-KEY_PAIR *lookup_info (ELEMENT *e, char *key);
-ELEMENT *lookup_extra_element (ELEMENT *e, char *key);
-ELEMENT *lookup_info_element (ELEMENT *e, char *key);
+KEY_PAIR *lookup_extra (const ELEMENT *e, char *key);
+KEY_PAIR *lookup_info (const ELEMENT *e, char *key);
+ELEMENT *lookup_extra_element (const ELEMENT *e, char *key);
+ELEMENT *lookup_info_element (const ELEMENT *e, char *key);
 ELEMENT *lookup_extra_contents (ELEMENT *e, char *key, int create);
 ELEMENT *lookup_extra_directions (ELEMENT *e, char *key, int create);
-int lookup_extra_integer (ELEMENT *e, char *key, int *ret);
-char *lookup_extra_string (ELEMENT *e, char *key);
+int lookup_extra_integer (const ELEMENT *e, char *key, int *ret);
+char *lookup_extra_string (const ELEMENT *e, char *key);
 
-KEY_PAIR *lookup_associated_info (ASSOCIATED_INFO *a, char *key);
+KEY_PAIR *lookup_associated_info (const ASSOCIATED_INFO *a, char *key);
 
 /* not to be used in general, only when using associated info
    as a temporary holder of information, for speed */
 void add_associated_info_key (ASSOCIATED_INFO *a, char *key, intptr_t value,
                               enum extra_type type);
-KEY_PAIR *lookup_extra_by_index (ELEMENT *e, char *key, int index);
+KEY_PAIR *lookup_extra_by_index (const ELEMENT *e, char *key, int index);
 #endif
diff --git a/tp/Texinfo/XS/main/utils.c b/tp/Texinfo/XS/main/utils.c
index 3fb0f40fb6..375a8c0b00 100644
--- a/tp/Texinfo/XS/main/utils.c
+++ b/tp/Texinfo/XS/main/utils.c
@@ -485,7 +485,7 @@ item_line_parent (ELEMENT *current)
 }
 
 ELEMENT *
-get_label_element (ELEMENT *e)
+get_label_element (const ELEMENT *e)
 {
   if ((e->cmd == CM_node || e->cmd == CM_anchor)
       && e->args.number > 0)
diff --git a/tp/Texinfo/XS/main/utils.h b/tp/Texinfo/XS/main/utils.h
index be22f1b8e4..8d626ddb01 100644
--- a/tp/Texinfo/XS/main/utils.h
+++ b/tp/Texinfo/XS/main/utils.h
@@ -215,7 +215,7 @@ void delete_global_commands (GLOBAL_COMMANDS 
*global_commands_ref);
 
 char *normalize_encoding_name (const char *text, int *possible_encoding);
 ELEMENT *item_line_parent (ELEMENT *current);
-ELEMENT *get_label_element (ELEMENT *e);
+ELEMENT *get_label_element (const ELEMENT *e);
 INDEX *indices_info_index_by_name (INDEX **indices_information, char *name);
 INDEX *ultimate_index (INDEX *index);
 char *read_flag_name (char **ptr);



reply via email to

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