texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[no subject]


From: Patrice Dumas
Date: Thu, 23 May 2024 13:15:53 -0400 (EDT)

branch: master
commit 613f340200eb3641252a21514a41a5d2979f025f
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Thu May 23 14:32:33 2024 +0200

    * tp/Texinfo/ParserNonXS.pm: access 'accept_internalvalue' in 'conf'.
    
    * tp/Texinfo/ParserNonXS.pm (_initialize_parsing): only initialize
    states from conf if they are modified during parsing.
---
 ChangeLog                     |  7 +++++++
 tp/Texinfo/ParserNonXS.pm     | 22 +++++++++-------------
 tp/Texinfo/XS/parsetexi/api.c | 18 ++++++++++--------
 3 files changed, 26 insertions(+), 21 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 3987a7237f..5e7327dcb0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2024-05-23  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/ParserNonXS.pm: access 'accept_internalvalue' in 'conf'.
+
+       * tp/Texinfo/ParserNonXS.pm (_initialize_parsing): only initialize
+       states from conf if they are modified during parsing.
+
 2024-05-23  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/parsetexi/api.c (parse_file): comment out the code
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index 7cdf0d1f47..c0de51b17c 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -635,17 +635,13 @@ sub _initialize_parsing()
 
   my $parser_state = dclone(\%parser_state_initialization);
 
-  # initialize with conf.  Note that most options do not ever change,
-  # but some do, in practice documentlanguage (if not in 'set') and
-  # values, such that it is important to reset and replace values obtained
-  # at the end of the previous parsing.
-  foreach my $key (keys(%{$parser->{'conf'}})) {
-    if (ref($parser->{'conf'}->{$key})) {
-      $parser_state->{$key} = dclone($parser->{'conf'}->{$key});
-    } else {
-      # includes undef values
-      $parser_state->{$key} = $parser->{'conf'}->{$key};
-    }
+  # initialize from conf.
+  if ($parser->{'conf'}->{'values'}) {
+    $parser_state->{'values'} = dclone($parser->{'conf'}->{'values'});
+  }
+  if (defined($parser->{'conf'}->{'documentlanguage'})) {
+    $parser_state->{'documentlanguage'}
+      = $parser->{'conf'}->{'documentlanguage'};
   }
 
   $parser_state->{'document'} = $document;
@@ -6778,7 +6774,7 @@ sub _process_remaining_on_line($$$$)
             }
             if ($all_commands{$name}
                 or ($name eq 'txiinternalvalue'
-                    and $self->{'accept_internalvalue'})) {
+                    and $self->{'conf'}->{'accept_internalvalue'})) {
               $self->_line_warn(sprintf(__(
                                 "redefining Texinfo language command: \@%s"),
                                         $name), $current->{'source_info'});
@@ -7098,7 +7094,7 @@ sub _process_remaining_on_line($$$$)
       and !$self->{'index_entry_commands'}->{$command}
       # @txiinternalvalue is invalid unless accept_internalvalue is set
       and !($command eq 'txiinternalvalue'
-            and $self->{'accept_internalvalue'})
+            and $self->{'conf'}->{'accept_internalvalue'})
       and !$macro_call_element) {
     $self->_line_error(sprintf(__("unknown command `%s'"),
                                   $command), $source_info);
diff --git a/tp/Texinfo/XS/parsetexi/api.c b/tp/Texinfo/XS/parsetexi/api.c
index 88cdee9126..0808281640 100644
--- a/tp/Texinfo/XS/parsetexi/api.c
+++ b/tp/Texinfo/XS/parsetexi/api.c
@@ -60,9 +60,10 @@ initialize_parsing (void)
   wipe_user_commands ();
   wipe_macros ();
 
+  /* initialize from conf */
   init_values ();
 
-  /* currently thee is no change done to include directories,
+  /* currently there is no change done to include directories,
      so global_parser_conf.include_directories could be used instead
      of parser_include_directories */
   clear_strings_list (&parser_include_directories);
@@ -76,6 +77,7 @@ initialize_parsing (void)
   else
     global_documentlanguage = 0;
 
+  /* initialize document state */
   free (global_clickstyle);
   global_clickstyle = strdup ("arrow");
   global_kbdinputstyle = kbd_distinct;
@@ -83,6 +85,13 @@ initialize_parsing (void)
   current_node = current_section = current_part = 0;
   source_marks_reset_counters ();
 
+  /* it is not totally obvious that is it better to reset the
+     list to avoid memory leaks rather than reuse the iconv
+     opened handlers */
+  parser_reset_encoding_list ();
+  set_input_encoding ("utf-8");
+
+  /* initialize parsing state */
   reset_context_stack ();
   reset_command_stack (&nesting_context.basic_inline_stack);
   reset_command_stack (&nesting_context.basic_inline_stack_on_line);
@@ -90,15 +99,8 @@ initialize_parsing (void)
   reset_command_stack (&nesting_context.regions_stack);
   memset (&nesting_context, 0, sizeof (nesting_context));
   reset_parser_counters ();
-  /* it is not totally obvious that is it better to reset the
-     list to avoid memory leaks rather than reuse the iconv
-     opened handlers */
-  parser_reset_encoding_list ();
 
   reset_obstacks ();
-
-
-  set_input_encoding ("utf-8");
 }
 
 void



reply via email to

[Prev in Thread] Current Thread [Next in Thread]