texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/Texinfo/Common.pm (split_custom_heading_comm


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/Common.pm (split_custom_heading_command_contents), tp/t/init/translation_in_parser_in_translation.pm, tp/Texinfo/XS/main/utils.c: do not use trim_spaces_comment_from_content in split_custom_heading_command_contents and translation_in_parser_in_translation.pm and remove trim_spaces_comment_from_content.
Date: Sun, 12 Nov 2023 16:32:37 -0500

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 563447522b * tp/Texinfo/Common.pm 
(split_custom_heading_command_contents), 
tp/t/init/translation_in_parser_in_translation.pm, tp/Texinfo/XS/main/utils.c: 
do not use trim_spaces_comment_from_content in 
split_custom_heading_command_contents and 
translation_in_parser_in_translation.pm and remove 
trim_spaces_comment_from_content.
563447522b is described below

commit 563447522ba0dffeb9f40ade779a1e1b8abfb6b6
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Nov 12 22:32:31 2023 +0100

    * tp/Texinfo/Common.pm (split_custom_heading_command_contents),
    tp/t/init/translation_in_parser_in_translation.pm,
    tp/Texinfo/XS/main/utils.c: do not use
    trim_spaces_comment_from_content in
    split_custom_heading_command_contents and
    translation_in_parser_in_translation.pm and remove
    trim_spaces_comment_from_content.
---
 ChangeLog                                         | 10 ++++
 tp/TODO                                           |  2 -
 tp/Texinfo/Common.pm                              | 72 +----------------------
 tp/Texinfo/XS/main/utils.c                        | 53 -----------------
 tp/Texinfo/XS/main/utils.h                        |  2 -
 tp/t/init/translation_in_parser_in_translation.pm |  9 +--
 6 files changed, 14 insertions(+), 134 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 7a15ed88ab..c5bc2e841f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2023-11-12  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/Common.pm (split_custom_heading_command_contents),
+       tp/t/init/translation_in_parser_in_translation.pm,
+       tp/Texinfo/XS/main/utils.c: do not use
+       trim_spaces_comment_from_content in
+       split_custom_heading_command_contents and
+       translation_in_parser_in_translation.pm and remove
+       trim_spaces_comment_from_content.
+
 2023-11-12  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/main/floats.c (add_to_listoffloats_list)
diff --git a/tp/TODO b/tp/TODO
index abc69ed168..097a1c6bff 100644
--- a/tp/TODO
+++ b/tp/TODO
@@ -43,8 +43,6 @@ Use ELEMENT_LIST for extra_contents extra_directions?
 error_messages: add a check that it is empty in
 html_destroy?
 
-remove trim_spaces_comment_from_content
-
 Bugs
 ====
 
diff --git a/tp/Texinfo/Common.pm b/tp/Texinfo/Common.pm
index 0b25e5217d..ec44d15a82 100644
--- a/tp/Texinfo/Common.pm
+++ b/tp/Texinfo/Common.pm
@@ -1386,63 +1386,6 @@ sub section_level($)
   return $level;
 }
 
-# NOTE this code does nothing with the current tree, as comments
-# are in 'info' 'comment_at_end', ignorable_spaces_after_command only appear
-# in specific situations, spaces_after_close_brace are only after some
-# commands and not first in contents, while spaces_at_end are before commands
-# and not at the end of contents. Spaces will also be in 'info'
-# if at the end of contents/line.
-# Also this code is not often called, likely because it is not useful with
-# the current tree.
-# In 2023, nothing was trimmed in the test suite.
-sub trim_spaces_comment_from_content($)
-{
-  my $element = shift;
-
-  return undef if (!$element->{'contents'});
-
-  my $contents_nr = scalar(@{$element->{'contents'}});
-
-  if ($contents_nr) {
-    # index to start from, from the beginning
-    my $i = 0;
-    for ( ; $i < $contents_nr; $i++) {
-      my $content = $element->{'contents'}->[$i];
-      if (not defined ($content->{'type'})
-          or ($content->{'type'} ne 'ignorable_spaces_after_command'
-              and $content->{'type'} ne 'spaces_after_close_brace')) {
-        last;
-      #} else {
-      #  print STDERR "TRIMMED b\n";
-      }
-    }
-
-    # index to end at, from the end
-    my $j = $contents_nr - 1;
-    for ( ; $j >= 0; $j--) {
-      my $content = $element->{'contents'}->[$j];
-
-      if (($content->{'cmdname'}
-          and ($content->{'cmdname'} eq 'c'
-               or $content->{'cmdname'} eq 'comment'))
-          or ($content->{'type'}
-              and $content->{'type'} eq 'spaces_at_end')) {
-        # nothing to do
-        #print STDERR "TRIMMED l\n";
-      } else {
-        last;
-      }
-    }
-
-    if ($j < $i) {
-      return undef;
-    } else {
-      return {'contents' => [@{$element->{'contents'}}[$i..$j]]};
-    }
-  }
-  return undef;
-}
-
 # decompose a decimal number on a given base.  It is not the
 # decomposition used for counting as we start at 0, not 1 for all
 # the factors.  This is in order to get aa and not ba in calling
@@ -1650,11 +1593,7 @@ sub split_custom_heading_command_contents($)
 
   my $nr_split_contents = 0;
 
