[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/XS/main/translations.c (replace_conv
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/XS/main/translations.c (replace_convert_substrings): call reset_parser_conf now that the configurations can be separate. |
Date: |
Wed, 22 May 2024 16:51:37 -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 b2788fdeae * tp/Texinfo/XS/main/translations.c
(replace_convert_substrings): call reset_parser_conf now that the
configurations can be separate.
b2788fdeae is described below
commit b2788fdeae9e6bc2af6e0e1b76e91335fd7a21e1
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Wed May 22 22:51:26 2024 +0200
* tp/Texinfo/XS/main/translations.c (replace_convert_substrings): call
reset_parser_conf now that the configurations can be separate.
* tp/Texinfo/XS/parsetexi/Parsetexi.pm (parser): do not store the
configuration for later reuse of the parser if accept_internalvalue is
set, which is interpreted as being called from gdt, in which case the
parser will not be reused.
---
ChangeLog | 10 ++++++++++
tp/Texinfo/XS/main/translations.c | 17 ++++++-----------
tp/Texinfo/XS/parsetexi/Parsetexi.pm | 18 +++++++++++++-----
tp/Texinfo/XS/parsetexi/conf.c | 3 +--
4 files changed, 30 insertions(+), 18 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 860fb41e58..f5b0a4a1fb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2024-05-22 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/XS/main/translations.c (replace_convert_substrings): call
+ reset_parser_conf now that the configurations can be separate.
+
+ * tp/Texinfo/XS/parsetexi/Parsetexi.pm (parser): do not store the
+ configuration for later reuse of the parser if accept_internalvalue is
+ set, which is interpreted as being called from gdt, in which case the
+ parser will not be reused.
+
2024-05-22 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XS/main/utils.c (wipe_values),
diff --git a/tp/Texinfo/XS/main/translations.c
b/tp/Texinfo/XS/main/translations.c
index c177f909db..f8143cd4c7 100644
--- a/tp/Texinfo/XS/main/translations.c
+++ b/tp/Texinfo/XS/main/translations.c
@@ -431,9 +431,6 @@ replace_convert_substrings (char *translated_string,
char *texinfo_line;
int document_descriptor;
int parser_debug_level = 0;
- int previous_debug_level;
- int previous_no_index;
- int previous_no_user_commands;
DOCUMENT *document;
if (replaced_substrings)
@@ -469,15 +466,18 @@ replace_convert_substrings (char *translated_string,
if (debug_level > 0)
parser_debug_level = debug_level - 1;
- previous_debug_level = parser_conf_set_DEBUG (parser_debug_level);
+ /* same as creating a new parser in Perl */
+ reset_parser_conf ();
+
+ parser_conf_set_DEBUG (parser_debug_level);
/*
accept @txiinternalvalue as a valid Texinfo command, used to mark
location in tree of substituted brace enclosed strings.
*/
parser_conf_set_accept_internalvalue (1);
- previous_no_index = parser_conf_set_NO_INDEX (1);
- previous_no_user_commands = parser_conf_set_NO_USER_COMMANDS (1);
+ parser_conf_set_NO_INDEX (1);
+ parser_conf_set_NO_USER_COMMANDS (1);
document_descriptor = parse_string (texinfo_line, 1);
@@ -497,11 +497,6 @@ replace_convert_substrings (char *translated_string,
}
clear_document_parser_errors (document_descriptor);
- parser_conf_set_accept_internalvalue (0);
- parser_conf_set_NO_INDEX (previous_no_index);
- parser_conf_set_NO_USER_COMMANDS (previous_no_user_commands);
- parser_conf_set_DEBUG (previous_debug_level);
-
if (replaced_substrings)
{
ELEMENT *result_tree = substitute (document->tree, replaced_substrings);
diff --git a/tp/Texinfo/XS/parsetexi/Parsetexi.pm
b/tp/Texinfo/XS/parsetexi/Parsetexi.pm
index a3124de21f..fcd567ecca 100644
--- a/tp/Texinfo/XS/parsetexi/Parsetexi.pm
+++ b/tp/Texinfo/XS/parsetexi/Parsetexi.pm
@@ -113,6 +113,11 @@ sub parser (;$)
# (re)set debug in any case, assuming that undef DEBUG is no debug
parser_conf_set_DEBUG($debug);
+ # Storing conf is only needed if the parser is reused. There could be
+ # a customization variable. Instead, we set store_conf to 0 if
+ # accept_internalvalue is set, if called from gdt as we know for sure that
+ # the parser is not gonna be reused.
+ my $store_conf = 1;
if (defined($conf)) {
foreach my $key (keys(%$conf)) {
if ($key eq 'INCLUDE_DIRECTORIES') {
@@ -153,7 +158,9 @@ sub parser (;$)
}
} elsif ($key eq 'accept_internalvalue') {
if ($conf->{$key}) {
+ # called from gdt, no need to store the parser configuration
parser_conf_set_accept_internalvalue(1);
+ $store_conf = 0;
}
} elsif ($key eq 'registrar' or $key eq 'COMMAND_LINE_ENCODING'
or $key eq 'DEBUG') {
@@ -163,17 +170,18 @@ sub parser (;$)
}
}
}
+ if ($store_conf) {
+ register_parser_conf($parser);
- register_parser_conf($parser);
+ # variables found by get_conf, set to the parser initialization values
+ # only. What is found in the document has no effect.
+ $parser->{'conf'} = $parser_conf;
+ }
if (not $parser->{'registrar'}) {
$parser->{'registrar'} = Texinfo::Report::new();
}
- # variables found by get_conf, set to the parser initialization values
- # only. What is found in the document has no effect.
- $parser->{'conf'} = $parser_conf;
-
return $parser;
}
diff --git a/tp/Texinfo/XS/parsetexi/conf.c b/tp/Texinfo/XS/parsetexi/conf.c
index 914b4ee6eb..de6e0e2a22 100644
--- a/tp/Texinfo/XS/parsetexi/conf.c
+++ b/tp/Texinfo/XS/parsetexi/conf.c
@@ -130,13 +130,12 @@ parser_conf_set_accept_internalvalue (int value)
void
reset_parser_conf (void)
{
- /* FIXME except for the very first call to reset_parser_conf, there
- should always be a descriptor set, so only the first case may happen */
if (global_parser_conf.descriptor)
/* it is important to set to 0 for list structures such that the list
pointer is set to 0 and not reused. */
memset (&global_parser_conf, 0, sizeof (PARSER_CONF));
else
+ /* unset the previous structures if not registered */
clear_parser_conf (&global_parser_conf);
global_parser_conf.descriptor = 0;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/XS/main/translations.c (replace_convert_substrings): call reset_parser_conf now that the configurations can be separate.,
Patrice Dumas <=