texinfo-commits
[Top][All Lists]
Advanced

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

[no subject]


From: Patrice Dumas
Date: Mon, 30 Sep 2024 13:29:14 -0400 (EDT)

branch: master
commit 6953da1af3945b9bdec3f894d62dc8307683a3d8
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Jul 21 20:44:36 2024 +0200

    * tp/Texinfo/XS/main/command_stack.c (push_string_stack_string):
    handle pushing NULL on a string_stack.
    
    * tp/Texinfo/Convert/HTML.pm (_internal_command_text)
    (convert_tree_new_formatting_context, _set_multiple_conversions)
    (_unset_multiple_conversions), tp/Texinfo/XS/convert/convert_html.c
    (html_set_multiple_conversions, html_unset_multiple_conversions)
    (convert_tree_new_formatting_context, html_internal_command_text):
    add multiple pass string argument to set_multiple_conversions,
    push on multiple_pass stack in the function and pop in
    unset_multiple_conversions.  Add html_set_multiple_conversions and
    html_unset_multiple_conversions to C.
    
    * tp/Texinfo/Convert/HTML.pm (%XS_conversion_overrides),
    (_initialize_output_state, conversion_initialization),
    tp/Texinfo/XS/convert/ConvertXS.xs (html_set_multiple_conversions)
    (html_unset_multiple_conversions, html_in_multi_expanded): add XS
    override for in_multi_expanded, update XS overrides for the changes in
    html_unset_multiple_conversions and html_set_multiple_conversions.
---
 ChangeLog                            | 22 ++++++++++++++++++++++
 tp/Texinfo/Convert/HTML.pm           | 24 ++++++++++++++----------
 tp/Texinfo/XS/convert/ConvertXS.xs   | 32 +++++++++++++++++++++++++++++---
 tp/Texinfo/XS/convert/convert_html.c | 25 +++++++++++++++++++------
 tp/Texinfo/XS/convert/convert_html.h |  3 +++
 tp/Texinfo/XS/main/command_stack.c   |  5 ++++-
 6 files changed, 91 insertions(+), 20 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 4221d57846..88d7ae9b97 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,28 @@
        get_converter_perl_info.c functions declarations to
        get_converter_perl_info.h.
 
+2024-07-21  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/main/command_stack.c (push_string_stack_string):
+       handle pushing NULL on a string_stack.
+
+       * tp/Texinfo/Convert/HTML.pm (_internal_command_text)
+       (convert_tree_new_formatting_context, _set_multiple_conversions)
+       (_unset_multiple_conversions), tp/Texinfo/XS/convert/convert_html.c
+       (html_set_multiple_conversions, html_unset_multiple_conversions)
+       (convert_tree_new_formatting_context, html_internal_command_text): 
+       add multiple pass string argument to set_multiple_conversions,
+       push on multiple_pass stack in the function and pop in
+       unset_multiple_conversions.  Add html_set_multiple_conversions and
+       html_unset_multiple_conversions to C.
+
+       * tp/Texinfo/Convert/HTML.pm (%XS_conversion_overrides),
+       (_initialize_output_state, conversion_initialization),
+       tp/Texinfo/XS/convert/ConvertXS.xs (html_set_multiple_conversions)
+       (html_unset_multiple_conversions, html_in_multi_expanded): add XS
+       override for in_multi_expanded, update XS overrides for the changes in
+       html_unset_multiple_conversions and html_set_multiple_conversions.
+
 2024-07-21  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/Convert/HTML.pm (_initialize_output_state),
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 903aeb0697..8c39873b5a 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -221,6 +221,8 @@ my %XS_conversion_overrides = (
    => "Texinfo::Convert::ConvertXS::html_preformatted_classes_stack",
   "Texinfo::Convert::HTML::in_align"
    => "Texinfo::Convert::ConvertXS::html_in_align",
+  "Texinfo::Convert::HTML::in_multi_expanded"
+   => "Texinfo::Convert::ConvertXS::html_in_multi_expanded",
   "Texinfo::Convert::HTML::current_filename"
    => "Texinfo::Convert::ConvertXS::html_current_filename",
   "Texinfo::Convert::HTML::current_output_unit"
@@ -1412,12 +1414,12 @@ sub _internal_command_text($$$)
       $tree_root = $selected_tree;
     }
 
-    $self->_set_multiple_conversions();
+    _set_multiple_conversions($self, undef);
 
     _push_referred_command_stack_command($self, $command);
     $target->{$type} = $self->_convert($tree_root, $explanation);
     _pop_referred_command_stack($self);
