[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Sat, 18 May 2024 15:28:27 -0400 (EDT) |
branch: master
commit 72fd6e40ebba04c161ab0fef5c36c7296235c8ee
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat May 18 20:00:09 2024 +0200
* tp/Texinfo/XS/main/document.c (new_document),
tp/Texinfo/XS/main/document_types.h (DOCUMENT),
tp/Texinfo/XS/convert/convert_html.c,
tp/Texinfo/XS/main/DocumentXS.xs,
tp/Texinfo/XS/main/build_perl_info.c,
tp/Texinfo/XS/main/convert_to_text.c, tp/Texinfo/XS/main/utils.c,
tp/Texinfo/XS/parsetexi/api.c,
tp/Texinfo/XS/parsetexi/handle_commands.c,
tp/Texinfo/XS/parsetexi/indices.c, tp/Texinfo/XS/parsetexi/input.c,
tp/Texinfo/XS/parsetexi/macro.c, tp/Texinfo/XS/parsetexi/separator.c:
put global_info directly in DOCUMENT, not as a pointer.
---
ChangeLog | 14 ++++++++++++++
tp/Texinfo/XS/convert/convert_html.c | 12 ++++++------
tp/Texinfo/XS/main/DocumentXS.xs | 14 +++++++-------
tp/Texinfo/XS/main/build_perl_info.c | 12 +++++++++---
tp/Texinfo/XS/main/convert_to_text.c | 2 +-
tp/Texinfo/XS/main/document.c | 8 +-------
tp/Texinfo/XS/main/document_types.h | 4 +++-
tp/Texinfo/XS/main/utils.c | 5 ++---
tp/Texinfo/XS/parsetexi/api.c | 2 +-
tp/Texinfo/XS/parsetexi/end_line.c | 6 +++---
tp/Texinfo/XS/parsetexi/handle_commands.c | 11 ++++++-----
tp/Texinfo/XS/parsetexi/indices.c | 11 ++++++-----
tp/Texinfo/XS/parsetexi/input.c | 4 ++--
tp/Texinfo/XS/parsetexi/macro.c | 22 ++++++++++++----------
tp/Texinfo/XS/parsetexi/separator.c | 2 +-
15 files changed, 74 insertions(+), 55 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 3971895cc3..a466839024 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2024-05-18 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/XS/main/document.c (new_document),
+ tp/Texinfo/XS/main/document_types.h (DOCUMENT),
+ tp/Texinfo/XS/convert/convert_html.c,
+ tp/Texinfo/XS/main/DocumentXS.xs,
+ tp/Texinfo/XS/main/build_perl_info.c,
+ tp/Texinfo/XS/main/convert_to_text.c, tp/Texinfo/XS/main/utils.c,
+ tp/Texinfo/XS/parsetexi/api.c,
+ tp/Texinfo/XS/parsetexi/handle_commands.c,
+ tp/Texinfo/XS/parsetexi/indices.c, tp/Texinfo/XS/parsetexi/input.c,
+ tp/Texinfo/XS/parsetexi/macro.c, tp/Texinfo/XS/parsetexi/separator.c:
+ put global_info directly in DOCUMENT, not as a pointer.
+
2024-05-18 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XS/main/document.c
diff --git a/tp/Texinfo/XS/convert/convert_html.c
b/tp/Texinfo/XS/convert/convert_html.c
index 758b5c4b58..ae75ab0233 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -9114,7 +9114,7 @@ find_image_extension_file (CONVERTER *self, const ELEMENT
*element,
char *located_image_path;
xasprintf (&image_file, "%s%s", image_basefile, extension);
- file_name = encoded_input_file_name (self->conf, self->document->global_info,
+ file_name = encoded_input_file_name (self->conf,
&self->document->global_info,
image_file, 0, &input_file_encoding, &element->source_info);
located_image_path = locate_include_file (file_name,
@@ -10696,7 +10696,7 @@ convert_verbatiminclude_command (CONVERTER *self, const
enum command_id cmd,
{
ELEMENT *verbatim_include_verbatim
= expand_verbatiminclude (&self->error_messages, self->conf,
- self->document->global_info, element);
+ &self->document->global_info, element);
if (verbatim_include_verbatim)
{
@@ -15953,12 +15953,12 @@ html_prepare_converted_output_info (CONVERTER *self)
self->added_title_tree = 1;
- if (self->document->global_info->input_file_name)
+ if (self->document->global_info.input_file_name)
{
/* setup a source info with file only */
memset (&cmd_source_info, 0, sizeof (SOURCE_INFO));
cmd_source_info.file_name
- = self->document->global_info->input_file_name;
+ = self->document->global_info.input_file_name;
/* this is more in line with the Perl function used, as DEBUG is
checked in the called function */
message_list_line_error_ext (&self->error_messages, self->conf,
@@ -18711,7 +18711,7 @@ convert_output_output_unit_internal (CONVERTER *self,
int overwritten_file;
char *encoded_out_filepath = encoded_output_file_name (self->conf,
- self->document->global_info, out_filepath,
+ &self->document->global_info, out_filepath,
&path_encoding, 0);
/* overwritten_file being set cannot happen */
FILE *file_fh = output_files_open_out (&self->output_files_information,
@@ -19159,7 +19159,7 @@ html_node_redirections (CONVERTER *self,
char *encoded_out_filepath
= encoded_output_file_name (self->conf,
- self->document->global_info, out_filepath,
+ &self->document->global_info, out_filepath,
&path_encoding, 0);
/* overwritten_file being set cannot happen */
FILE *file_fh
diff --git a/tp/Texinfo/XS/main/DocumentXS.xs b/tp/Texinfo/XS/main/DocumentXS.xs
index 73e6d2c2ae..883a25c1b8 100644
--- a/tp/Texinfo/XS/main/DocumentXS.xs
+++ b/tp/Texinfo/XS/main/DocumentXS.xs
@@ -178,29 +178,29 @@ set_document_global_info (SV *document_in, char *key, SV
*value_sv)
if (!strcmp (key, "input_file_name"))
{
char *value = (char *)SvPVbyte_nolen(value_sv);
- if (document->global_info->input_file_name)
+ if (document->global_info.input_file_name)
{
fprintf (stderr,
"BUG: %zu: reset input_file_name '%s' -> '%s'\n",
document->descriptor,
- document->global_info->input_file_name, value);
- non_perl_free (document->global_info->input_file_name);
+ document->global_info.input_file_name, value);
+ non_perl_free (document->global_info.input_file_name);
}
- document->global_info->input_file_name
+ document->global_info.input_file_name
= non_perl_strdup (value);
}
else if (!strcmp (key, "input_perl_encoding"))
{
/* should not be needed, but in case global information
is reused, it will avoid memory leaks */
- non_perl_free (document->global_info->input_perl_encoding);
- document->global_info->input_perl_encoding
+ non_perl_free (document->global_info.input_perl_encoding);
+ document->global_info.input_perl_encoding
= non_perl_strdup ((char *)SvPVbyte_nolen(value_sv));
}
else
{
add_associated_info_string_dup (
- &document->global_info->other_info,
+ &document->global_info.other_info,
key, (char *)SvPVutf8_nolen(value_sv));
}
}
diff --git a/tp/Texinfo/XS/main/build_perl_info.c
b/tp/Texinfo/XS/main/build_perl_info.c
index 03d33d3789..fff850da78 100644
--- a/tp/Texinfo/XS/main/build_perl_info.c
+++ b/tp/Texinfo/XS/main/build_perl_info.c
@@ -1390,7 +1390,8 @@ get_document (size_t document_descriptor)
hv = newHV ();
hv_tree = newHV ();
- hv_info = build_global_info (document->global_info,
document->global_commands);
+ hv_info = build_global_info (&document->global_info,
+ document->global_commands);
#define STORE(key, value) hv_store (hv, key, strlen (key), newRV_inc ((SV *)
value), 0)
STORE("tree", hv_tree);
@@ -1434,7 +1435,7 @@ fill_document_hv (HV *hv, size_t document_descriptor, int
no_store)
hv_tree = build_texinfo_tree (document->tree, 0);
- hv_info = build_global_info (document->global_info,
+ hv_info = build_global_info (&document->global_info,
document->global_commands);
hv_commands_info = build_global_commands (document->global_commands);
@@ -1588,6 +1589,11 @@ store_texinfo_tree (DOCUMENT *document, HV *document_hv)
return result_sv;
}
+/* there are 2 differences between BUILD_PERL_DOCUMENT_ITEM and
+ BUILD_PERL_DOCUMENT_LIST: in BUILD_PERL_DOCUMENT_LIST no check on existing
+ and the address of document->fieldname is passed.
+ */
+
#define
BUILD_PERL_DOCUMENT_ITEM(funcname,fieldname,keyname,flagname,buildname,HVAV) \
SV * \
funcname (SV *document_in) \
@@ -1718,7 +1724,7 @@ document_global_information (SV *document_in)
{
if (document->modified_information & F_DOCM_global_info)
{
- HV *result_hv = build_global_info (document->global_info,
+ HV *result_hv = build_global_info (&document->global_info,
document->global_commands);
result_sv = newRV_inc ((SV *) result_hv);
hv_store (document_hv, key, strlen (key), result_sv, 0);
diff --git a/tp/Texinfo/XS/main/convert_to_text.c
b/tp/Texinfo/XS/main/convert_to_text.c
index 3b2ccc1a06..c6340674de 100644
--- a/tp/Texinfo/XS/main/convert_to_text.c
+++ b/tp/Texinfo/XS/main/convert_to_text.c
@@ -892,7 +892,7 @@ convert_to_text_internal (const ELEMENT *element,
TEXT_OPTIONS *text_options,
DOCUMENT *document
= retrieve_document (text_options->document_descriptor);
if (document)
- global_information = document->global_info;
+ global_information = &document->global_info;
}
verbatim_include_verbatim
= expand_verbatiminclude (0,
text_options->self_converter_options,
diff --git a/tp/Texinfo/XS/main/document.c b/tp/Texinfo/XS/main/document.c
index 823c603687..a174e77523 100644
--- a/tp/Texinfo/XS/main/document.c
+++ b/tp/Texinfo/XS/main/document.c
@@ -81,11 +81,6 @@ new_document (void)
memset (document, 0, sizeof (DOCUMENT));
document->descriptor = document_index +1;
- /* Information that is not local to where it is set in the Texinfo input,
- for example document language and encoding. */
- document->global_info = malloc (sizeof (GLOBAL_INFO));
- memset (document->global_info, 0, sizeof (GLOBAL_INFO));
-
document->global_commands = malloc (sizeof (GLOBAL_COMMANDS));
memset (document->global_commands, 0, sizeof (GLOBAL_COMMANDS));
/* For filenames and macro names, it is possible that they won't be
referenced
@@ -401,8 +396,7 @@ destroy_document_information_except_tree (DOCUMENT
*document)
{
if (document->tree)
{
- delete_global_info (document->global_info);
- free (document->global_info);
+ delete_global_info (&document->global_info);
delete_global_commands (document->global_commands);
free (document->global_commands);
free (document->internal_references.list);
diff --git a/tp/Texinfo/XS/main/document_types.h
b/tp/Texinfo/XS/main/document_types.h
index cc19381dc1..aa5e3dd0b6 100644
--- a/tp/Texinfo/XS/main/document_types.h
+++ b/tp/Texinfo/XS/main/document_types.h
@@ -186,7 +186,9 @@ typedef struct DOCUMENT {
LABEL_LIST labels_list;
/* Array of target elements with unique identifiers, sorted by identifier */
LABEL_LIST identifiers_target;
- GLOBAL_INFO *global_info;
+ /* Information that is not local to where it is set in the Texinfo input,
+ for example document language and encoding. */
+ GLOBAL_INFO global_info;
GLOBAL_COMMANDS *global_commands;
STRING_LIST *small_strings;
ELEMENT_LIST *nodes_list;
diff --git a/tp/Texinfo/XS/main/utils.c b/tp/Texinfo/XS/main/utils.c
index ece8562801..b886396ace 100644
--- a/tp/Texinfo/XS/main/utils.c
+++ b/tp/Texinfo/XS/main/utils.c
@@ -1044,10 +1044,9 @@ void
set_output_encoding (OPTIONS *customization_information, DOCUMENT *document)
{
if (customization_information
- && document && document->global_info
- && document->global_info->input_encoding_name) {
+ && document && document->global_info.input_encoding_name) {
set_conf_string (&customization_information->OUTPUT_ENCODING_NAME,
- document->global_info->input_encoding_name);
+ document->global_info.input_encoding_name);
}
}
diff --git a/tp/Texinfo/XS/parsetexi/api.c b/tp/Texinfo/XS/parsetexi/api.c
index 159017088f..71eeb83589 100644
--- a/tp/Texinfo/XS/parsetexi/api.c
+++ b/tp/Texinfo/XS/parsetexi/api.c
@@ -132,7 +132,7 @@ parse_file (const char *filename, const char
*input_file_name,
return 0;
}
- global_info = parsed_document->global_info;
+ global_info = &parsed_document->global_info;
free (global_info->input_file_name);
free (global_info->input_directory);
diff --git a/tp/Texinfo/XS/parsetexi/end_line.c
b/tp/Texinfo/XS/parsetexi/end_line.c
index f1fe6ed85f..2160007a94 100644
--- a/tp/Texinfo/XS/parsetexi/end_line.c
+++ b/tp/Texinfo/XS/parsetexi/end_line.c
@@ -1305,7 +1305,6 @@ end_line_misc_line (ELEMENT *current)
{
int status;
char *fullpath, *sys_filename;
- GLOBAL_INFO *global_info = parsed_document->global_info;
sys_filename = encode_file_name (text);
fullpath = parser_locate_include_file (sys_filename);
@@ -1336,7 +1335,8 @@ end_line_misc_line (ELEMENT *current)
include_source_mark = new_source_mark (SM_type_include);
include_source_mark->status = SM_status_start;
set_input_source_mark (include_source_mark);
- add_string (fullpath, &global_info->included_files);
+ add_string (fullpath,
+
&parsed_document->global_info.included_files);
}
free (fullpath);
}
@@ -1344,7 +1344,7 @@ end_line_misc_line (ELEMENT *current)
else if (current->cmd == CM_verbatiminclude)
{
char *fullpath, *sys_filename;
- GLOBAL_INFO *global_info = parsed_document->global_info;
+ GLOBAL_INFO *global_info = &parsed_document->global_info;
if (global_info->input_encoding_name)
add_extra_string_dup (current, "input_encoding_name",
diff --git a/tp/Texinfo/XS/parsetexi/handle_commands.c
b/tp/Texinfo/XS/parsetexi/handle_commands.c
index 7de7f49003..b0869fd155 100644
--- a/tp/Texinfo/XS/parsetexi/handle_commands.c
+++ b/tp/Texinfo/XS/parsetexi/handle_commands.c
@@ -698,11 +698,11 @@ handle_line_command (ELEMENT *current, char **line_inout,
if (cmd == CM_raisesections)
{
- parsed_document->global_info->sections_level_modifier++;
+ parsed_document->global_info.sections_level_modifier++;
}
else if (cmd == CM_lowersections)
{
- parsed_document->global_info->sections_level_modifier--;
+ parsed_document->global_info.sections_level_modifier--;
}
if (command_e)
@@ -825,11 +825,12 @@ handle_line_command (ELEMENT *current, char **line_inout,
if (command_data(data_cmd).flags & CF_sectioning_heading)
{
- GLOBAL_INFO *global_info = parsed_document->global_info;
- if (global_info->sections_level_modifier)
+ int sections_level_modifier
+ = parsed_document->global_info.sections_level_modifier;
+ if (sections_level_modifier)
{
add_extra_integer (command_e, "level_modifier",
- global_info->sections_level_modifier);
+ sections_level_modifier);
}
}
diff --git a/tp/Texinfo/XS/parsetexi/indices.c
b/tp/Texinfo/XS/parsetexi/indices.c
index 578f33a045..b572c3f31b 100644
--- a/tp/Texinfo/XS/parsetexi/indices.c
+++ b/tp/Texinfo/XS/parsetexi/indices.c
@@ -241,7 +241,8 @@ enter_index_entry (enum command_id index_type_cmd,
INDEX *idx;
INDEX_ENTRY *entry;
TEXT ignored_chars;
- GLOBAL_INFO *global_info = parsed_document->global_info;
+ const IGNORED_CHARS *ignored_chars_info
+ = &parsed_document->global_info.ignored_chars;
if (conf.no_index)
return;
@@ -265,13 +266,13 @@ enter_index_entry (enum command_id index_type_cmd,
/* Create ignored_chars string. */
text_init (&ignored_chars);
- if (global_info->ignored_chars.backslash)
+ if (ignored_chars_info->backslash)
text_append (&ignored_chars, "\\");
- if (global_info->ignored_chars.hyphen)
+ if (ignored_chars_info->hyphen)
text_append (&ignored_chars, "-");
- if (global_info->ignored_chars.lessthan)
+ if (ignored_chars_info->lessthan)
text_append (&ignored_chars, "<");
- if (global_info->ignored_chars.atsign)
+ if (ignored_chars_info->atsign)
text_append (&ignored_chars, "@");
if (ignored_chars.end > 0)
{
diff --git a/tp/Texinfo/XS/parsetexi/input.c b/tp/Texinfo/XS/parsetexi/input.c
index 492d988e75..a7cf42876a 100644
--- a/tp/Texinfo/XS/parsetexi/input.c
+++ b/tp/Texinfo/XS/parsetexi/input.c
@@ -79,7 +79,7 @@ set_input_encoding (const char *encoding)
if (current_encoding_conversion)
{
encoding_set = 1;
- GLOBAL_INFO *global_info = parsed_document->global_info;
+ GLOBAL_INFO *global_info = &parsed_document->global_info;
free (global_info->input_encoding_name);
global_info->input_encoding_name = strdup (encoding);
}
@@ -210,7 +210,7 @@ encode_file_name (char *filename)
else if (doc_encoding_for_input_file_name)
{
if (current_encoding_conversion
- && strcmp (parsed_document->global_info->input_encoding_name,
+ && strcmp (parsed_document->global_info.input_encoding_name,
"utf-8"))
{
char *conversion_encoding
diff --git a/tp/Texinfo/XS/parsetexi/macro.c b/tp/Texinfo/XS/parsetexi/macro.c
index 81739fcf11..79c5d6b7a2 100644
--- a/tp/Texinfo/XS/parsetexi/macro.c
+++ b/tp/Texinfo/XS/parsetexi/macro.c
@@ -1061,16 +1061,17 @@ store_value (const char *name, const char *value)
/* Internal Texinfo flag */
if (!strncmp (name, "txi", 3) && parsed_document)
{
- GLOBAL_INFO *global_info = parsed_document->global_info;
+ IGNORED_CHARS *ignored_chars_info
+ = &parsed_document->global_info.ignored_chars;
int val = (strcmp (value, "0") != 0);
if (!strcmp (name, "txiindexbackslashignore"))
- global_info->ignored_chars.backslash = val;
+ ignored_chars_info->backslash = val;
else if (!strcmp (name, "txiindexhyphenignore"))
- global_info->ignored_chars.hyphen = val;
+ ignored_chars_info->hyphen = val;
else if (!strcmp (name, "txiindexlessthanignore"))
- global_info->ignored_chars.lessthan = val;
+ ignored_chars_info->lessthan = val;
else if (!strcmp (name, "txiindexatsignignore"))
- global_info->ignored_chars.atsign = val;
+ ignored_chars_info->atsign = val;
/* also: txicodequotebacktick, txicodequoteundirected,
txicommandconditionals. Deal with them here? */
@@ -1092,15 +1093,16 @@ clear_value (char *name)
/* Internal Texinfo flag */
if (!strncmp (name, "txi", 3))
{
- GLOBAL_INFO *global_info = parsed_document->global_info;
+ IGNORED_CHARS *ignored_chars_info
+ = &parsed_document->global_info.ignored_chars;
if (!strcmp (name, "txiindexbackslashignore"))
- global_info->ignored_chars.backslash = 0;
+ ignored_chars_info->backslash = 0;
else if (!strcmp (name, "txiindexhyphenignore"))
- global_info->ignored_chars.hyphen = 0;
+ ignored_chars_info->hyphen = 0;
else if (!strcmp (name, "txiindexlessthanignore"))
- global_info->ignored_chars.lessthan = 0;
+ ignored_chars_info->lessthan = 0;
else if (!strcmp (name, "txiindexatsignignore"))
- global_info->ignored_chars.atsign = 0;
+ ignored_chars_info->atsign = 0;
/* also: txicodequotebacktick, txicodequoteundirected,
txicommandconditionals. Deal with them here? */
diff --git a/tp/Texinfo/XS/parsetexi/separator.c
b/tp/Texinfo/XS/parsetexi/separator.c
index 428293fe02..1f21bcc348 100644
--- a/tp/Texinfo/XS/parsetexi/separator.c
+++ b/tp/Texinfo/XS/parsetexi/separator.c
@@ -430,7 +430,7 @@ handle_close_brace (ELEMENT *current, char **line_inout)
}
else if (closed_command == CM_image)
{
- GLOBAL_INFO *global_info = parsed_document->global_info;
+ GLOBAL_INFO *global_info = &parsed_document->global_info;
ELEMENT *image = current->parent;
if (image->args.number == 0
|| image->args.list[0]->contents.number == 0)
- Prev by Date:
[no subject]
- Next by Date:
branch master updated: * tp/Texinfo/XS/main/document.c (new_document) (destroy_document_information_except_tree, clear_document_errors) (clear_document_parser_errors), tp/Texinfo/XS/main/document_types.h (DOCUMENT), tp/Texinfo/XS/main/DocumentXS.xs, tp/Texinfo/XS/main/build_perl_info.c, tp/Texinfo/XS/main/translations.c, tp/Texinfo/XS/parsetexi/errors_parser.c, tp/Texinfo/XS/structuring_transfo/structuring.c, tp/Texinfo/XS/structuring_transfo/transformations.c: put error_messages and parser_error_messages direct [...]
- Previous by thread:
[no subject]
- Next by thread:
branch master updated: * tp/Texinfo/XS/main/document.c (new_document) (destroy_document_information_except_tree, clear_document_errors) (clear_document_parser_errors), tp/Texinfo/XS/main/document_types.h (DOCUMENT), tp/Texinfo/XS/main/DocumentXS.xs, tp/Texinfo/XS/main/build_perl_info.c, tp/Texinfo/XS/main/translations.c, tp/Texinfo/XS/parsetexi/errors_parser.c, tp/Texinfo/XS/structuring_transfo/structuring.c, tp/Texinfo/XS/structuring_transfo/transformations.c: put error_messages and parser_error_messages direct [...]
- Index(es):