texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/Texinfo/ParserNonXS.pm (_end_line_misc_line)


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/ParserNonXS.pm (_end_line_misc_line), tp/Texinfo/Convert/Texinfo.pm (convert_to_texinfo) (_expand_cmd_args_to_texi), tp/Texinfo/Convert/TexinfoMarkup.pm (%ignored_types, %ignored_types): do not set replaced type on included files element, use a variable set it a file was included. Remove completely the replaced type.
Date: Sun, 08 Jan 2023 03:34:50 -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 4699667861 * tp/Texinfo/ParserNonXS.pm (_end_line_misc_line), 
tp/Texinfo/Convert/Texinfo.pm (convert_to_texinfo) (_expand_cmd_args_to_texi), 
tp/Texinfo/Convert/TexinfoMarkup.pm (%ignored_types, %ignored_types): do not 
set replaced type on included files element, use a variable set it a file was 
included.  Remove completely the replaced type.
4699667861 is described below

commit 4699667861ed85c0754775e0ee91cf45f49f4ebc
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Jan 8 09:34:39 2023 +0100

    * tp/Texinfo/ParserNonXS.pm (_end_line_misc_line),
    tp/Texinfo/Convert/Texinfo.pm (convert_to_texinfo)
    (_expand_cmd_args_to_texi), tp/Texinfo/Convert/TexinfoMarkup.pm
    (%ignored_types, %ignored_types): do not set replaced type on included
    files element, use a variable set it a file was included.  Remove
    completely the replaced type.
    
    * tp/Texinfo/ParserNonXS.pm (_input_push_text),
    tp/Texinfo/XS/parsetexi/input.c (input_push_text): rename input_push as
    input_push_text.  Update the callers.
---
 ChangeLog                                 | 13 ++++++++
 tp/Texinfo/Convert/Texinfo.pm             | 21 +++++--------
 tp/Texinfo/Convert/TexinfoMarkup.pm       |  9 ------
 tp/Texinfo/ParserNonXS.pm                 | 52 ++++++++++---------------------
 tp/Texinfo/XS/parsetexi/api.c             |  6 ++--
 tp/Texinfo/XS/parsetexi/handle_commands.c |  2 +-
 tp/Texinfo/XS/parsetexi/input.c           |  2 +-
 tp/Texinfo/XS/parsetexi/input.h           |  3 +-
 tp/Texinfo/XS/parsetexi/macro.c           |  5 +--
 tp/Texinfo/XS/parsetexi/parser.c          | 14 ++++-----
 10 files changed, 55 insertions(+), 72 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b7c3591444..0156e4a215 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2023-01-08  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/ParserNonXS.pm (_end_line_misc_line),
+       tp/Texinfo/Convert/Texinfo.pm (convert_to_texinfo)
+       (_expand_cmd_args_to_texi), tp/Texinfo/Convert/TexinfoMarkup.pm
+       (%ignored_types, %ignored_types): do not set replaced type on included
+       files element, use a variable set it a file was included.  Remove
+       completely the replaced type.
+
+       * tp/Texinfo/ParserNonXS.pm (_input_push_text),
+       tp/Texinfo/XS/parsetexi/input.c (input_push_text): rename input_push as
+       input_push_text.  Update the callers.
+
 2023-01-07  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/parsetexi/input.c (input_push),
diff --git a/tp/Texinfo/Convert/Texinfo.pm b/tp/Texinfo/Convert/Texinfo.pm
index 54d50cb6ab..fd0837b7bb 100644
--- a/tp/Texinfo/Convert/Texinfo.pm
+++ b/tp/Texinfo/Convert/Texinfo.pm
@@ -100,11 +100,10 @@ sub root_heading_command_to_texinfo($)
 # tree item to be shown, in the default case they are
 # not shown.
 # expand a tree to the corresponding texinfo.
