[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Mon, 13 Nov 2023 16:08:41 -0500 (EST) |
branch: master
commit 5fc252e0f477155ef4edb441def444c9ac6143b9
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Mon Nov 13 18:22:15 2023 +0100
* tp/Texinfo/XS/main/convert_to_text.c (brace_no_arg_command)
(text_heading), tp/Texinfo/XS/main/convert_utils.c
(element_associated_processing_encoding, add_heading_number)
(find_innermost_accent_contents, convert_to_utf8)
(encoded_input_file_name, expand_verbatiminclude)
(definition_arguments_content, definition_category_tree),
tp/Texinfo/XS/main/errors.c (message_list_line_error_internal)
(message_list_command_error), tp/Texinfo/XS/main/tree.c
(insert_list_slice_into_list, insert_slice_into_contents),
tp/Texinfo/XS/main/utils.c (encode_with_iconv, decode_string)
(encode_string, section_level): add const for source info and elements
in argument for function that should not modify the argument they point
to. Not much successful in making sure that the Texinfo tree is not
modified, though.
---
ChangeLog | 17 +++++++++++++++++
tp/Texinfo/XS/main/convert_to_text.c | 4 ++--
tp/Texinfo/XS/main/convert_utils.c | 21 +++++++++++----------
tp/Texinfo/XS/main/convert_utils.h | 8 ++++----
tp/Texinfo/XS/main/errors.c | 4 ++--
tp/Texinfo/XS/main/errors.h | 2 +-
tp/Texinfo/XS/main/tree.c | 4 ++--
tp/Texinfo/XS/main/tree.h | 4 ++--
tp/Texinfo/XS/main/utils.c | 8 ++++----
tp/Texinfo/XS/main/utils.h | 9 +++++----
10 files changed, 50 insertions(+), 31 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 40238bb67f..96b92052c9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,23 @@
* tp/Texinfo/XS:
Run "gnulib-tool --add-import uchar".
+2023-11-13 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/XS/main/convert_to_text.c (brace_no_arg_command)
+ (text_heading), tp/Texinfo/XS/main/convert_utils.c
+ (element_associated_processing_encoding, add_heading_number)
+ (find_innermost_accent_contents, convert_to_utf8)
+ (encoded_input_file_name, expand_verbatiminclude)
+ (definition_arguments_content, definition_category_tree),
+ tp/Texinfo/XS/main/errors.c (message_list_line_error_internal)
+ (message_list_command_error), tp/Texinfo/XS/main/tree.c
+ (insert_list_slice_into_list, insert_slice_into_contents),
+ tp/Texinfo/XS/main/utils.c (encode_with_iconv, decode_string)
+ (encode_string, section_level): add const for source info and elements
+ in argument for function that should not modify the argument they point
+ to. Not much successful in making sure that the Texinfo tree is not
+ modified, though.
+
2023-11-13 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XS/convert/build_html_perl_state.c,
diff --git a/tp/Texinfo/XS/main/convert_to_text.c
b/tp/Texinfo/XS/main/convert_to_text.c
index a0befb329c..d174cd2762 100644
--- a/tp/Texinfo/XS/main/convert_to_text.c
+++ b/tp/Texinfo/XS/main/convert_to_text.c
@@ -204,7 +204,7 @@ text_accents (ELEMENT *accent, char *encoding, int set_case)
/* result to be freed by caller */
char *
-brace_no_arg_command (ELEMENT *e, TEXT_OPTIONS *options)
+brace_no_arg_command (const ELEMENT *e, TEXT_OPTIONS *options)
{
char *result = 0;
enum command_id cmd = e->cmd;
@@ -270,7 +270,7 @@ static const char *underline_symbol[5] = {"*", "*", "=",
"-", "."};
/* Return the text of an underlined heading, possibly indented. */
/* return to be freed by caller */
char *
-text_heading (ELEMENT *current, char *text, OPTIONS *options,
+text_heading (const ELEMENT *current, char *text, OPTIONS *options,
int numbered, int indent_length)
{
int i;
diff --git a/tp/Texinfo/XS/main/convert_utils.c
b/tp/Texinfo/XS/main/convert_utils.c
index e8b8a8f64f..e06804d8e2 100644
--- a/tp/Texinfo/XS/main/convert_utils.c
+++ b/tp/Texinfo/XS/main/convert_utils.c
@@ -45,7 +45,7 @@ char *convert_utils_month_name[12] = {
/* in Texinfo::Common */
char *
-element_associated_processing_encoding (ELEMENT *element)
+element_associated_processing_encoding (const ELEMENT *element)
{
char *input_encoding = lookup_extra_string (element, "input_encoding_name");
return input_encoding;
@@ -62,7 +62,7 @@ find_innermost_accent_contents (ELEMENT *element)
while (1)
{
- ELEMENT *arg;
+ const ELEMENT *arg;
int i;
/* the following can happen if called with a bad tree */
@@ -124,7 +124,7 @@ destroy_accent_stack (ACCENTS_STACK *accent_stack)
*/
/* caller should free return */
char *
-add_heading_number (OPTIONS *options, ELEMENT *current, char *text,
+add_heading_number (OPTIONS *options, const ELEMENT *current, char *text,
int numbered)
{
TEXT result;
@@ -173,7 +173,7 @@ add_heading_number (OPTIONS *options, ELEMENT *current,
char *text,
static char *
convert_to_utf8 (char *s, ENCODING_CONVERSION *conversion,
- SOURCE_INFO *source_info)
+ const SOURCE_INFO *source_info)
{
char *result;
if (!conversion)
@@ -191,7 +191,8 @@ char *
encoded_input_file_name (OPTIONS *options,
GLOBAL_INFO *global_information,
char *file_name, char *input_file_encoding,
- char **file_name_encoding, SOURCE_INFO *source_info)
+ char **file_name_encoding,
+ const SOURCE_INFO *source_info)
{
char *result;
char *encoding = 0;
@@ -251,7 +252,7 @@ encoded_output_file_name (OPTIONS *options, GLOBAL_INFO
*global_information,
ELEMENT *
expand_verbatiminclude (ERROR_MESSAGE_LIST *error_messages,
OPTIONS *options, GLOBAL_INFO *global_information,
- ELEMENT *current)
+ const ELEMENT *current)
{
ELEMENT *verbatiminclude = 0;
char *file_name_encoding;
@@ -361,14 +362,14 @@ expand_verbatiminclude (ERROR_MESSAGE_LIST
*error_messages,
}
PARSED_DEF *
-definition_arguments_content (ELEMENT *element)
+definition_arguments_content (const ELEMENT *element)
{
PARSED_DEF *result = malloc (sizeof (PARSED_DEF));
memset (result, 0, sizeof (PARSED_DEF));
if (element->args.number >= 0)
{
int i;
- ELEMENT *def_line = element->args.list[0];
+ const ELEMENT *def_line = element->args.list[0];
if (def_line->contents.number > 0)
{
for (i = 0; i < def_line->contents.number; i++)
@@ -413,7 +414,7 @@ destroy_parsed_def (PARSED_DEF *parsed_def)
}
ELEMENT *
-definition_category_tree (OPTIONS * options, ELEMENT *current)
+definition_category_tree (OPTIONS * options, const ELEMENT *current)
{
ELEMENT *result = 0;
ELEMENT *arg_category = 0;
@@ -425,7 +426,7 @@ definition_category_tree (OPTIONS * options, ELEMENT
*current)
if (current->args.number >= 0)
{
int i;
- ELEMENT *def_line = current->args.list[0];
+ const ELEMENT *def_line = current->args.list[0];
for (i = 0; i < def_line->contents.number; i++)
{
ELEMENT *arg = def_line->contents.list[i];
diff --git a/tp/Texinfo/XS/main/convert_utils.h
b/tp/Texinfo/XS/main/convert_utils.h
index 0ef03e7d4e..51dbb77c7d 100644
--- a/tp/Texinfo/XS/main/convert_utils.h
+++ b/tp/Texinfo/XS/main/convert_utils.h
@@ -27,16 +27,16 @@ typedef struct PARSED_DEF {
ACCENTS_STACK *find_innermost_accent_contents (ELEMENT *element);
void destroy_accent_stack (ACCENTS_STACK *accent_stack);
-char *add_heading_number (OPTIONS *options, ELEMENT *current, char *text,
+char *add_heading_number (OPTIONS *options, const ELEMENT *current, char *text,
int numbered);
ELEMENT *expand_verbatiminclude (ERROR_MESSAGE_LIST *error_messages,
OPTIONS *options, GLOBAL_INFO *global_information,
- ELEMENT *current);
+ const ELEMENT *current);
-PARSED_DEF *definition_arguments_content (ELEMENT *element);
+PARSED_DEF *definition_arguments_content (const ELEMENT *element);
void destroy_parsed_def (PARSED_DEF *parsed_def);
-ELEMENT *definition_category_tree (OPTIONS *options, ELEMENT *current);
+ELEMENT *definition_category_tree (OPTIONS *options, const ELEMENT *current);
ELEMENT *translated_command_tree (CONVERTER *self, enum command_id cmd);
void destroy_translated_commands (TRANSLATED_COMMAND *translated_commands);
diff --git a/tp/Texinfo/XS/main/errors.c b/tp/Texinfo/XS/main/errors.c
index 7e2b6f2318..30be8cb1a4 100644
--- a/tp/Texinfo/XS/main/errors.c
+++ b/tp/Texinfo/XS/main/errors.c
@@ -62,7 +62,7 @@ reallocate_error_messages (ERROR_MESSAGE_LIST *error_messages)
static void
message_list_line_error_internal (ERROR_MESSAGE_LIST *error_messages,
enum error_type type, int continuation,
- SOURCE_INFO *cmd_source_info,
+ const SOURCE_INFO *cmd_source_info,
char *format, va_list v)
{
char *message;
@@ -287,7 +287,7 @@ command_error (ELEMENT *e, char *format, ...)
void
message_list_command_error (ERROR_MESSAGE_LIST *error_messages,
- ELEMENT *e, char *format, ...)
+ const ELEMENT *e, char *format, ...)
{
va_list v;
diff --git a/tp/Texinfo/XS/main/errors.h b/tp/Texinfo/XS/main/errors.h
index da62eea719..d981f7f866 100644
--- a/tp/Texinfo/XS/main/errors.h
+++ b/tp/Texinfo/XS/main/errors.h
@@ -22,7 +22,7 @@ char *prepare_error_line_message (ERROR_MESSAGE
*error_message);
void wipe_error_message_list (ERROR_MESSAGE_LIST *error_messages);
void clear_error_message_list (ERROR_MESSAGE_LIST *error_messages);
void message_list_command_error (ERROR_MESSAGE_LIST *error_messages,
- ELEMENT *e, char *format, ...);
+ const ELEMENT *e, char *format, ...);
void message_list_command_warn (ERROR_MESSAGE_LIST *error_messages,
ELEMENT *e, char *format, ...);
diff --git a/tp/Texinfo/XS/main/tree.c b/tp/Texinfo/XS/main/tree.c
index 41c8e8c854..b94bb5ea1d 100644
--- a/tp/Texinfo/XS/main/tree.c
+++ b/tp/Texinfo/XS/main/tree.c
@@ -326,7 +326,7 @@ insert_into_args (ELEMENT *parent, ELEMENT *e, int where)
/* Insert elements to TO at position WHERE from FROM from START inclusive
to END exclusive. */
void
-insert_list_slice_into_list (ELEMENT_LIST *to, int where, ELEMENT_LIST *from,
+insert_list_slice_into_list (ELEMENT_LIST *to, int where, const ELEMENT_LIST
*from,
int start, int end)
{
int num = end - start;
@@ -345,7 +345,7 @@ insert_list_slice_into_list (ELEMENT_LIST *to, int where,
ELEMENT_LIST *from,
/* Insert elements to the contents of TO at position WHERE from FROM contents
from START inclusive to END exclusive. Do not set the parent fields. */
void
-insert_slice_into_contents (ELEMENT *to, int where, ELEMENT *from,
+insert_slice_into_contents (ELEMENT *to, int where, const ELEMENT *from,
int start, int end)
{
insert_list_slice_into_list (&to->contents, where, &from->contents,
diff --git a/tp/Texinfo/XS/main/tree.h b/tp/Texinfo/XS/main/tree.h
index 0c3a93edec..a9b6fc231f 100644
--- a/tp/Texinfo/XS/main/tree.h
+++ b/tp/Texinfo/XS/main/tree.h
@@ -18,8 +18,8 @@ void insert_into_contents (ELEMENT *parent, ELEMENT *e, int
where);
void insert_into_args (ELEMENT *parent, ELEMENT *e, int where);
ELEMENT *remove_element_from_list (ELEMENT_LIST *list, ELEMENT *e);
void insert_list_slice_into_list (ELEMENT_LIST *to, int where,
- ELEMENT_LIST *from, int start, int end);
-void insert_slice_into_contents (ELEMENT *to, int idx, ELEMENT *from,
+ const ELEMENT_LIST *from, int start, int
end);
+void insert_slice_into_contents (ELEMENT *to, int idx, const ELEMENT *from,
int start, int end);
void insert_list_slice_into_contents (ELEMENT *to, int idx, ELEMENT_LIST *from,
int start, int end);
diff --git a/tp/Texinfo/XS/main/utils.c b/tp/Texinfo/XS/main/utils.c
index 375a8c0b00..4dc393b305 100644
--- a/tp/Texinfo/XS/main/utils.c
+++ b/tp/Texinfo/XS/main/utils.c
@@ -317,7 +317,7 @@ text_buffer_iconv (TEXT *buf, iconv_t iconv_state,
}
char *
-encode_with_iconv (iconv_t our_iconv, char *s, 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;
@@ -370,7 +370,7 @@ encode_with_iconv (iconv_t our_iconv, char *s, SOURCE_INFO
*source_info)
char *
decode_string (char *input_string, char *encoding, int *status,
- SOURCE_INFO *source_info)
+ const SOURCE_INFO *source_info)
{
char *result;
*status = 0;
@@ -392,7 +392,7 @@ decode_string (char *input_string, char *encoding, int
*status,
char *
encode_string (char *input_string, char *encoding, int *status,
- SOURCE_INFO *source_info)
+ const SOURCE_INFO *source_info)
{
char *result;
*status = 0;
@@ -1070,7 +1070,7 @@ new_options (void)
/* the returned level will be < 0 if the command is not supposed
to be associated to a level. */
int
-section_level (ELEMENT *section)
+section_level (const ELEMENT *section)
{
int level = command_structuring_level[section->cmd];
KEY_PAIR *k_level_modifier = lookup_extra (section, "level_modifier");
diff --git a/tp/Texinfo/XS/main/utils.h b/tp/Texinfo/XS/main/utils.h
index 77b1df555f..3e578ea723 100644
--- a/tp/Texinfo/XS/main/utils.h
+++ b/tp/Texinfo/XS/main/utils.h
@@ -219,7 +219,7 @@ 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);
-int section_level (ELEMENT *section);
+int section_level (const ELEMENT *section);
char *collapse_spaces (char *text);
char *parse_line_directive (char *line, int *retval, int *out_line_no);
int is_content_empty (ELEMENT *tree, int do_not_ignore_index_entries);
@@ -244,12 +244,13 @@ char *locate_include_file (char *filename, STRING_LIST
*include_dirs_list);
ENCODING_CONVERSION *get_encoding_conversion (char *encoding,
ENCODING_CONVERSION_LIST *encodings_list);
-char *encode_with_iconv (iconv_t our_iconv, char *s, SOURCE_INFO
*source_info);
+char *encode_with_iconv (iconv_t our_iconv, char *s,
+ const SOURCE_INFO *source_info);
void reset_encoding_list (ENCODING_CONVERSION_LIST *encodings_list);
char *decode_string (char *input_string, char *encoding, int *status,
- SOURCE_INFO *source_info);
+ const SOURCE_INFO *source_info);
char *encode_string (char *input_string, char *encoding, int *status,
- SOURCE_INFO *source_info);
+ const SOURCE_INFO *source_info);
EXPANDED_FORMAT *new_expanded_formats (void);
void clear_expanded_formats (EXPANDED_FORMAT *formats);