[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/XS/main/document.c (unregister_docum
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/XS/main/document.c (unregister_document_merge_with_document): simplify code. |
Date: |
Sat, 18 May 2024 13:25:23 -0400 |
This is an automated email from the git hooks/post-receive script.
pertusus pushed a commit to branch master
in repository texinfo.
The following commit(s) were added to refs/heads/master by this push:
new 0481daf2e4 * tp/Texinfo/XS/main/document.c
(unregister_document_merge_with_document): simplify code.
0481daf2e4 is described below
commit 0481daf2e4f7b352ecce4e56deec6943a89f0343
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat May 18 19:25:26 2024 +0200
* tp/Texinfo/XS/main/document.c
(unregister_document_merge_with_document): simplify code.
* tp/Texinfo/XS/main/targets.c (set_labels_identifiers_target): pass a
LABEL_LIST. Update callers.
* tp/Texinfo/XS/main/DocumentXS.xs (document_errors),
tp/Texinfo/XS/main/build_perl_info.c (add_formatted_error_messages)
(pass_errors_to_registrar): call clear_error_message_list out of code
building Perl as far as possible.
* tp/Texinfo/XS/main/build_perl_info.c, tp/Texinfo/XS/main/targets.c,
tp/maintain/regenerate_C_options_info.pl: add const.
---
ChangeLog | 16 ++++
tp/Texinfo/XS/main/DocumentXS.xs | 3 +
tp/Texinfo/XS/main/build_perl_info.c | 144 ++++++++++++++++---------------
tp/Texinfo/XS/main/build_perl_info.h | 18 ++--
tp/Texinfo/XS/main/document.c | 25 +++---
tp/Texinfo/XS/main/targets.c | 25 ++----
tp/Texinfo/XS/main/targets.h | 2 +-
tp/Texinfo/XS/main/tree_types.h | 1 +
tp/Texinfo/XS/parsetexi/parser.c | 3 +-
tp/maintain/regenerate_C_options_info.pl | 3 +-
10 files changed, 129 insertions(+), 111 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 1cf5658bc4..3971895cc3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2024-05-18 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/XS/main/document.c
+ (unregister_document_merge_with_document): simplify code.
+
+ * tp/Texinfo/XS/main/targets.c (set_labels_identifiers_target): pass a
+ LABEL_LIST. Update callers.
+
+ * tp/Texinfo/XS/main/DocumentXS.xs (document_errors),
+ tp/Texinfo/XS/main/build_perl_info.c (add_formatted_error_messages)
+ (pass_errors_to_registrar): call clear_error_message_list out of code
+ building Perl as far as possible.
+
+ * tp/Texinfo/XS/main/build_perl_info.c, tp/Texinfo/XS/main/targets.c,
+ tp/maintain/regenerate_C_options_info.pl: add const.
+
2024-05-18 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XS/main/DocumentXS.xs (set_document_global_info): fix
diff --git a/tp/Texinfo/XS/main/DocumentXS.xs b/tp/Texinfo/XS/main/DocumentXS.xs
index 970ec0eeae..73e6d2c2ae 100644
--- a/tp/Texinfo/XS/main/DocumentXS.xs
+++ b/tp/Texinfo/XS/main/DocumentXS.xs
@@ -31,6 +31,8 @@
#include "extra.h"
/* for non_perl_* */
#include "utils.h"
+/* for clear_error_message_list */
+#include "errors.h"
#include "document.h"
#include "translations.h"
#include "get_perl_info.h"
@@ -119,6 +121,7 @@ document_errors (SV *document_in)
pass_errors_to_registrar (error_messages, document_in,
&errors_warnings_sv,
&error_nrs_sv);
+ clear_error_message_list (error_messages);
if (!errors_warnings_sv)
errors_warnings_sv = newSV (0);
diff --git a/tp/Texinfo/XS/main/build_perl_info.c
b/tp/Texinfo/XS/main/build_perl_info.c
index 4fd50315f3..03d33d3789 100644
--- a/tp/Texinfo/XS/main/build_perl_info.c
+++ b/tp/Texinfo/XS/main/build_perl_info.c
@@ -155,7 +155,7 @@ void element_to_perl_hash (ELEMENT *e, int avoid_recursion);
information where build_perl_array is called.
*/
static SV *
-build_perl_array (ELEMENT_LIST *e, int avoid_recursion)
+build_perl_array (const ELEMENT_LIST *e, int avoid_recursion)
{
SV *sv;
AV *av;
@@ -302,10 +302,9 @@ build_additional_info (HV *extra, const ASSOCIATED_INFO *a,
for (i = 0; i < a->info_number; i++)
{
- KEY_PAIR *k = &a->info[i];
+ const KEY_PAIR *k = &a->info[i];
#define STORE(sv) hv_store (extra, key, strlen (key), sv, 0)
const char *key = k->key;
- ELEMENT *f = k->element;
if (k->type == extra_deleted)
continue;
@@ -314,6 +313,7 @@ build_additional_info (HV *extra, const ASSOCIATED_INFO *a,
switch (k->type)
{
case extra_element:
+ {
/* For references to other parts of the tree, create the hash so
we can point to it. */
/* Note that this does not happen much, as the contents
@@ -321,11 +321,14 @@ build_additional_info (HV *extra, const ASSOCIATED_INFO
*a,
happens for root commands (sections, nodes) and associated
commands, and could also happen for subentry as it is not
a children of the associated index command */
+ ELEMENT *f = k->element;
if (!f->hv)
f->hv = newHV ();
STORE(newRV_inc ((SV *)f->hv));
break;
+ }
case extra_element_oot:
+ {
/* Note that this is only used for info hash in the parser, with
simple elements that are associated to one element only,
should
not be referred to elsewhere (and should not contain other
@@ -349,17 +352,22 @@ build_additional_info (HV *extra, const ASSOCIATED_INFO
*a,
fprintf (stderr, message.text);
}
*/
+ ELEMENT *f = k->element;
if (!f->hv || !avoid_recursion)
element_to_perl_hash (f, avoid_recursion);
STORE(newRV_inc ((SV *)f->hv));
break;
+ }
case extra_container:
+ {
+ ELEMENT *f = k->element;
build_perl_container (f, avoid_recursion);
STORE(newRV_inc ((SV *)f->hv));
break;
+ }
case extra_contents:
{
- ELEMENT_LIST *l = k->list;
+ const ELEMENT_LIST *l = k->list;
if (l && l->number)
STORE(build_perl_array (l, avoid_recursion));
break;
@@ -371,7 +379,7 @@ build_additional_info (HV *extra, const ASSOCIATED_INFO *a,
}
case extra_string:
{ /* A simple string. */
- char *value = k->string;
+ const char *value = k->string;
STORE(newSVpv_utf8 (value, 0));
break;
}
@@ -385,16 +393,16 @@ build_additional_info (HV *extra, const ASSOCIATED_INFO
*a,
}
case extra_misc_args:
{
- int j;
- AV *av;
- av = newAV ();
+ size_t j;
+ const ELEMENT *f = k->element;
+ AV *av = newAV ();
av_unshift (av, f->contents.number);
STORE(newRV_inc ((SV *)av));
/* An array of strings or integers. */
for (j = 0; j < f->contents.number; j++)
{
- KEY_PAIR *k_integer;
+ const KEY_PAIR *k_integer;
k_integer = lookup_extra (f->contents.list[j], "integer");
if (k_integer)
{
@@ -425,8 +433,8 @@ build_additional_info (HV *extra, const ASSOCIATED_INFO *a,
}
static void
-store_additional_info (const ELEMENT *e, ASSOCIATED_INFO *a, char *key,
- int avoid_recursion)
+store_additional_info (const ELEMENT *e, const ASSOCIATED_INFO *a,
+ const char *key, int avoid_recursion)
{
int nr_info;
HV *additional_info_hv;
@@ -446,7 +454,7 @@ store_additional_info (const ELEMENT *e, ASSOCIATED_INFO
*a, char *key,
}
static void
-store_source_mark_list (ELEMENT *e)
+store_source_mark_list (const ELEMENT *e)
{
dTHX;
@@ -463,7 +471,7 @@ store_source_mark_list (ELEMENT *e)
{
HV *source_mark;
SV *sv;
- SOURCE_MARK *s_mark = e->source_mark_list.list[i];
+ const SOURCE_MARK *s_mark = e->source_mark_list.list[i];
IV source_mark_position;
IV source_mark_counter;
source_mark = newHV ();
@@ -480,14 +488,14 @@ store_source_mark_list (ELEMENT *e)
}
if (s_mark->element)
{
- ELEMENT *e = s_mark->element;
+ ELEMENT *s_m_e = s_mark->element;
/* should only be referred to in one source mark */
/* but can be reused when tree is rebuilt
if (e->hv)
fatal ("element_to_perl_hash source mark elt twice");
*/
- element_to_perl_hash (e, 0);
- STORE("element", newRV_inc ((SV *)e->hv));
+ element_to_perl_hash (s_m_e, 0);
+ STORE("element", newRV_inc ((SV *)s_m_e->hv));
}
if (s_mark->line)
{
@@ -695,7 +703,7 @@ element_to_perl_hash (ELEMENT *e, int avoid_recursion)
if (e->source_info.line_nr)
{
#define STORE(key, sv, hsh) hv_store (hv, key, strlen (key), sv, hsh)
- SOURCE_INFO *source_info = &e->source_info;
+ const SOURCE_INFO *source_info = &e->source_info;
HV *hv = newHV ();
hv_store (e->hv, "source_info", strlen ("source_info"),
newRV_noinc ((SV *)hv), HSH_source_info);
@@ -1023,7 +1031,7 @@ build_global_info (const GLOBAL_INFO *global_info_ref,
if (global_commands.setfilename)
{
- char *setfilename_text
+ const char *setfilename_text
= informative_command_value (global_commands.setfilename);
if (setfilename_text)
hv_store (hv, "setfilename", strlen ("setfilename"),
@@ -1034,7 +1042,7 @@ build_global_info (const GLOBAL_INFO *global_info_ref,
CM_documentlanguage, CL_preamble);
if (document_language)
{
- char *language = informative_command_value (document_language);
+ const char *language = informative_command_value (document_language);
hv_store (hv, "documentlanguage", strlen ("documentlanguage"),
newSVpv (language, 0), 0);
}
@@ -1045,13 +1053,12 @@ build_global_info (const GLOBAL_INFO *global_info_ref,
/* Return object to be used as 'commands_info', which holds references
to tree elements. */
HV *
-build_global_commands (GLOBAL_COMMANDS *global_commands_ref)
+build_global_commands (const GLOBAL_COMMANDS *global_commands_ref)
{
HV *hv;
AV *av;
int i;
- ELEMENT *e;
- GLOBAL_COMMANDS global_commands = *global_commands_ref;
+ const GLOBAL_COMMANDS global_commands = *global_commands_ref;
dTHX;
@@ -1080,7 +1087,7 @@ build_global_commands (GLOBAL_COMMANDS
*global_commands_ref)
newRV_noinc ((SV *) av), 0);
for (i = 0; i < global_commands.dircategory_direntry.number; i++)
{
- e = global_commands.dircategory_direntry.list[i];
+ const ELEMENT *e = global_commands.dircategory_direntry.list[i];
if (e->hv)
av_push (av, newRV_inc ((SV *) e->hv));
}
@@ -1095,7 +1102,7 @@ build_global_commands (GLOBAL_COMMANDS
*global_commands_ref)
newRV_noinc ((SV *) av), 0);
for (i = 0; i < global_commands.footnotes.number; i++)
{
- e = global_commands.footnotes.list[i];
+ const ELEMENT *e = global_commands.footnotes.list[i];
if (e->hv)
av_push (av, newRV_inc ((SV *) e->hv));
}
@@ -1109,7 +1116,7 @@ build_global_commands (GLOBAL_COMMANDS
*global_commands_ref)
newRV_noinc ((SV *) av), 0);
for (i = 0; i < global_commands.floats.number; i++)
{
- e = global_commands.floats.list[i];
+ const ELEMENT *e = global_commands.floats.list[i];
if (e->hv)
av_push (av, newRV_inc ((SV *) e->hv));
}
@@ -1123,7 +1130,7 @@ build_global_commands (GLOBAL_COMMANDS
*global_commands_ref)
newRV_noinc ((SV *) av), 0); \
for (i = 0; i < global_commands.cmd.number; i++) \
{ \
- e = global_commands.cmd.list[i]; \
+ const ELEMENT *e = global_commands.cmd.list[i]; \
if (e->hv) \
av_push (av, newRV_inc ((SV *) e->hv)); \
} \
@@ -1141,7 +1148,7 @@ build_global_commands (GLOBAL_COMMANDS
*global_commands_ref)
static void
-build_source_info_hash (SOURCE_INFO source_info, HV *hv)
+build_source_info_hash (const SOURCE_INFO source_info, HV *hv)
{
dTHX;
@@ -1167,7 +1174,7 @@ build_source_info_hash (SOURCE_INFO source_info, HV *hv)
/* build perl already 'formatted' message, same as the output of
Texinfo::Report::format*message */
static SV *
-convert_error (ERROR_MESSAGE e)
+convert_error (const ERROR_MESSAGE e)
{
HV *hv;
SV *msg;
@@ -1200,7 +1207,7 @@ convert_error (ERROR_MESSAGE e)
/* Errors */
AV *
-build_errors (ERROR_MESSAGE *error_list, size_t error_number)
+build_errors (const ERROR_MESSAGE *error_list, size_t error_number)
{
AV *av;
int i;
@@ -1229,7 +1236,7 @@ build_errors (ERROR_MESSAGE *error_list, size_t
error_number)
is interested in those SV.
*/
static void
-add_formatted_error_messages (ERROR_MESSAGE_LIST *error_messages,
+add_formatted_error_messages (const ERROR_MESSAGE_LIST *error_messages,
HV *report_hv, SV **errors_warnings_out,
SV **error_nrs_out)
{
@@ -1280,7 +1287,7 @@ add_formatted_error_messages (ERROR_MESSAGE_LIST
*error_messages,
for (i = 0; i < error_messages->number; i++)
{
- ERROR_MESSAGE error_msg = error_messages->list[i];
+ const ERROR_MESSAGE error_msg = error_messages->list[i];
SV *sv = convert_error (error_msg);
if (error_msg.type == MSG_error && !error_msg.continuation)
@@ -1310,14 +1317,13 @@ add_formatted_error_messages (ERROR_MESSAGE_LIST
*error_messages,
it is likely that the error messages are going to disappear */
fprintf (stderr, "BUG? no 'errors_warnings'. Not a Perl
Texinfo::Report?\n");
}
-
- clear_error_message_list (error_messages);
}
/* ERROR_MESSAGES can be 0, in that case the function is used to get
the perl references but they are not modified */
SV *
-pass_errors_to_registrar (ERROR_MESSAGE_LIST *error_messages, SV *object_sv,
+pass_errors_to_registrar (const ERROR_MESSAGE_LIST *error_messages,
+ SV *object_sv,
SV **errors_warnings_out, SV **error_nrs_out)
{
HV *object_hv;
@@ -1359,6 +1365,7 @@ pass_document_parser_errors_to_registrar (int
document_descriptor,
pass_errors_to_registrar (document->parser_error_messages, parser_sv,
&errors_warnings_sv, &error_nrs_sv);
+ clear_error_message_list (document->parser_error_messages);
}
@@ -2027,7 +2034,7 @@ rebuild_output_units_list (SV *output_units_sv, size_t
output_units_descriptor)
SV *
-get_conf (CONVERTER *converter, const char *option_name)
+get_conf (const CONVERTER *converter, const char *option_name)
{
dTHX;
@@ -2055,7 +2062,7 @@ build_integer_stack (const INTEGER_STACK *integer_stack)
}
SV *
-build_filenames (FILE_NAME_PATH_COUNTER_LIST *output_unit_files)
+build_filenames (const FILE_NAME_PATH_COUNTER_LIST *output_unit_files)
{
int i;
HV *hv;
@@ -2068,9 +2075,10 @@ build_filenames (FILE_NAME_PATH_COUNTER_LIST
*output_unit_files)
{
for (i = 0; i < output_unit_files->number; i++)
{
- FILE_NAME_PATH_COUNTER *output_unit_file
+ const FILE_NAME_PATH_COUNTER *output_unit_file
= &output_unit_files->list[i];
- char *normalized_filename = output_unit_file->normalized_filename;
+ const char *normalized_filename
+ = output_unit_file->normalized_filename;
SV *normalized_filename_sv = newSVpv_utf8 (normalized_filename, 0);
hv_store_ent (hv, normalized_filename_sv,
@@ -2082,7 +2090,7 @@ build_filenames (FILE_NAME_PATH_COUNTER_LIST
*output_unit_files)
}
SV *
-build_file_counters (FILE_NAME_PATH_COUNTER_LIST *output_unit_files)
+build_file_counters (const FILE_NAME_PATH_COUNTER_LIST *output_unit_files)
{
int i;
HV *hv;
@@ -2095,9 +2103,9 @@ build_file_counters (FILE_NAME_PATH_COUNTER_LIST
*output_unit_files)
{
for (i = 0; i < output_unit_files->number; i++)
{
- FILE_NAME_PATH_COUNTER *output_unit_file
+ const FILE_NAME_PATH_COUNTER *output_unit_file
= &output_unit_files->list[i];
- char *filename = output_unit_file->filename;
+ const char *filename = output_unit_file->filename;
SV *filename_sv = newSVpv_utf8 (filename, 0);
hv_store_ent (hv, filename_sv, newSViv (output_unit_file->counter),
0);
@@ -2108,7 +2116,7 @@ build_file_counters (FILE_NAME_PATH_COUNTER_LIST
*output_unit_files)
}
SV *
-build_out_filepaths (FILE_NAME_PATH_COUNTER_LIST *output_unit_files)
+build_out_filepaths (const FILE_NAME_PATH_COUNTER_LIST *output_unit_files)
{
int i;
HV *hv;
@@ -2121,9 +2129,9 @@ build_out_filepaths (FILE_NAME_PATH_COUNTER_LIST
*output_unit_files)
{
for (i = 0; i < output_unit_files->number; i++)
{
- FILE_NAME_PATH_COUNTER *output_unit_file
+ const FILE_NAME_PATH_COUNTER *output_unit_file
= &output_unit_files->list[i];
- char *filename = output_unit_file->filename;
+ const char *filename = output_unit_file->filename;
SV *filename_sv = newSVpv_utf8 (filename, 0);
hv_store_ent (hv, filename_sv,
@@ -2136,7 +2144,7 @@ build_out_filepaths (FILE_NAME_PATH_COUNTER_LIST
*output_unit_files)
void
pass_output_unit_files (SV *converter_sv,
- FILE_NAME_PATH_COUNTER_LIST *output_unit_files)
+ const FILE_NAME_PATH_COUNTER_LIST *output_unit_files)
{
SV *filenames_sv;
SV *file_counters_sv;
@@ -2162,12 +2170,12 @@ pass_output_unit_files (SV *converter_sv,
/* Texinfo::Common output_files_information API */
void
build_output_files_unclosed_files (HV *hv,
- OUTPUT_FILES_INFORMATION *output_files_information)
+ const OUTPUT_FILES_INFORMATION *output_files_information)
{
SV **unclosed_files_sv;
HV *unclosed_files_hv;
- FILE_STREAM_LIST *unclosed_files;
+ const FILE_STREAM_LIST *unclosed_files;
int i;
dTHX;
@@ -2191,8 +2199,8 @@ build_output_files_unclosed_files (HV *hv,
{
for (i = 0; i < unclosed_files->number; i++)
{
- FILE_STREAM *file_stream = &unclosed_files->list[i];
- char *file_path = file_stream->file_path;
+ const FILE_STREAM *file_stream = &unclosed_files->list[i];
+ const char *file_path = file_stream->file_path;
/* It is not possible to associate the unclosed stream to a SV.
It is possible to obtain a PerlIO from a FILE, as described in
https://perldoc.perl.org/perlapio
@@ -2225,12 +2233,12 @@ build_output_files_unclosed_files (HV *hv,
$converter->{'output_files'} = Texinfo::Common::output_files_initialize(); */
void
build_output_files_opened_files (HV *hv,
- OUTPUT_FILES_INFORMATION *output_files_information)
+ const OUTPUT_FILES_INFORMATION *output_files_information)
{
SV **opened_files_sv;
HV *opened_files_hv;
- STRING_LIST *opened_files;
+ const STRING_LIST *opened_files;
int i;
dTHX;
@@ -2253,7 +2261,7 @@ build_output_files_opened_files (HV *hv,
{
for (i = 0; i < opened_files->number; i++)
{
- char *file_path = opened_files->list[i];
+ const char *file_path = opened_files->list[i];
SV *file_path_sv = newSVpv_byte (file_path, 0);
hv_store_ent (opened_files_hv, file_path_sv, newSViv (1), 0);
}
@@ -2262,7 +2270,7 @@ build_output_files_opened_files (HV *hv,
void
build_output_files_information (SV *converter_sv,
- OUTPUT_FILES_INFORMATION *output_files_information)
+ const OUTPUT_FILES_INFORMATION *output_files_information)
{
HV *hv;
SV **output_files_sv;
@@ -2294,7 +2302,7 @@ build_output_files_information (SV *converter_sv,
/* not used for now */
SV *
-build_expanded_formats (EXPANDED_FORMAT *expanded_formats)
+build_expanded_formats (const EXPANDED_FORMAT *expanded_formats)
{
int i;
HV *expanded_hv;
@@ -2306,7 +2314,7 @@ build_expanded_formats (EXPANDED_FORMAT *expanded_formats)
{
if (expanded_formats[i].expandedp)
{
- char *format = expanded_formats[i].format;
+ const char *format = expanded_formats[i].format;
hv_store (expanded_hv, format, strlen (format),
newSViv (1), 0);
}
@@ -2377,9 +2385,9 @@ build_indices_sort_strings (const INDICES_SORT_STRINGS
*indices_sort_strings,
for (i = 0; i < indices_sort_strings->number; i++)
{
- INDEX_SORT_STRINGS *index_sort_strings
+ const INDEX_SORT_STRINGS *index_sort_strings
= &indices_sort_strings->indices[i];
- char *index_name = index_sort_strings->index->name;
+ const char *index_name = index_sort_strings->index->name;
if (index_sort_strings->entries_number > 0)
{
@@ -2391,10 +2399,10 @@ build_indices_sort_strings (const INDICES_SORT_STRINGS
*indices_sort_strings,
for (j = 0; j < index_sort_strings->entries_number; j++)
{
- INDEX_ENTRY_SORT_STRING *index_entry_sort_string
+ const INDEX_ENTRY_SORT_STRING *index_entry_sort_string
= &index_sort_strings->sort_string_entries[j];
- INDEX_ENTRY *entry = index_entry_sort_string->entry;
- char *entry_index_name = entry->index_name;
+ const INDEX_ENTRY *entry = index_entry_sort_string->entry;
+ const char *entry_index_name = entry->index_name;
int entry_number = entry->number;
char *message;
SV *index_entry_sv;
@@ -2442,7 +2450,7 @@ build_indices_sort_strings (const INDICES_SORT_STRINGS
*indices_sort_strings,
for (k = 0; k < index_entry_sort_string->subentries_number; k++)
{
- INDEX_SUBENTRY_SORT_STRING *subentry_sort_string
+ const INDEX_SUBENTRY_SORT_STRING *subentry_sort_string
= &index_entry_sort_string->sort_string_subentries[k];
HV *subentry_sort_string_hv = newHV ();
@@ -2487,8 +2495,8 @@ build_sorted_indices_by_index (
for (j = 0; j < idx->entries_number; j++)
{
- INDEX_ENTRY *entry = idx->entries[j];
- char *index_name = entry->index_name;
+ const INDEX_ENTRY *entry = idx->entries[j];
+ const char *index_name = entry->index_name;
int entry_number = entry->number;
char *message;
SV *index_entry_sv;
@@ -2544,7 +2552,7 @@ build_sorted_indices_by_letter (
size_t j;
HV *letter_hv = newHV ();
AV *entries_av = newAV ();
- LETTER_INDEX_ENTRIES *letter = &idx->letter_entries[i];
+ const LETTER_INDEX_ENTRIES *letter = &idx->letter_entries[i];
hv_store (letter_hv, "letter", strlen ("letter"),
newSVpv_utf8 (letter->letter, 0), 0);
@@ -2556,8 +2564,8 @@ build_sorted_indices_by_letter (
for (j = 0; j < letter->entries_number; j++)
{
- INDEX_ENTRY *entry = letter->entries[j];
- char *index_name = entry->index_name;
+ const INDEX_ENTRY *entry = letter->entries[j];
+ const char *index_name = entry->index_name;
int entry_number = entry->number;
char *message;
SV *index_entry_sv;
@@ -2582,8 +2590,8 @@ build_sorted_indices_by_letter (
}
SV *
-html_build_direction_icons (CONVERTER *converter,
- DIRECTION_ICON_LIST *direction_icons)
+html_build_direction_icons (const CONVERTER *converter,
+ const DIRECTION_ICON_LIST *direction_icons)
{
HV *icons_hv;
int i;
diff --git a/tp/Texinfo/XS/main/build_perl_info.h
b/tp/Texinfo/XS/main/build_perl_info.h
index 3c95cb3646..efec6a6efb 100644
--- a/tp/Texinfo/XS/main/build_perl_info.h
+++ b/tp/Texinfo/XS/main/build_perl_info.h
@@ -22,7 +22,8 @@ char *perl_only_strndup (const char *s, size_t n);
int init (int texinfo_uninstalled, char *srcdir_in);
/* in options_get_perl.c */
-SV *build_sv_option (OPTIONS *options, const char *key, CONVERTER *converter);
+SV *build_sv_option (const OPTIONS *options, const char *key,
+ const CONVERTER *converter);
/* does not exist as perl macro */
SV *newSVpv_utf8 (const char *str, STRLEN len);
@@ -36,10 +37,9 @@ void rebuild_document (SV *document_in, int no_store);
HV *build_texinfo_tree (ELEMENT *root, int avoid_recursion);
SV *store_texinfo_tree (DOCUMENT *document, HV *document_hv);
-AV *build_errors (ERROR_MESSAGE* error_list, size_t error_number);
+AV *build_errors (const ERROR_MESSAGE* error_list, size_t error_number);
HV *build_float_list (FLOAT_RECORD *floats_list, size_t floats_number);
void build_global_info_tree_info (HV *hv, GLOBAL_INFO *global_info_ref);
-HV *build_global_commands (GLOBAL_COMMANDS *global_commands_ref);
SV *document_indices_information (SV *document_in);
SV *document_global_commands_information (SV *document_in);
@@ -55,7 +55,7 @@ SV *document_global_information (SV *document_in);
void pass_document_parser_errors_to_registrar (int document_descriptor,
SV *parser_sv);
-SV *pass_errors_to_registrar (ERROR_MESSAGE_LIST *error_messages,
+SV *pass_errors_to_registrar (const ERROR_MESSAGE_LIST *error_messages,
SV *object_sv,
SV **errors_warnings_out, SV **error_nrs_out);
@@ -68,10 +68,10 @@ AV *build_integer_stack (const INTEGER_STACK
*integer_stack);
AV *build_string_list (const STRING_LIST *strings_list, enum sv_string_type);
void pass_output_unit_files (SV *converter_sv,
- FILE_NAME_PATH_COUNTER_LIST *output_unit_files);
+ const FILE_NAME_PATH_COUNTER_LIST *output_unit_files);
void build_output_files_information (SV *converter_sv,
- OUTPUT_FILES_INFORMATION *output_files_information);
+ const OUTPUT_FILES_INFORMATION *output_files_information);
HV *build_indices_sort_strings (
const INDICES_SORT_STRINGS *indices_sort_strings,
@@ -83,9 +83,9 @@ HV *build_sorted_indices_by_index (
const INDEX_SORTED_BY_INDEX *index_entries_by_index,
HV *indices_information_hv);
-SV *html_build_direction_icons (CONVERTER *converter,
- DIRECTION_ICON_LIST *direction_icons);
-SV *get_conf (CONVERTER *converter, const char *option_name);
+SV *html_build_direction_icons (const CONVERTER *converter,
+ const DIRECTION_ICON_LIST *direction_icons);
+SV *get_conf (const CONVERTER *converter, const char *option_name);
void build_tree_to_build (ELEMENT_LIST *tree_to_build);
diff --git a/tp/Texinfo/XS/main/document.c b/tp/Texinfo/XS/main/document.c
index 9777b63ddd..823c603687 100644
--- a/tp/Texinfo/XS/main/document.c
+++ b/tp/Texinfo/XS/main/document.c
@@ -515,22 +515,19 @@ unregister_document_merge_with_document (int
document_descriptor,
fprintf (stderr, "UNREGISTER %p\n", removed_document);
*/
- if (removed_document->small_strings)
+ if (removed_document->small_strings->number)
{
- if (removed_document->small_strings->number)
- {
- if (document)
- merge_strings (document->small_strings,
- removed_document->small_strings);
- else
- fatal ("unregister_document_merge_with_document "
- "no document but small_strings");
- }
- free (removed_document->small_strings->list);
- free (removed_document->small_strings);
-
- removed_document->small_strings = 0;
+ if (document)
+ merge_strings (document->small_strings,
+ removed_document->small_strings);
+ else
+ fatal ("unregister_document_merge_with_document "
+ "no document but small_strings");
}
+ free (removed_document->small_strings->list);
+ free (removed_document->small_strings);
+
+ removed_document->small_strings = 0;
return tree;
}
diff --git a/tp/Texinfo/XS/main/targets.c b/tp/Texinfo/XS/main/targets.c
index 2e0a190636..cb4dfab662 100644
--- a/tp/Texinfo/XS/main/targets.c
+++ b/tp/Texinfo/XS/main/targets.c
@@ -92,27 +92,19 @@ compare_labels (const void *a, const void *b)
*/
}
-/*
-some_fun (LABEL_LIST *labels_list)
-{
- LABEL *list_of_labels = labels_list->list;
- set_labels_identifiers_target (list_of_labels, labels_list->number);
-}
- */
-
/* fill a LABEL_LIST that is sorted with unique identifiers such that
elements are easy to find.
Called from parser */
void
-set_labels_identifiers_target (LABEL *list_of_labels, size_t labels_number,
+set_labels_identifiers_target (const LABEL_LIST *labels,
LABEL_LIST *result)
{
+ size_t labels_number = labels->number;
LABEL *targets = malloc (labels_number * sizeof (LABEL));
size_t targets_number = labels_number;
-
size_t i;
- memcpy (targets, list_of_labels, labels_number * sizeof (LABEL));
+ memcpy (targets, labels->list, labels_number * sizeof (LABEL));
qsort (targets, labels_number, sizeof (LABEL), compare_labels);
i = 0;
@@ -133,7 +125,7 @@ set_labels_identifiers_target (LABEL *list_of_labels,
size_t labels_number,
while (j < targets_number - 1 && targets[j+1].identifier
&& !strcmp (targets[i].identifier, targets[j+1].identifier))
{
- list_of_labels[targets[j+1].label_number].reference
+ labels->list[targets[j+1].label_number].reference
= targets[i].element;
j++;
}
@@ -173,8 +165,9 @@ set_labels_identifiers_target (LABEL *list_of_labels,
size_t labels_number,
result->space = labels_number;
}
-LABEL *
-sort_labels_identifiers_target (LABEL *list_of_labels, size_t labels_number)
+static LABEL *
+sort_labels_identifiers_target (const LABEL *list_of_labels,
+ size_t labels_number)
{
LABEL *targets = malloc (labels_number * sizeof (LABEL));
@@ -230,8 +223,8 @@ add_element_to_identifiers_target (DOCUMENT *document,
ELEMENT *element,
free (identifiers_target->list);
identifiers_target->list = sorted_identifiers_target;
/* knowing that space is the same as number requires looking at
- sort_labels_identifiers_target to know the space
- allocated for sorted_identifiers_target in that function */
+ sort_labels_identifiers_target to figure out the total space
+ allocated for sorted_identifiers_target */
identifiers_target->space = identifiers_target->number;
*status = 0;
document->modified_information |= F_DOCM_labels_list
diff --git a/tp/Texinfo/XS/main/targets.h b/tp/Texinfo/XS/main/targets.h
index bcb1e77da7..180ea5a938 100644
--- a/tp/Texinfo/XS/main/targets.h
+++ b/tp/Texinfo/XS/main/targets.h
@@ -12,7 +12,7 @@ ELEMENT *find_identifier_target (const LABEL_LIST
*identifiers_target,
int register_label_element (int document_descriptor, ELEMENT *element,
ERROR_MESSAGE_LIST *error_messages);
-void set_labels_identifiers_target (LABEL *list_of_labels, size_t
labels_number,
+void set_labels_identifiers_target (const LABEL_LIST *labels,
LABEL_LIST *result);
#endif
diff --git a/tp/Texinfo/XS/main/tree_types.h b/tp/Texinfo/XS/main/tree_types.h
index 77481da2bf..c619b135f1 100644
--- a/tp/Texinfo/XS/main/tree_types.h
+++ b/tp/Texinfo/XS/main/tree_types.h
@@ -275,6 +275,7 @@ typedef struct {
typedef struct {
size_t label_number;
const char *identifier;
+ /* cannot be const because is_target is added */
ELEMENT *element;
/* for label that is a duplicate, points to the element used in links */
const ELEMENT *reference;
diff --git a/tp/Texinfo/XS/parsetexi/parser.c b/tp/Texinfo/XS/parsetexi/parser.c
index 248352a5d1..ea7299de19 100644
--- a/tp/Texinfo/XS/parsetexi/parser.c
+++ b/tp/Texinfo/XS/parsetexi/parser.c
@@ -2662,8 +2662,7 @@ parse_texi (ELEMENT *root_elt, ELEMENT *current_elt)
index merge */
resolve_indices_merged_in (&parsed_document->indices_info);
- set_labels_identifiers_target (parsed_document->labels_list.list,
- parsed_document->labels_list.number,
+ set_labels_identifiers_target (&parsed_document->labels_list,
&parsed_document->identifiers_target);
parsed_document->tree = current;
diff --git a/tp/maintain/regenerate_C_options_info.pl
b/tp/maintain/regenerate_C_options_info.pl
index ee5c5b6519..06a471608f 100755
--- a/tp/maintain/regenerate_C_options_info.pl
+++ b/tp/maintain/regenerate_C_options_info.pl
@@ -366,7 +366,8 @@ print GET '}
';
print GET 'SV *
-build_sv_option (OPTIONS *options, const char *key, CONVERTER *converter)
+build_sv_option (const OPTIONS *options, const char *key,
+ const CONVERTER *converter)
{
dTHX;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/XS/main/document.c (unregister_document_merge_with_document): simplify code.,
Patrice Dumas <=