-  my $trimmed_element = trim_spaces_comment_from_content($element);
-
-  return $result if (!$trimmed_element);
-
-  my $contents_nr = scalar(@{$trimmed_element->{'contents'}});
+  my $contents_nr = scalar(@{$element->{'contents'}});
 
   if (!$contents_nr) {
     return $result;
@@ -1665,7 +1604,7 @@ sub split_custom_heading_command_contents($)
   push @{$result->{'contents'}}, $heading_element;
 
   for (my $i = 0; $i < $contents_nr; $i++) {
-    my $current_content = $trimmed_element->{'contents'}->[$i];
+    my $current_content = $element->{'contents'}->[$i];
     #print STDERR "$nr_split_contents : "
     #          .debug_print_element($current_content)."\n";
     if (defined($current_content->{'cmdname'})
@@ -3074,13 +3013,6 @@ the I<$element> has no useful content.  The input 
I<$element>
 is supposed to be C<< $element->{'args'}->[0] >>
 of C<%Texinfo::Commands::heading_spec_commands> commands such as 
C<@everyheading>.
 
-=item $trimmed_element = trim_spaces_comment_from_content($element)
-X<C<trim_spaces_comment_from_content>>
-
-Return an element with contents from I<$element>, with empty spaces after
-commands or braces at begin and spaces and comments at end removed.  Return
-C<undef> if there are no remaining contents.
-
 =item $status = valid_customization_option($name)
 X<C<valid_option>>
 
diff --git a/tp/Texinfo/XS/main/utils.c b/tp/Texinfo/XS/main/utils.c
index e86fddc63c..2a04c0f165 100644
--- a/tp/Texinfo/XS/main/utils.c
+++ b/tp/Texinfo/XS/main/utils.c
@@ -1190,59 +1190,6 @@ is_content_empty (ELEMENT *tree, int 
do_not_ignore_index_entries)
   return 1;
 }
 
-/*
-  NOTE this code does nothing with the current tree, as comments
-  are in 'info' 'comment_at_end', ignorable_spaces_after_command only appear
-  in specific situations, spaces_after_close_brace are only after some
-  commands and not first in contents, while spaces_at_end are before commands
-  and not at the end of contents. Spaces will also be in 'info'
-  if at the end of contents/line.
-  Also this code is not often called, likely because it is not useful with
-  the current tree.
-  In 2023, nothing was trimmed in the test suite.
- */
-ELEMENT *
-trim_spaces_comment_from_content (ELEMENT *element)
-{
-  if (element->contents.number <= 0)
-    return 0;
-
-  if (element->contents.number > 0)
-    {
-      int i, j;
-
-      /* index to start from, from the beginning */
-      for (i = 0; i < element->contents.number; i++)
-        {
-          ELEMENT *content = element->contents.list[i];
-          if (!content->type
-              || (content->type != ET_ignorable_spaces_after_command
-                  && content->type != ET_spaces_after_close_brace))
-            break;
-        }
-
-      for (j = element->contents.number -1; j >= 0; j--)
-        {
-          ELEMENT *content = element->contents.list[j];
-          if ((content->cmd == CM_c || content->cmd == CM_comment)
-              || content->type == ET_spaces_at_end)
-            {}
-          else
-            break;
-        }
-
-      if (j < i)
-        return 0;
-      else
-        {
-          ELEMENT *result = new_element (ET_NONE);
-          insert_slice_into_contents (result, 0, element, i, j);
-          return result;
-        }
-    }
-  return 0;
-}
-
 /*
   decompose a decimal number on a given base.  It is not the
   decomposition used for counting as we start at 0, not 1 for all
diff --git a/tp/Texinfo/XS/main/utils.h b/tp/Texinfo/XS/main/utils.h
index c695cdcef2..354d4d0f88 100644
--- a/tp/Texinfo/XS/main/utils.h
+++ b/tp/Texinfo/XS/main/utils.h
@@ -269,8 +269,6 @@ void clear_expanded_formats (EXPANDED_FORMAT *formats);
 void add_expanded_format (EXPANDED_FORMAT *formats, char *format);
 int format_expanded_p (EXPANDED_FORMAT *formats, char *format);
 
-ELEMENT *trim_spaces_comment_from_content (ELEMENT *element);
-
 char *enumerate_item_representation (char *specification, int number);
 
 CONVERTER *new_converter (void);
diff --git a/tp/t/init/translation_in_parser_in_translation.pm 
b/tp/t/init/translation_in_parser_in_translation.pm
index c7d18739fd..16b7d26a5a 100644
--- a/tp/t/init/translation_in_parser_in_translation.pm
+++ b/tp/t/init/translation_in_parser_in_translation.pm
@@ -79,16 +79,11 @@ sub _texi2any_tests_def_line_show_id($$$$)
   my $entry_reference_content_element
         = Texinfo::Common::index_content_element($element);
 
-  # note that in case of definition line, the translated element
-  # put in extra as index entry element has no associated spaces.
-  my $trimmed_element
-   = Texinfo::Common::trim_spaces_comment_from_content(
-                                $entry_reference_content_element);
   my $normalized_index = '';
-  if ($trimmed_element) {
+  if ($entry_reference_content_element) {
     $normalized_index =
      Texinfo::Convert::NodeNameNormalization::normalize_transliterate_texinfo(
-        $trimmed_element, $no_unidecode);
+        $entry_reference_content_element, $no_unidecode);
   }
   my $target_base = "index-" . $region .$normalized_index;
 



reply via email to

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