-    $self->_unset_multiple_conversions;
+    _unset_multiple_conversions($self);
 
     $self->_pop_document_context();
     return $target->{$type};
@@ -2488,9 +2490,8 @@ sub convert_tree_new_formatting_context($$$;$$$)
   my $multiple_pass_str = '';
 
   if ($multiple_pass) {
-    $self->_set_multiple_conversions();
-    push @{$self->{'multiple_pass'}}, $multiple_pass;
-    $multiple_pass_str = '|M'
+    _set_multiple_conversions($self, $multiple_pass);
+    $multiple_pass_str = '|M';
   }
 
   print STDERR "new_fmt_ctx ${context_string_str}${multiple_pass_str}\n"
@@ -2498,8 +2499,7 @@ sub convert_tree_new_formatting_context($$$;$$$)
   my $result = $self->convert_tree($tree, "new_fmt_ctx ${context_string_str}");
 
   if ($multiple_pass) {
-    $self->_unset_multiple_conversions();
-    pop @{$self->{'multiple_pass'}};
+    _unset_multiple_conversions($self);
   }
 
   $self->_pop_document_context();
@@ -8649,16 +8649,20 @@ sub _unset_raw_context($)
   $self->{'document_context'}->[-1]->{'raw'}--;
 }
 
-sub _set_multiple_conversions($)
+sub _set_multiple_conversions($$)
 {
   my $self = shift;
+  my $multiple_pass = shift;
+
   $self->{'multiple_conversions'}++;
+  push @{$self->{'multiple_pass'}}, $multiple_pass;
 }
 
 sub _unset_multiple_conversions($)
 {
   my $self = shift;
   $self->{'multiple_conversions'}--;
+  pop @{$self->{'multiple_pass'}};
 }
 
 # can be set through Texinfo::Config::texinfo_register_file_id_setting_function
@@ -12447,6 +12451,8 @@ sub _initialize_output_state($$)
   $self->{'converter_info'}->{'expanded_formats'}
     = $self->{'expanded_formats'};
 
+  $self->{'multiple_pass'} = [];
+
   # for global directions always set, and for directions to special elements,
   # only filled if special elements are actually used.
   $self->{'global_units_directions'} = {};
@@ -12471,8 +12477,6 @@ sub conversion_initialization($;$)
 
   $self->{'shared_conversion_state'} = {};
 
-  $self->{'multiple_pass'} = [];
-
   $self->_initialize_output_state('_convert');
 }
 
diff --git a/tp/Texinfo/XS/convert/ConvertXS.xs 
b/tp/Texinfo/XS/convert/ConvertXS.xs
index 98f528a476..dd50acbeb0 100644
--- a/tp/Texinfo/XS/convert/ConvertXS.xs
+++ b/tp/Texinfo/XS/convert/ConvertXS.xs
@@ -848,14 +848,21 @@ html_unset_raw_context (SV *converter_in)
            html_unset_raw_context (self);
 
 void
-html_set_multiple_conversions (SV *converter_in)
+html_set_multiple_conversions (SV *converter_in, SV *multiple_pass_sv)
      PREINIT:
          CONVERTER *self;
      CODE:
          self = get_sv_converter (converter_in,
                                   "html_set_multiple_conversions");
          if (self)
-           self->multiple_conversions++;
+           {
+             char *multiple_pass;
+             if (SvOK (multiple_pass_sv))
+               multiple_pass = SvPVutf8_nolen (multiple_pass_sv);
+             else
+               multiple_pass = 0;
+             html_set_multiple_conversions (self, multiple_pass);
+           }
 
 void
 html_unset_multiple_conversions (SV *converter_in)
@@ -865,7 +872,26 @@ html_unset_multiple_conversions (SV *converter_in)
          self = get_sv_converter (converter_in,
                                   "html_unset_multiple_conversions");
          if (self)
-           self->multiple_conversions--;
+           html_unset_multiple_conversions (self);
+
+SV *
+html_in_multi_expanded (SV *converter_in)
+     PREINIT:
+         CONVERTER *self;
+         const char *multi_expanded = 0;
+     CODE:
+         self = get_sv_converter (converter_in,
+                                  "html_in_multi_expanded");
+         if (self)
+           multi_expanded = html_in_multi_expanded (self);
+
+         if (multi_expanded)
+           RETVAL = newSVpv_utf8 (multi_expanded, 0);
+         else
+           RETVAL = newSV (0);
+    OUTPUT:
+         RETVAL
+
 
 SV *
 html_debug_print_html_contexts (SV *converter_in)