-sub convert_to_texinfo($;$);
-sub convert_to_texinfo($;$)
+sub convert_to_texinfo($);
+sub convert_to_texinfo($)
 {
   my $element = shift;
-  my $expand_replaced = shift;
 
   confess "convert_to_texinfo: element undef" if (!defined($element));
   confess "convert_to_texinfo: bad element type (".ref($element).") $element"
@@ -112,9 +111,7 @@ sub convert_to_texinfo($;$)
   my $result = '';
 
   return '' if ($element->{'type'}
-                and ($ignored_types{$element->{'type'}}
-                     or ($element->{'type'} eq 'replaced'
-                         and not $expand_replaced)));
+                and ($ignored_types{$element->{'type'}}));
   if (defined($element->{'text'})) {
     $result .= $element->{'text'};
   } else {
@@ -122,7 +119,7 @@ sub convert_to_texinfo($;$)
        or ($element->{'type'} and ($element->{'type'} eq 'def_line'
                                 or $element->{'type'} eq 'menu_entry'
                                 or $element->{'type'} eq 'menu_comment'))) {
-      $result .= _expand_cmd_args_to_texi($element, $expand_replaced);
+      $result .= _expand_cmd_args_to_texi($element);
     }
     if ($element->{'type'}
         and ($element->{'type'} eq 'bracketed'
@@ -135,15 +132,14 @@ sub convert_to_texinfo($;$)
     }
     if (defined($element->{'contents'})) {
       foreach my $child (@{$element->{'contents'}}) {
-        $result .= convert_to_texinfo($child, $expand_replaced);
+        $result .= convert_to_texinfo($child);
       }
     }
     if ($element->{'info'} and $element->{'info'}->{'spaces_after_argument'}) {
       $result .= $element->{'info'}->{'spaces_after_argument'};
     }
     if ($element->{'info'} and $element->{'info'}->{'comment_at_end'}) {
-      $result .= convert_to_texinfo($element->{'info'}->{'comment_at_end'},
-                         $expand_replaced);
+      $result .= convert_to_texinfo($element->{'info'}->{'comment_at_end'})
     }
     $result .= '}' if ($element->{'type'}
                        and ($element->{'type'} eq 'bracketed'
@@ -153,9 +149,8 @@ sub convert_to_texinfo($;$)
 }
 
 # expand a command argument as texinfo.
-sub _expand_cmd_args_to_texi($;$) {
+sub _expand_cmd_args_to_texi($) {
   my $cmd = shift;
-  my $expand_replaced = shift;
 
   my $cmdname = $cmd->{'cmdname'};
   $cmdname = '' if (!$cmd->{'cmdname'});
@@ -176,7 +171,7 @@ sub _expand_cmd_args_to_texi($;$) {
      $result .= $cmd->{'info'}->{'spaces_before_argument'}
        if $cmd->{'info'} and $cmd->{'info'}->{'spaces_before_argument'};
      foreach my $arg (@{$cmd->{'args'}}) {
-        $result .= convert_to_texinfo($arg, $expand_replaced);
+        $result .= convert_to_texinfo($arg);
     }
   # arg_line set for line_commands with type special and @macro
   } elsif ($cmd->{'info'} and defined($cmd->{'info'}->{'arg_line'})) {
diff --git a/tp/Texinfo/Convert/TexinfoMarkup.pm 
b/tp/Texinfo/Convert/TexinfoMarkup.pm
index 13f1458d72..850dc299fd 100644
--- a/tp/Texinfo/Convert/TexinfoMarkup.pm
+++ b/tp/Texinfo/Convert/TexinfoMarkup.pm
@@ -232,14 +232,6 @@ my %defcommand_name_type = (
  'deftp'     => 'datatype',
 );
 
-my %ignored_types;
-foreach my $type (
-            # @-commands replaced in the tree
-            'replaced',
-  ) {
-  $ignored_types{$type} = 1;
-}
-
 my %type_elements = (
   'paragraph' => 'para',
   'preformatted' => 'pre',
@@ -613,7 +605,6 @@ sub _convert($$;$)
     #  if (defined($element->{'extra'}) and 
$element->{'extra'}->{'def_command'});
   }
 
-  return '' if ($element->{'type'} and $ignored_types{$element->{'type'}});
   if (defined($element->{'text'})) {
     if ($self->{'document_context'}->[-1]->{'raw'}) {
       return $element->{'text'};
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index b78f8d0446..6a97c08a64 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -788,7 +788,7 @@ sub _new_text_input($$)
           'input_source_info' => $input_source_info};
 }
 
-sub _input_push($$$;$$)
+sub _input_push_text($$$;$$)
 {
   my ($self, $text, $line_nr, $macro_name, $value_name) = @_;
 
@@ -819,11 +819,6 @@ sub _input_pushback_text($$;$)
   my ($self, $text, $line_nr) = @_;
 
   if (defined($text) and $text ne '') {
-    ## should not happen in current code
-    #if (not $self->{'input'} or not scalar(@{$self->{'input'}})) {
-    #  $line_nr = 1 if (!defined($line_nr));
-    #  _input_push($self, $text, $line_nr);
-    #}
     my $text_input = _new_text_input($text,
                           $self->{'input'}->[0]->{'input_source_info'});
     unshift @{$self->{'input'}}, $text_input;
@@ -844,7 +839,7 @@ sub parse_texi_piece($$;$)
 
   $self = parser() if (!defined($self));
 
-  _input_push($self, $text, $line_nr);
+  _input_push_text($self, $text, $line_nr);
 
   my ($document_root, $before_node_section)
      = _setup_document_root_and_before_node_section();
@@ -863,7 +858,7 @@ sub parse_texi_line($$;$)
 
   $self = parser() if (!defined($self));
 
-  _input_push($self, $text, $line_nr);
+  _input_push_text($self, $text, $line_nr);
 
   my $root = {'type' => 'root_line'};
   my $tree = $self->_parse_texi($root, $root);
@@ -880,7 +875,7 @@ sub parse_texi_text($$;$)
 
   $self = parser() if (!defined($self));
 
-  _input_push($self, $text, $line_nr);
+  _input_push_text($self, $text, $line_nr);
 
   return $self->_parse_texi_document();
 }
@@ -2995,6 +2990,7 @@ sub _end_line_misc_line($$$)
   my $misc_cmd = $current;
   my $command = $current->{'cmdname'};
   my $end_command;
+  my $included_file;
   print STDERR "MISC END \@$command: $self->{'line_commands'}->{$command}\n"
      if ($self->{'DEBUG'});
 
@@ -3063,23 +3059,18 @@ sub _end_line_misc_line($$$)
         if (defined($file)) {
           my $filehandle = do { local *FH };
           if (_open_in ($self, $filehandle, $file)) {
+            $included_file = 1;
             print STDERR "Included $file($filehandle)\n" if ($self->{'DEBUG'});
             my ($directories, $suffix);
             ($file, $directories, $suffix) = fileparse($file);
             unshift @{$self->{'input'}}, {
+              # note that it is bytes
               'input_source_info' => {'file_name' => $file,
                                 'line_nr' => 0,
                                 'macro' => '',
                                },
               'file_name_encoding' => $file_name_encoding,
               'fh' => $filehandle };
-            # TODO note that it is bytes.  No reason to have it used much
-            # Make sure to document that it is bytes.
-            # TODO add $file_name_encoding information?
-            $current->{'extra'}->{'file'} = $file;
-            # we set the type to replaced to tell converters not to
-            # expand the @-command
-            $current->{'type'} = 'replaced';
           } else {
             # FIXME $text does not show the include directory.  Using $file
             # would require to decode it to perl internal codepoints with
@@ -3134,11 +3125,8 @@ sub _end_line_misc_line($$$)
       }
     }
     if ($superfluous_arg) {
-      # note that the argument to expand replaced @-commands is
-      # set, such that @include that are removed from the tree
-      # with type set to replaced are still shown in error messages.
       my $texi_line
-        = 
Texinfo::Convert::Texinfo::convert_to_texinfo($current->{'args'}->[0], 1);
+        = 
Texinfo::Convert::Texinfo::convert_to_texinfo($current->{'args'}->[0]);
       $texi_line =~ s/^\s*//;
       $texi_line =~ s/\s*$//;
 
@@ -3259,14 +3247,8 @@ sub _end_line_misc_line($$$)
       if ($close_preformatted_commands{$command});
   }
   # Ignore @setfilename in included file, as said in the manual.
-  if (($command eq 'setfilename'
-         and _in_include($self))
-    # TODO remove this condition if/when the XS parser has been updated
-    # to output @include with type replaced when the file was found
-      or ($current->{'contents'} and scalar(@{$current->{'contents'}})
-           and exists($current->{'contents'}->[-1]->{'type'})
-           and $current->{'contents'}->[-1]->{'type'} eq 'replaced')) {
-    # TODO keep the information
+  if ($included_file
+      or ($command eq 'setfilename' and _in_include($self))) {
     pop @{$current->{'contents'}};
   } elsif ($command eq 'setfilename'
            and ($self->{'current_node'} or $self->{'current_section'})) {
@@ -4447,11 +4429,11 @@ sub _process_remaining_on_line($$$$)
         if ($self->{'DEBUG'});
       # first put the line that was interrupted by the macro call
       # on the input pending text with information stack
-      _input_push($self, $line, $source_info->{'line_nr'});
+      _input_push_text($self, $line, $source_info->{'line_nr'});
       # then put the following macro expansion lines with information on the
       # pending text
-      _input_push($self, $expanded, $source_info->{'line_nr'},
-                  $expanded_macro->{'args'}->[0]->{'text'});
+      _input_push_text($self, $expanded, $source_info->{'line_nr'},
+                       $expanded_macro->{'args'}->[0]->{'text'});
       $line = '';
       goto funexit;
     }
@@ -4477,10 +4459,10 @@ sub _process_remaining_on_line($$$$)
             goto funexit;
           }
           unshift @{$self->{'value_stack'}}, $value;
-          _input_push($self, $remaining_line, $source_info->{'line_nr'},
-                      $source_info->{'macro'});
-          _input_push($self, $self->{'values'}->{$value},
-                      $source_info->{'line_nr'}, $source_info->{'macro'}, 
$value);
+          _input_push_text($self, $remaining_line, $source_info->{'line_nr'},
+                           $source_info->{'macro'});
+          _input_push_text($self, $self->{'values'}->{$value},
+                           $source_info->{'line_nr'}, $source_info->{'macro'}, 
$value);
           $line = '';
           goto funexit;
         }
diff --git a/tp/Texinfo/XS/parsetexi/api.c b/tp/Texinfo/XS/parsetexi/api.c
index 04aa654906..998ddd53f2 100644
--- a/tp/Texinfo/XS/parsetexi/api.c
+++ b/tp/Texinfo/XS/parsetexi/api.c
@@ -212,7 +212,7 @@ void
 parse_text (char *string, int line_nr)
 {
   reset_parser_except_conf ();
-  input_push (strdup (string), line_nr, 0, 0);
+  input_push_text (strdup (string), line_nr, 0, 0);
   Root = parse_texi_document ();
 }
 
@@ -224,7 +224,7 @@ parse_string (char *string, int line_nr)
   ELEMENT *root_elt = new_element (ET_root_line);
 
   reset_parser_except_conf ();
-  input_push (strdup (string), line_nr, 0, 0);
+  input_push_text (strdup (string), line_nr, 0, 0);
   Root = parse_texi (root_elt, root_elt);
 }
 
@@ -236,7 +236,7 @@ parse_piece (char *string, int line_nr)
   ELEMENT *document_root = before_node_section->parent;
 
   reset_parser_except_conf ();
-  input_push (strdup (string), line_nr, 0, 0);
+  input_push_text (strdup (string), line_nr, 0, 0);
   Root = parse_texi (document_root, before_node_section);
 }
 
diff --git a/tp/Texinfo/XS/parsetexi/handle_commands.c 
b/tp/Texinfo/XS/parsetexi/handle_commands.c
index 2406096cf3..52b68fd6b4 100644
--- a/tp/Texinfo/XS/parsetexi/handle_commands.c
+++ b/tp/Texinfo/XS/parsetexi/handle_commands.c
@@ -353,7 +353,7 @@ handle_line_command (ELEMENT *current, char **line_inout,
           char *line2;
           SOURCE_INFO save_src_info; 
 
-          input_push (strdup (line), current_source_info.line_nr, 0, 0);
+          input_push_text (strdup (line), current_source_info.line_nr, 0, 0);
 
           save_src_info = current_source_info;
           line2 = new_line ();
diff --git a/tp/Texinfo/XS/parsetexi/input.c b/tp/Texinfo/XS/parsetexi/input.c
index 45fa5d12ad..454a5adadf 100644
--- a/tp/Texinfo/XS/parsetexi/input.c
+++ b/tp/Texinfo/XS/parsetexi/input.c
@@ -496,7 +496,7 @@ next_text (void)
    string.  TEXT will be later free'd and must be allocated on the heap.
    MACRO is the name of a macro that the text came from. */
 void
-input_push (char *text, int line_number, char *macro, char *value_flag)
+input_push_text (char *text, int line_number, char *macro, char *value_flag)
 {
   char *filename = 0;
 
diff --git a/tp/Texinfo/XS/parsetexi/input.h b/tp/Texinfo/XS/parsetexi/input.h
index ba13ca42a0..5fad1ad577 100644
--- a/tp/Texinfo/XS/parsetexi/input.h
+++ b/tp/Texinfo/XS/parsetexi/input.h
@@ -9,7 +9,8 @@ char *next_text (void);
 
 void save_line_directive (int line_nr, char *filename);
 
-void input_push (char *text, int line_number, char *macro, char *value_flag);
+void input_push_text (char *text, int line_number, char *macro,
+                      char *value_flag);
 int input_push_file (char *filename);
 void input_pushback (char *line);
 void input_reset_input_stack (void);
diff --git a/tp/Texinfo/XS/parsetexi/macro.c b/tp/Texinfo/XS/parsetexi/macro.c
index efe142ce14..be930e0999 100644
--- a/tp/Texinfo/XS/parsetexi/macro.c
+++ b/tp/Texinfo/XS/parsetexi/macro.c
@@ -595,9 +595,10 @@ handle_macro (ELEMENT *current, char **line_inout, enum 
command_id cmd)
 
   /* Put expansion in front of the current line. */
   macro_expansion_nr++;
-  input_push (strdup (line), current_source_info.line_nr, 0, 0);
+  input_push_text (strdup (line), current_source_info.line_nr, 0, 0);
   line = strchr (line, '\0');
-  input_push (expanded.text, current_source_info.line_nr, command_name(cmd), 
0);
+  input_push_text (expanded.text, current_source_info.line_nr,
+                   command_name(cmd), 0);
 
 funexit:
   *line_inout = line;
diff --git a/tp/Texinfo/XS/parsetexi/parser.c b/tp/Texinfo/XS/parsetexi/parser.c
index 7039f98a6a..bdb8d78904 100644
--- a/tp/Texinfo/XS/parsetexi/parser.c
+++ b/tp/Texinfo/XS/parsetexi/parser.c
@@ -1584,13 +1584,13 @@ superfluous_arg:
                           goto funexit;
                         }
 
-                      input_push (strdup (remaining_line),
-                                  current_source_info.line_nr,
-                                  current_source_info.macro, 0);
-                      input_push (strdup (value),
-                                  current_source_info.line_nr,
-                                  current_source_info.macro,
-                                  strdup(flag));
+                      input_push_text (strdup (remaining_line),
+                                       current_source_info.line_nr,
+                                       current_source_info.macro, 0);
+                      input_push_text (strdup (value),
+                                       current_source_info.line_nr,
+                                       current_source_info.macro,
+                                       strdup(flag));
                       value_expansion_nr++;
 
                       /* Move 'line' to end of string so next input to



reply via email to

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