[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/XS/convert/convert_html.c (prepare_i
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/XS/convert/convert_html.c (prepare_index_entries_targets) (convert_printindex_command, html_initialize_output_state) (html_reset_converter), tp/Texinfo/XS/convert/get_html_perl_info.c (find_index_entry_numbers_index_entry_sv), tp/Texinfo/XS/main/IndicesXS.xs (index_entry_element_sort_string), tp/Texinfo/XS/main/build_perl_info.c (build_index_data) (fill_document_hv), tp/Texinfo/XS/main/document.c (document_merged_indices, document_indices_sort_strings) (destroy_document_inform [...] |
Date: |
Sat, 18 May 2024 06:39:54 -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 20d75896be * tp/Texinfo/XS/convert/convert_html.c
(prepare_index_entries_targets) (convert_printindex_command,
html_initialize_output_state) (html_reset_converter),
tp/Texinfo/XS/convert/get_html_perl_info.c
(find_index_entry_numbers_index_entry_sv), tp/Texinfo/XS/main/IndicesXS.xs
(index_entry_element_sort_string), tp/Texinfo/XS/main/build_perl_info.c
(build_index_data) (fill_document_hv), tp/Texinfo/XS/main/document.c
(document_merged_indices, document_indices_sort_strings) (de [...]
20d75896be is described below
commit 20d75896be63ba0bb837482b54f7c1cd51ca7fce
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat May 18 12:39:49 2024 +0200
* tp/Texinfo/XS/convert/convert_html.c (prepare_index_entries_targets)
(convert_printindex_command, html_initialize_output_state)
(html_reset_converter), tp/Texinfo/XS/convert/get_html_perl_info.c
(find_index_entry_numbers_index_entry_sv),
tp/Texinfo/XS/main/IndicesXS.xs (index_entry_element_sort_string),
tp/Texinfo/XS/main/build_perl_info.c (build_index_data)
(fill_document_hv), tp/Texinfo/XS/main/document.c
(document_merged_indices, document_indices_sort_strings)
(destroy_document_information_except_tree),
tp/Texinfo/XS/main/document_types.h (INDEX_LIST),
tp/Texinfo/XS/main/get_perl_info.c (find_index_entry_sv)
(get_sv_index_entries_sorted_by_letter)
(find_document_index_entry_extra_index_entry_sv)
(find_element_extra_index_entry_sv),
tp/Texinfo/XS/main/manipulate_indices.c (merge_indices)
(setup_index_entries_sort_strings), tp/Texinfo/XS/main/utils.c
(indices_info_index_by_name, wipe_index_names),
tp/Texinfo/XS/parsetexi/end_line.c (parse_line_command_args),
tp/Texinfo/XS/parsetexi/indices.c (add_index_internal)
(add_index, init_index_commands, forget_indices)
(resolve_indices_merged_in, complete_indices),
tp/Texinfo/XS/parsetexi/parser.c (parse_texi),
tp/Texinfo/XS/structuring_transfo/StructuringTransfoXS.xs
(relate_index_entries_to_table_items_in_tree),
tp/Texinfo/XS/structuring_transfo/transformations.c
(lookup_index_entry, relate_index_entries_to_table_items_in)
(relate_index_entries_to_table_items_internal)
(relate_index_entries_to_table_items_in_tree): replace the index_names
indices list by indices_info INDEX_LIST structure, with the number of
indices. Pass an indices list as argument to
resolve_indices_merged_in.
---
ChangeLog | 34 +++++++++
tp/Texinfo/XS/convert/convert_html.c | 23 +++---
tp/Texinfo/XS/convert/get_html_perl_info.c | 2 +-
tp/Texinfo/XS/main/IndicesXS.xs | 2 +-
tp/Texinfo/XS/main/build_perl_info.c | 20 +++---
tp/Texinfo/XS/main/build_perl_info.h | 2 +-
tp/Texinfo/XS/main/document.c | 11 +--
tp/Texinfo/XS/main/document_types.h | 7 +-
tp/Texinfo/XS/main/get_perl_info.c | 26 +++----
tp/Texinfo/XS/main/get_perl_info.h | 5 +-
tp/Texinfo/XS/main/manipulate_indices.c | 11 +--
tp/Texinfo/XS/main/manipulate_indices.h | 5 +-
tp/Texinfo/XS/main/utils.c | 31 +++++----
tp/Texinfo/XS/main/utils.h | 4 +-
tp/Texinfo/XS/parsetexi/end_line.c | 6 +-
tp/Texinfo/XS/parsetexi/indices.c | 81 +++++++++-------------
tp/Texinfo/XS/parsetexi/indices.h | 2 +-
tp/Texinfo/XS/parsetexi/parser.c | 8 ++-
.../XS/structuring_transfo/StructuringTransfoXS.xs | 6 +-
.../XS/structuring_transfo/transformations.c | 16 ++---
.../XS/structuring_transfo/transformations.h | 2 +-
21 files changed, 168 insertions(+), 136 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index d7b2b3a4fa..e5293dfb74 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,37 @@
+2024-05-18 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/XS/convert/convert_html.c (prepare_index_entries_targets)
+ (convert_printindex_command, html_initialize_output_state)
+ (html_reset_converter), tp/Texinfo/XS/convert/get_html_perl_info.c
+ (find_index_entry_numbers_index_entry_sv),
+ tp/Texinfo/XS/main/IndicesXS.xs (index_entry_element_sort_string),
+ tp/Texinfo/XS/main/build_perl_info.c (build_index_data)
+ (fill_document_hv), tp/Texinfo/XS/main/document.c
+ (document_merged_indices, document_indices_sort_strings)
+ (destroy_document_information_except_tree),
+ tp/Texinfo/XS/main/document_types.h (INDEX_LIST),
+ tp/Texinfo/XS/main/get_perl_info.c (find_index_entry_sv)
+ (get_sv_index_entries_sorted_by_letter)
+ (find_document_index_entry_extra_index_entry_sv)
+ (find_element_extra_index_entry_sv),
+ tp/Texinfo/XS/main/manipulate_indices.c (merge_indices)
+ (setup_index_entries_sort_strings), tp/Texinfo/XS/main/utils.c
+ (indices_info_index_by_name, wipe_index_names),
+ tp/Texinfo/XS/parsetexi/end_line.c (parse_line_command_args),
+ tp/Texinfo/XS/parsetexi/indices.c (add_index_internal)
+ (add_index, init_index_commands, forget_indices)
+ (resolve_indices_merged_in, complete_indices),
+ tp/Texinfo/XS/parsetexi/parser.c (parse_texi),
+ tp/Texinfo/XS/structuring_transfo/StructuringTransfoXS.xs
+ (relate_index_entries_to_table_items_in_tree),
+ tp/Texinfo/XS/structuring_transfo/transformations.c
+ (lookup_index_entry, relate_index_entries_to_table_items_in)
+ (relate_index_entries_to_table_items_internal)
+ (relate_index_entries_to_table_items_in_tree): replace the index_names
+ indices list by indices_info INDEX_LIST structure, with the number of
+ indices. Pass an indices list as argument to
+ resolve_indices_merged_in.
+
2024-05-18 Patrice Dumas <pertusus@free.fr>
Setup an empty document early instead of storing variables at the end
diff --git a/tp/Texinfo/XS/convert/convert_html.c
b/tp/Texinfo/XS/convert/convert_html.c
index e96446da3b..8bcd7345a8 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -4693,7 +4693,7 @@ compare_index_name (const void *a, const void *b)
void
prepare_index_entries_targets (CONVERTER *self)
{
- if (self->document->index_names)
+ if (self->document->indices_info->number)
{
size_t i;
self->shared_conversion_state.formatted_index_entries
@@ -12771,7 +12771,7 @@ convert_printindex_command (CONVERTER *self, const enum
command_id cmd,
entry_content_element = index_content_element (main_entry_element,
0);
entry_index_nr
= index_number_index_by_name (&self->sorted_index_names,
-
index_entry_ref->index_name);
+ index_entry_ref->index_name);
entry_index = self->sorted_index_names.list[entry_index_nr-1];
/* to avoid double error messages, call convert_tree_new_formatting_context
@@ -16923,26 +16923,27 @@ html_initialize_output_state (CONVERTER *self, const
char *context)
html_new_document_context (self, context, 0, 0);
- if (self->document && self->document->index_names)
+ if (self->document && self->document->indices_info->number)
{
- INDEX **i, *idx;
+ size_t i;
size_t j;
- INDEX **index_names = self->document->index_names;
+ INDEX_LIST *indices_info = self->document->indices_info;
const INDEX **sorted_index_names;
- size_t index_nr = 0;
+ size_t index_nr = indices_info->number;
size_t non_empty_index_nr = 0;
size_t idx_non_empty = 0;
- for (i = index_names; (idx = *i); i++)
+ for (i = 0; i < index_nr; i++)
{
- index_nr++;
+ INDEX *idx = indices_info->list[i];
if (idx->entries_number > 0)
non_empty_index_nr++;
}
sorted_index_names = (const INDEX **) malloc (index_nr * sizeof (INDEX
*));
- memcpy (sorted_index_names, index_names, index_nr * sizeof (INDEX *));
+ memcpy (sorted_index_names, indices_info->list,
+ index_nr * sizeof (INDEX *));
qsort (sorted_index_names, index_nr, sizeof (INDEX *),
compare_index_name);
@@ -17082,7 +17083,7 @@ html_reset_converter (CONVERTER *self)
free (self->shared_conversion_state.formatted_listoffloats_nr);
self->shared_conversion_state.formatted_listoffloats_nr = 0;
- if (self->document->index_names)
+ if (self->document->indices_info->number)
{
for (i = 0; i < self->sorted_index_names.number; i++)
{
@@ -17092,7 +17093,7 @@ html_reset_converter (CONVERTER *self)
}
free (self->sorted_index_names.list);
- memset (&self->sorted_index_names, 0, sizeof (SORTED_INDEX_NAMES));
+ memset (&self->sorted_index_names, 0, sizeof (INDEX_LIST));
free (self->special_units_direction_name);
self->special_units_direction_name = 0;
diff --git a/tp/Texinfo/XS/convert/get_html_perl_info.c
b/tp/Texinfo/XS/convert/get_html_perl_info.c
index 97f9c730d7..eee3b1b3b6 100644
--- a/tp/Texinfo/XS/convert/get_html_perl_info.c
+++ b/tp/Texinfo/XS/convert/get_html_perl_info.c
@@ -1364,7 +1364,7 @@ find_index_entry_numbers_index_entry_sv (CONVERTER
*converter,
dTHX;
- if (!converter->document->index_names)
+ if (!converter->document->indices_info->number)
return 0;
index_entry_hv = (HV *) SvRV (index_entry_sv);
diff --git a/tp/Texinfo/XS/main/IndicesXS.xs b/tp/Texinfo/XS/main/IndicesXS.xs
index c34ef0ac5f..1851de96ad 100644
--- a/tp/Texinfo/XS/main/IndicesXS.xs
+++ b/tp/Texinfo/XS/main/IndicesXS.xs
@@ -121,7 +121,7 @@ index_entry_element_sort_string (SV *customization_info_sv,
SV *main_entry_sv, S
const ELEMENT *element = find_element_from_sv (0, document,
element_sv, 0);
INDEX_ENTRY *main_entry = find_index_entry_sv (main_entry_sv,
- document->index_names, 0,
+ document->indices_info, 0,
&entry_idx, &entry_number);
in_code = entry_idx->in_code;
diff --git a/tp/Texinfo/XS/main/build_perl_info.c
b/tp/Texinfo/XS/main/build_perl_info.c
index 021f6ce48e..ffd0e62280 100644
--- a/tp/Texinfo/XS/main/build_perl_info.c
+++ b/tp/Texinfo/XS/main/build_perl_info.c
@@ -933,23 +933,21 @@ build_single_index_data (INDEX *index)
build_texinfo_tree must be called before this so all the 'hv' fields
are set on the elements in the tree. */
HV *
-build_index_data (INDEX **index_names_in)
+build_index_data (INDEX_LIST *indices_info)
{
+ size_t i;
HV *hv;
- INDEX **i, *idx;
dTHX;
hv = newHV ();
- if (index_names_in)
+ for (i = 0; i < indices_info->number; i++)
{
- for (i = index_names_in; (idx = *i); i++)
- {
- HV *hv2 = build_single_index_data (idx);
- hv_store (hv, idx->name, strlen (idx->name),
- newRV_noinc ((SV *)hv2), 0);
- }
+ INDEX *idx = indices_info->list[i];
+ HV *hv2 = build_single_index_data (idx);
+ hv_store (hv, idx->name, strlen (idx->name),
+ newRV_noinc ((SV *)hv2), 0);
}
return hv;
@@ -1435,7 +1433,7 @@ fill_document_hv (HV *hv, size_t document_descriptor, int
no_store)
hv_commands_info = build_global_commands (document->global_commands);
- hv_index_names = build_index_data (document->index_names);
+ hv_index_names = build_index_data (document->indices_info);
/* NOTE there is also a document->listoffloats which structure
is more like the hv_listoffloats_list, so it could be
@@ -1634,7 +1632,7 @@ funcname (SV *document_in) \
BUILD_PERL_DOCUMENT_ITEM(funcname,fieldname,keyname,flagname,buildname,HVAV)
*/
-BUILD_PERL_DOCUMENT_ITEM(document_indices_information,index_names,"indices",F_DOCM_index_names,build_index_data,HV)
+BUILD_PERL_DOCUMENT_ITEM(document_indices_information,indices_info,"indices",F_DOCM_index_names,build_index_data,HV)
BUILD_PERL_DOCUMENT_ITEM(document_global_commands_information,global_commands,"commands_info",F_DOCM_global_commands,build_global_commands,HV)
diff --git a/tp/Texinfo/XS/main/build_perl_info.h
b/tp/Texinfo/XS/main/build_perl_info.h
index 5810daf1b5..0d67b45cdf 100644
--- a/tp/Texinfo/XS/main/build_perl_info.h
+++ b/tp/Texinfo/XS/main/build_perl_info.h
@@ -43,7 +43,7 @@ HV* build_identifiers_target (LABEL_LIST *identifiers_target);
AV *build_internal_xref_list (ELEMENT **internal_xref_list,
size_t internal_xref_number);
HV *build_float_list (FLOAT_RECORD *floats_list, size_t floats_number);
-HV *build_index_data (INDEX **index_names_in);
+HV *build_index_data (INDEX_LIST *indices_info);
HV *build_global_info (GLOBAL_INFO *global_info_ref,
GLOBAL_COMMANDS *global_commands_ref);
void build_global_info_tree_info (HV *hv, GLOBAL_INFO *global_info_ref);
diff --git a/tp/Texinfo/XS/main/document.c b/tp/Texinfo/XS/main/document.c
index 3a74b91ac3..7f3afe56ad 100644
--- a/tp/Texinfo/XS/main/document.c
+++ b/tp/Texinfo/XS/main/document.c
@@ -99,6 +99,8 @@ new_document (void)
memset (document->floats, 0, sizeof (FLOAT_RECORD_LIST));
document->internal_references = malloc (sizeof (ELEMENT_LIST));
memset (document->internal_references, 0, sizeof (ELEMENT_LIST));
+ document->indices_info = malloc (sizeof (INDEX_LIST));
+ memset (document->indices_info, 0, sizeof (INDEX_LIST));
/* For filenames and macro names, it is possible that they won't be
referenced
in the line number of any element. It would be too much work to keep track,
so just keep them all here, and free them all together at the end. */
@@ -147,11 +149,12 @@ register_document_options (DOCUMENT *document, OPTIONS
*options)
const MERGED_INDICES *
document_merged_indices (DOCUMENT *document)
{
- if (document->index_names)
+ if (document->indices_info->number)
{
if (!document->merged_indices)
{
- document->merged_indices = merge_indices (document->index_names);
+ document->merged_indices
+ = merge_indices (document->indices_info);
document->modified_information |= F_DOCM_merged_indices;
}
}
@@ -180,7 +183,7 @@ document_indices_sort_strings (DOCUMENT *document,
document->indices_sort_strings
= setup_index_entries_sort_strings (error_messages, options,
- merged_indices, document->index_names, 0);
+ merged_indices, document->indices_info, 0);
document->modified_information |= F_DOCM_indices_sort_strings;
}
@@ -427,7 +430,7 @@ destroy_document_information_except_tree (DOCUMENT
*document)
free (document->labels_list);
free (document->identifiers_target->list);
free (document->identifiers_target);
- wipe_index_names (document->index_names);
+ wipe_index_names (document->indices_info);
wipe_error_message_list (document->error_messages);
free (document->error_messages);
wipe_error_message_list (document->parser_error_messages);
diff --git a/tp/Texinfo/XS/main/document_types.h
b/tp/Texinfo/XS/main/document_types.h
index c74bbe100c..10ea7aecc9 100644
--- a/tp/Texinfo/XS/main/document_types.h
+++ b/tp/Texinfo/XS/main/document_types.h
@@ -78,6 +78,11 @@ typedef struct GLOBAL_INFO {
char *input_perl_encoding;
} GLOBAL_INFO;
+typedef struct INDEX_LIST {
+ size_t number;
+ INDEX **list;
+} INDEX_LIST;
+
typedef struct MERGED_INDEX {
char *name;
INDEX_ENTRY *index_entries;
@@ -172,7 +177,7 @@ typedef struct COLLATIONS_INDICES_SORTED_BY_LETTER {
typedef struct DOCUMENT {
int descriptor;
ELEMENT *tree;
- INDEX **index_names;
+ INDEX_LIST *indices_info;
MERGED_INDICES *merged_indices;
FLOAT_RECORD_LIST *floats;
LISTOFFLOATS_TYPE_LIST *listoffloats;
diff --git a/tp/Texinfo/XS/main/get_perl_info.c
b/tp/Texinfo/XS/main/get_perl_info.c
index 804fbcb5c3..314d76d671 100644
--- a/tp/Texinfo/XS/main/get_perl_info.c
+++ b/tp/Texinfo/XS/main/get_perl_info.c
@@ -637,7 +637,7 @@ reset_output_init_conf (SV *sv_in)
}
INDEX_ENTRY *
-find_index_entry_sv (const SV *index_entry_sv, INDEX **index_names,
+find_index_entry_sv (const SV *index_entry_sv, INDEX_LIST *indices_info,
const char *warn_string, const INDEX **entry_idx,
int *entry_number)
{
@@ -669,8 +669,7 @@ find_index_entry_sv (const SV *index_entry_sv, INDEX
**index_names,
*entry_number = SvIV (*entry_number_sv);
entry_idx_in_index = *entry_number - 1;
- idx = indices_info_index_by_name (index_names,
- entry_index_name);
+ idx = indices_info_index_by_name (indices_info, entry_index_name);
*entry_idx = idx;
if (idx)
{
@@ -688,7 +687,7 @@ find_index_entry_sv (const SV *index_entry_sv, INDEX
**index_names,
/* return value to be freed by caller */
/* Currently not used */
INDEX_SORTED_BY_LETTER *
-get_sv_index_entries_sorted_by_letter (INDEX **index_names,
+get_sv_index_entries_sorted_by_letter (INDEX_LIST *indices_info,
SV *index_entries_sorted_by_letter)
{
INDEX_SORTED_BY_LETTER *indices_entries_by_letter;
@@ -855,16 +854,17 @@ get_sv_index_entries_sorted_by_letter (INDEX
**index_names,
{
char *msg;
xasprintf (&msg,
- "get_sv_index_entries_sorted_by_letter: %s: %d: %s: %d: no entry\n",
+ "get_sv_index_entries_sorted_by_letter: %s: %d: %s: %d: no entry\n",
idx_name, i, letter_entries->letter, k);
fatal (msg);
}
non_perl_xasprintf (&warn_string,
- "get_sv_index_entries_sorted_by_letter: %s: %d: %s:
%d",
+ "get_sv_index_entries_sorted_by_letter: %s: %d: %s: %d",
idx_name, i, letter_entries->letter, k);
- index_entry = find_index_entry_sv (*index_entry_sv,
index_names,
- warn_string, &entry_idx,
- &entry_number);
+ index_entry
+ = find_index_entry_sv (*index_entry_sv, indices_info,
+ warn_string, &entry_idx,
+ &entry_number);
non_perl_free (warn_string);
letter_entries->entries[k] = index_entry;
@@ -1271,10 +1271,11 @@ find_document_index_entry_extra_index_entry_sv (const
DOCUMENT *document,
SV **index_name_sv;
char *index_name = 0;
const INDEX *idx = 0;
+ INDEX_LIST *indices_info = document->indices_info;
dTHX;
- if (!document->index_names)
+ if (!indices_info->number)
return 0;
extra_index_entry_av = (AV *) SvRV (extra_index_entry_sv);
@@ -1283,8 +1284,7 @@ find_document_index_entry_extra_index_entry_sv (const
DOCUMENT *document,
if (index_name_sv)
{
index_name = SvPVutf8_nolen (*index_name_sv);
- idx = indices_info_index_by_name (document->index_names,
- index_name);
+ idx = indices_info_index_by_name (indices_info, index_name);
}
if (idx)
@@ -1309,7 +1309,7 @@ find_element_extra_index_entry_sv (const DOCUMENT
*document,
const SV *extra_index_entry_sv)
{
const INDEX_ENTRY *index_entry;
- if (!converter || !converter->document || !converter->document->index_names)
+ if (!converter || !converter->document || !converter->document->indices_info)
{
if (document)
index_entry
diff --git a/tp/Texinfo/XS/main/get_perl_info.h
b/tp/Texinfo/XS/main/get_perl_info.h
index 775b7f1d23..d71bb119e1 100644
--- a/tp/Texinfo/XS/main/get_perl_info.h
+++ b/tp/Texinfo/XS/main/get_perl_info.h
@@ -44,12 +44,13 @@ int converter_initialize (SV *converter_sv);
void reset_output_init_conf (SV *sv_in);
void converter_set_document (SV *converter_in, SV *document_in);
-INDEX_ENTRY *find_index_entry_sv (const SV *index_entry_sv, INDEX
**index_names,
+INDEX_ENTRY *find_index_entry_sv (const SV *index_entry_sv,
+ INDEX_LIST *indices_info,
const char *warn_string, const INDEX **entry_idx,
int *entry_number);
INDEX_SORTED_BY_LETTER *get_sv_index_entries_sorted_by_letter
- (INDEX **index_names, SV *index_entries_sorted_by_letter);
+ (INDEX_LIST *indices_info, SV
*index_entries_sorted_by_letter);
TEXT_OPTIONS *copy_sv_options_for_convert_text (SV *sv_in);
diff --git a/tp/Texinfo/XS/main/manipulate_indices.c
b/tp/Texinfo/XS/main/manipulate_indices.c
index b6dd6a84dd..3918c1ee8f 100644
--- a/tp/Texinfo/XS/main/manipulate_indices.c
+++ b/tp/Texinfo/XS/main/manipulate_indices.c
@@ -40,13 +40,13 @@
/* corresponding perl code in Texinfo::Indices */
MERGED_INDICES *
-merge_indices (INDEX **index_names)
+merge_indices (INDEX_LIST *indices_information)
{
size_t merged_indices_space = 4;
size_t merged_indices_number = 0;
- INDEX **i, *idx;
+ size_t i;
- if (!index_names)
+ if (!indices_information->number)
return 0;
MERGED_INDEX *merged_indices_list
@@ -55,8 +55,9 @@ merge_indices (INDEX **index_names)
MERGED_INDICES *merged_indices
= (MERGED_INDICES *) malloc (sizeof (MERGED_INDICES));
- for (i = index_names; (idx = *i); i++)
+ for (i = 0; i < indices_information->number; i++)
{
+ INDEX *idx = indices_information->list[i];
if (idx->index_entries && idx->entries_number)
{
size_t j;
@@ -366,7 +367,7 @@ destroy_index_entries_sort_strings (INDICES_SORT_STRINGS
*indices_sort_strings)
INDICES_SORT_STRINGS *
setup_index_entries_sort_strings (ERROR_MESSAGE_LIST *error_messages,
OPTIONS *options, const MERGED_INDICES *merged_indices,
- INDEX **indices_information, int prefer_reference_element)
+ INDEX_LIST *indices_information, int
prefer_reference_element)
{
size_t i;
TEXT_OPTIONS *convert_text_options;
diff --git a/tp/Texinfo/XS/main/manipulate_indices.h
b/tp/Texinfo/XS/main/manipulate_indices.h
index ffe4fa4895..fe58e50873 100644
--- a/tp/Texinfo/XS/main/manipulate_indices.h
+++ b/tp/Texinfo/XS/main/manipulate_indices.h
@@ -37,7 +37,7 @@ typedef struct INDEX_ENTRY_TEXT_OR_COMMAND {
ELEMENT *command;
} INDEX_ENTRY_TEXT_OR_COMMAND;
-MERGED_INDICES *merge_indices (INDEX **index_names);
+MERGED_INDICES *merge_indices (INDEX_LIST *indices_information);
void destroy_merged_indices (MERGED_INDICES *merged_indices);
void destroy_indices_sorted_by_index (
@@ -57,7 +57,8 @@ void destroy_index_entries_sort_strings (
INDICES_SORT_STRINGS *setup_index_entries_sort_strings (
ERROR_MESSAGE_LIST *error_messages,
OPTIONS *options, const MERGED_INDICES *merged_indices,
- INDEX **indices_information, int prefer_reference_element);
+ INDEX_LIST *indices_information,
+ int prefer_reference_element);
INDEX_SORTED_BY_INDEX *sort_indices_by_index (
DOCUMENT *document, ERROR_MESSAGE_LIST *error_messages,
diff --git a/tp/Texinfo/XS/main/utils.c b/tp/Texinfo/XS/main/utils.c
index 7a99b8eaa3..d0d6377061 100644
--- a/tp/Texinfo/XS/main/utils.c
+++ b/tp/Texinfo/XS/main/utils.c
@@ -647,14 +647,17 @@ get_label_element (const ELEMENT *e)
/* index related code used both in parsing and conversion */
/* NAME is the name of an index, e.g. "cp" */
INDEX *
-indices_info_index_by_name (INDEX **indices_information, const char *name)
+indices_info_index_by_name (const INDEX_LIST *indices_information,
+ const char *name)
{
- INDEX **i;
- INDEX *idx;
+ size_t i;
- for (i = indices_information; (idx = *i); i++)
- if (!strcmp (idx->name, name))
- return idx;
+ for (i = 0; i < indices_information->number; i++)
+ {
+ INDEX *idx = indices_information->list[i];
+ if (!strcmp (idx->name, name))
+ return idx;
+ }
return 0;
}
@@ -850,18 +853,16 @@ wipe_index (INDEX *idx)
}
void
-wipe_index_names (INDEX **index_names)
+wipe_index_names (INDEX_LIST *indices_information)
{
- INDEX **i, *idx;
- if (index_names)
+ size_t i;
+ for (i = 0; i < indices_information->number; i++)
{
- for (i = index_names; (idx = *i); i++)
- {
- wipe_index (idx);
- free (idx);
- }
+ INDEX *idx = indices_information->list[i];
+ wipe_index (idx);
+ free (idx);
}
- free (index_names);
+ free (indices_information);
}
diff --git a/tp/Texinfo/XS/main/utils.h b/tp/Texinfo/XS/main/utils.h
index 6271ca07ea..7256b744f7 100644
--- a/tp/Texinfo/XS/main/utils.h
+++ b/tp/Texinfo/XS/main/utils.h
@@ -179,7 +179,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 (const ELEMENT *e);
-INDEX *indices_info_index_by_name (INDEX **indices_information,
+INDEX *indices_info_index_by_name (const INDEX_LIST *indices_information,
const char *name);
INDEX *ultimate_index (INDEX *index);
size_t index_number_index_by_name (const SORTED_INDEX_NAMES *sorted_indices,
@@ -204,7 +204,7 @@ size_t find_string (const STRING_LIST *strings_list, const
char *string);
void destroy_accent_stack (ACCENTS_STACK *accent_stack);
void wipe_index (INDEX *idx);
-void wipe_index_names (INDEX **index_names);
+void wipe_index_names (INDEX_LIST *indices_information);
/* in options_init_free.c */
void initialize_options (OPTIONS *options);
diff --git a/tp/Texinfo/XS/parsetexi/end_line.c
b/tp/Texinfo/XS/parsetexi/end_line.c
index 9d29674807..3e0e88880b 100644
--- a/tp/Texinfo/XS/parsetexi/end_line.c
+++ b/tp/Texinfo/XS/parsetexi/end_line.c
@@ -408,9 +408,9 @@ parse_line_command_args (ELEMENT *line_command)
break;
}
- from_index = indices_info_index_by_name (parsed_document->index_names,
+ from_index = indices_info_index_by_name (parsed_document->indices_info,
index_name_from);
- to_index = indices_info_index_by_name (parsed_document->index_names,
+ to_index = indices_info_index_by_name (parsed_document->indices_info,
index_name_to);
if (!from_index)
line_error ("unknown source index in @%s: %s",
@@ -462,7 +462,7 @@ parse_line_command_args (ELEMENT *line_command)
else
{
INDEX *idx
- = indices_info_index_by_name (parsed_document->index_names, arg);
+ = indices_info_index_by_name (parsed_document->indices_info, arg);
if (!idx)
line_error ("unknown index `%s' in @printindex", arg);
else
diff --git a/tp/Texinfo/XS/parsetexi/indices.c
b/tp/Texinfo/XS/parsetexi/indices.c
index b2275ea404..0d4899c68f 100644
--- a/tp/Texinfo/XS/parsetexi/indices.c
+++ b/tp/Texinfo/XS/parsetexi/indices.c
@@ -41,7 +41,6 @@
#include "parser.h"
#include "indices.h"
-int number_of_indices = 0;
int space_for_indices = 0;
typedef struct {
@@ -100,21 +99,24 @@ add_index_command (char *cmdname, INDEX *idx)
static INDEX *
add_index_internal (char *name, int in_code)
{
- INDEX *idx = malloc (sizeof (INDEX));
+ INDEX_LIST *indices = parsed_document->indices_info;
+ INDEX *idx = (INDEX *) malloc (sizeof (INDEX));
- memset (idx, 0, sizeof *idx);
+ memset (idx, 0, sizeof (INDEX));
idx->name = name;
idx->prefix = name;
idx->in_code = in_code;
- if (number_of_indices == space_for_indices)
+
+ if (indices->number == space_for_indices)
{
space_for_indices += 5;
- parsed_document->index_names
- = realloc (parsed_document->index_names, (space_for_indices + 1)
- * sizeof (INDEX *));
+ indices->list
+ = realloc (indices->list, space_for_indices * sizeof (INDEX *));
}
- parsed_document->index_names[number_of_indices++] = idx;
- parsed_document->index_names[number_of_indices] = 0;
+
+ indices->list[indices->number] = idx;
+ indices->number++;
+
return idx;
}
@@ -124,7 +126,8 @@ add_index_internal (char *name, int in_code)
void
add_index (const char *name, int in_code)
{
- INDEX *idx = indices_info_index_by_name (parsed_document->index_names, name);
+ INDEX *idx
+ = indices_info_index_by_name (parsed_document->indices_info, name);
char *cmdname;
if (!idx)
@@ -140,7 +143,7 @@ void
init_index_commands (void)
{
INDEX *idx;
- INDEX **index_names;
+ INDEX_LIST *indices;
struct def { char *name; int in_code;
enum command_id cmd2; enum command_id cmd1;}
@@ -193,21 +196,6 @@ init_index_commands (void)
};
#undef X
- /* number_of_indices and num_index_commands
- * should already be reset to 0 by forget_indices
-
- if (number_of_indices != 0)
- {
- fprintf (stderr, "BUG: init_index_commands: number_of_indices != 0\n");
- number_of_indices = 0;
- }
- if (num_index_commands != 0)
- {
- fprintf (stderr, "BUG: init_index_commands: num_index_commands != 0\n");
- num_index_commands = 0;
- }
- */
-
for (p = default_indices; p->name; p++)
{
idx = add_index_internal (strdup (p->name), p->in_code);
@@ -217,19 +205,19 @@ init_index_commands (void)
associate_command_to_index (p->cmd1, idx);
}
/* set the variable now that the realloc have been done */
- index_names = parsed_document->index_names;
+ indices = parsed_document->indices_info;
associate_command_to_index (CM_vtable,
- indices_info_index_by_name (index_names, "vr"));
+ indices_info_index_by_name (indices, "vr"));
associate_command_to_index (CM_ftable,
- indices_info_index_by_name (index_names, "fn"));
+ indices_info_index_by_name (indices, "fn"));
for (i = 0;
i < sizeof (def_command_indices) / sizeof (def_command_indices[0]);
i++)
{
enum command_id cmd;
- idx = indices_info_index_by_name (index_names,
+ idx = indices_info_index_by_name (indices,
def_command_indices[i].name);
if (idx)
{
@@ -357,26 +345,22 @@ set_non_ignored_space_in_index_before_command (ELEMENT
*content)
void
forget_indices (void)
{
- number_of_indices = 0;
space_for_indices = 0;
num_index_commands = 0;
}
void
-resolve_indices_merged_in (void)
+resolve_indices_merged_in (INDEX_LIST *indices_info)
{
- INDEX **i, *idx;
-
- if (parsed_document->index_names)
+ size_t i;
+ for (i = 0; i < indices_info->number; i++)
{
- for (i = parsed_document->index_names; (idx = *i); i++)
+ INDEX *idx = indices_info->list[i];
+ if (idx->merged_in)
{
- if (idx->merged_in)
- {
- /* This index is merged in another one. */
- INDEX *ultimate = ultimate_index (idx);
- idx->merged_in = ultimate;
- }
+ /* This index is merged in another one. */
+ INDEX *ultimate = ultimate_index (idx);
+ idx->merged_in = ultimate;
}
}
}
@@ -387,22 +371,19 @@ resolve_indices_merged_in (void)
void
complete_indices (int document_descriptor, int debug_level)
{
- INDEX **i, *idx;
DOCUMENT *document;
- INDEX **index_names;
+ INDEX_LIST *indices;
+ size_t i;
/* beware that document may have a change in adress if realloc on
the documents list is called in gdt. So only use it here and
not after gdt call */
document = retrieve_document (document_descriptor);
+ indices = document->indices_info;
- if (!document->index_names)
- return;
-
- index_names = document->index_names;
-
- for (i = index_names; (idx = *i); i++)
+ for (i = 0; i < indices->number; i++)
{
+ INDEX *idx = indices->list[i];
if (idx->entries_number > 0)
{
int j;
diff --git a/tp/Texinfo/XS/parsetexi/indices.h
b/tp/Texinfo/XS/parsetexi/indices.h
index f557f2aeea..fc579c7195 100644
--- a/tp/Texinfo/XS/parsetexi/indices.h
+++ b/tp/Texinfo/XS/parsetexi/indices.h
@@ -14,7 +14,7 @@ void set_non_ignored_space_in_index_before_command (ELEMENT
*content);
void forget_indices (void);
-void resolve_indices_merged_in (void);
+void resolve_indices_merged_in (INDEX_LIST *indices_info);
void complete_indices (int document_descriptor, int debug_level);
#endif
diff --git a/tp/Texinfo/XS/parsetexi/parser.c b/tp/Texinfo/XS/parsetexi/parser.c
index cece03ec68..eae59a8d4a 100644
--- a/tp/Texinfo/XS/parsetexi/parser.c
+++ b/tp/Texinfo/XS/parsetexi/parser.c
@@ -570,6 +570,12 @@ parse_texi_document (void)
document_descriptor = parse_texi (document_root, before_node_section);
+ /* TODO the document information often use more memory than needed,
+ when space > number. We could realloc here the diverse structures
+ to number. No need to do it in parse_texi, it should only be
+ truely interesting for a whole document.
+ */
+
rearrange_tree_beginning (before_node_section, document_descriptor);
return document_descriptor;
@@ -2654,7 +2660,7 @@ parse_texi (ELEMENT *root_elt, ELEMENT *current_elt)
/* update merged_in. Only needed for merging happening after first
index merge */
- resolve_indices_merged_in ();
+ resolve_indices_merged_in (parsed_document->indices_info);
parsed_document->identifiers_target
= set_labels_identifiers_target (parsed_document->labels_list->list,
diff --git a/tp/Texinfo/XS/structuring_transfo/StructuringTransfoXS.xs
b/tp/Texinfo/XS/structuring_transfo/StructuringTransfoXS.xs
index 2f1f1dc2a3..195ae4565e 100644
--- a/tp/Texinfo/XS/structuring_transfo/StructuringTransfoXS.xs
+++ b/tp/Texinfo/XS/structuring_transfo/StructuringTransfoXS.xs
@@ -114,15 +114,15 @@ relate_index_entries_to_table_items_in_tree (SV
*document_in)
"relate_index_entries_to_table_items_in_tree");
if (document)
{
- if (!document->index_names)
+ if (!document->indices_info)
{
- fprintf (stderr, "ERROR: %d: no index_names\n",
+ fprintf (stderr, "ERROR: %d: no indices_info\n",
document->descriptor);
}
else
{
relate_index_entries_to_table_items_in_tree (document->tree,
- document->index_names);
+ document->indices_info);
document->modified_information |= F_DOCM_tree
| F_DOCM_index_names;
}
diff --git a/tp/Texinfo/XS/structuring_transfo/transformations.c
b/tp/Texinfo/XS/structuring_transfo/transformations.c
index 58ac1f8cc5..064ab7baef 100644
--- a/tp/Texinfo/XS/structuring_transfo/transformations.c
+++ b/tp/Texinfo/XS/structuring_transfo/transformations.c
@@ -50,7 +50,7 @@
/* in Common.pm */
INDEX_ENTRY_AND_INDEX *
-lookup_index_entry (ELEMENT *index_entry_info, INDEX **indices_information)
+lookup_index_entry (ELEMENT *index_entry_info, INDEX_LIST *indices_info)
{
INDEX_ENTRY_AND_INDEX *result = 0;
int status;
@@ -60,7 +60,7 @@ lookup_index_entry (ELEMENT *index_entry_info, INDEX
**indices_information)
char *entry_index_name = index_entry_info->contents.list[0]->text.text;
INDEX *index_info;
- index_info = indices_info_index_by_name (indices_information,
+ index_info = indices_info_index_by_name (indices_info,
entry_index_name);
if (!index_info)
return 0;
@@ -315,7 +315,7 @@ fill_gaps_in_sectioning (ELEMENT *root, ELEMENT
*commands_heading_content)
void
relate_index_entries_to_table_items_in (ELEMENT *table,
- INDEX **indices_information)
+ INDEX_LIST *indices_info)
{
int i;
@@ -385,7 +385,7 @@ relate_index_entries_to_table_items_in (ELEMENT *table,
ELEMENT *index_entry_info = lookup_extra_element
(content,
"index_entry");
idx_info = lookup_index_entry (index_entry_info,
- indices_information);
+ indices_info);
if (idx_info->index_entry)
entry_idx_info = idx_info;
else
@@ -431,18 +431,18 @@ relate_index_entries_to_table_items_internal (const char
*type,
{
if (current->cmd && current->cmd == CM_table)
{
- INDEX **indices_information = (INDEX **)argument;
- relate_index_entries_to_table_items_in (current, indices_information);
+ INDEX_LIST *indices_info = (INDEX_LIST *)argument;
+ relate_index_entries_to_table_items_in (current, indices_info);
}
return 0;
}
void
relate_index_entries_to_table_items_in_tree (ELEMENT *tree,
- INDEX **indices_information)
+ INDEX_LIST *indices_info)
{
modify_tree (tree, &relate_index_entries_to_table_items_internal,
- indices_information);
+ indices_info);
}
void
diff --git a/tp/Texinfo/XS/structuring_transfo/transformations.h
b/tp/Texinfo/XS/structuring_transfo/transformations.h
index 384faf25cd..5b056b7be9 100644
--- a/tp/Texinfo/XS/structuring_transfo/transformations.h
+++ b/tp/Texinfo/XS/structuring_transfo/transformations.h
@@ -8,7 +8,7 @@
ELEMENT_LIST *fill_gaps_in_sectioning (ELEMENT *root,
ELEMENT *commands_heading_content);
void relate_index_entries_to_table_items_in_tree (ELEMENT *tree,
- INDEX **indices_information);
+ INDEX_LIST *indices_info);
void move_index_entries_after_items_in_tree (ELEMENT *tree);
ELEMENT *reference_to_arg_in_tree (ELEMENT *tree, DOCUMENT *document);
void complete_tree_nodes_menus (const ELEMENT *root, int use_sections);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/XS/convert/convert_html.c (prepare_index_entries_targets) (convert_printindex_command, html_initialize_output_state) (html_reset_converter), tp/Texinfo/XS/convert/get_html_perl_info.c (find_index_entry_numbers_index_entry_sv), tp/Texinfo/XS/main/IndicesXS.xs (index_entry_element_sort_string), tp/Texinfo/XS/main/build_perl_info.c (build_index_data) (fill_document_hv), tp/Texinfo/XS/main/document.c (document_merged_indices, document_indices_sort_strings) (destroy_document_inform [...],
Patrice Dumas <=