diff --git a/tp/Texinfo/XS/convert/convert_html.c 
b/tp/Texinfo/XS/convert/convert_html.c
index 6c8401de2b..775414977f 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -2954,6 +2954,20 @@ html_convert_tree (CONVERTER *self, const ELEMENT *tree,
   return result.text;
 }
 
+void
+html_set_multiple_conversions (CONVERTER *self, const char *multiple_pass)
+{
+  self->multiple_conversions++;
+  push_string_stack_string (&self->multiple_pass, multiple_pass);
+}
+
+void
+html_unset_multiple_conversions (CONVERTER *self)
+{
+  self->multiple_conversions--;
+  pop_string_stack (&self->multiple_pass);
+}
+
 /* Call convert_tree out of the main conversion flow.
  */
 char *
@@ -2974,8 +2988,7 @@ convert_tree_new_formatting_context (CONVERTER *self, 
const ELEMENT *tree,
 
   if (multiple_pass)
     {
-      self->multiple_conversions++;
-      push_string_stack_string (&self->multiple_pass, multiple_pass);
+      html_set_multiple_conversions (self, multiple_pass);
       self->modified_state |= HMSF_multiple_pass;
       multiple_pass_str = "|M";
     }
@@ -2991,8 +3004,7 @@ convert_tree_new_formatting_context (CONVERTER *self, 
const ELEMENT *tree,
 
   if (multiple_pass)
     {
-      self->multiple_conversions--;
-      pop_string_stack (&self->multiple_pass);
+      html_unset_multiple_conversions (self);
       self->modified_state |= HMSF_multiple_pass;
     }
 
@@ -4159,14 +4171,15 @@ html_internal_command_text (CONVERTER *self, const 
ELEMENT *command,
           else
             tree_root = selected_tree;
 
-          self->multiple_conversions++;
+          html_set_multiple_conversions (self, 0);
           push_element_reference_stack_element (&self->referred_command_stack,
                                                 command, command->hv);
           target_info->command_text[type]
             = html_convert_tree (self, tree_root, explanation);
           free (explanation);
           pop_element_reference_stack (&self->referred_command_stack);
-          self->multiple_conversions--;
+
+          html_unset_multiple_conversions (self);
 
           html_pop_document_context (self);
 
diff --git a/tp/Texinfo/XS/convert/convert_html.h 
b/tp/Texinfo/XS/convert/convert_html.h
index 0892ff7976..21beba8b8b 100644
--- a/tp/Texinfo/XS/convert/convert_html.h
+++ b/tp/Texinfo/XS/convert/convert_html.h
@@ -93,6 +93,8 @@ void html_set_string_context (CONVERTER *self);
 void html_unset_string_context (CONVERTER *self);
 void html_set_raw_context (CONVERTER *self);
 void html_unset_raw_context (CONVERTER *self);
+void html_set_multiple_conversions (CONVERTER *self, const char 
*multiple_pass);
+void html_unset_multiple_conversions (CONVERTER *self);
 
 int html_in_math (const CONVERTER *self);
 int html_in_preformatted_context (const CONVERTER *self);
@@ -110,6 +112,7 @@ enum command_id html_top_block_command (const CONVERTER 
*self);
 const COMMAND_OR_TYPE_STACK *html_preformatted_classes_stack
                                     (const CONVERTER *self);
 enum command_id html_in_align (const CONVERTER *self);
+const char *html_in_multi_expanded (CONVERTER *self);
 
 char *debug_print_html_contexts (const CONVERTER *self);
 
diff --git a/tp/Texinfo/XS/main/command_stack.c 
b/tp/Texinfo/XS/main/command_stack.c
index 0263f052a8..6e3b449230 100644
--- a/tp/Texinfo/XS/main/command_stack.c
+++ b/tp/Texinfo/XS/main/command_stack.c
@@ -138,7 +138,10 @@ push_string_stack_string (STRING_STACK *stack, const char 
*string)
                    (stack->space += 5) * sizeof (char *));
     }
 
-  stack->stack[stack->top] = strdup (string);
+  if (string)
+    stack->stack[stack->top] = strdup (string);
+  else
+    stack->stack[stack->top] = 0;
 
   stack->top++;
 }



reply via email to

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