[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/ParserNonXS.pm (_input_push), tp/Tex
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/ParserNonXS.pm (_input_push), tp/Texinfo/XS/parsetexi/api.c, tp/Texinfo/XS/parsetexi/handle_commands.c, tp/Texinfo/XS/parsetexi/input.c (input_push), tp/Texinfo/XS/parsetexi/parser.c: change the order of input_push arguments. Get the filename from the input stack in input_push. Remove input_push_text and input_push_text_with_line_nos, call directly input_push. Update callers. |
Date: |
Sat, 07 Jan 2023 13:19:11 -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 ef60886eab * tp/Texinfo/ParserNonXS.pm (_input_push),
tp/Texinfo/XS/parsetexi/api.c, tp/Texinfo/XS/parsetexi/handle_commands.c,
tp/Texinfo/XS/parsetexi/input.c (input_push), tp/Texinfo/XS/parsetexi/parser.c:
change the order of input_push arguments. Get the filename from the input
stack in input_push. Remove input_push_text and input_push_text_with_line_nos,
call directly input_push. Update callers.
ef60886eab is described below
commit ef60886eab51d316e42582ab87859aea0d330eaf
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Jan 7 19:18:26 2023 +0100
* tp/Texinfo/ParserNonXS.pm (_input_push),
tp/Texinfo/XS/parsetexi/api.c,
tp/Texinfo/XS/parsetexi/handle_commands.c,
tp/Texinfo/XS/parsetexi/input.c (input_push),
tp/Texinfo/XS/parsetexi/parser.c: change the order of
input_push arguments. Get the filename from the input stack in
input_push. Remove input_push_text and input_push_text_with_line_nos,
call directly input_push. Update callers.
* tp/Texinfo/XS/parsetexi/Parsetexi.pm: simplify arguments passing
to parse_texi_*. Change variable name, remove comments.
---
ChangeLog | 14 ++++++
tp/Texinfo/ParserNonXS.pm | 74 ++++++++++++++-----------------
tp/Texinfo/XS/parsetexi/Parsetexi.pm | 47 ++++++--------------
tp/Texinfo/XS/parsetexi/api.c | 6 +--
tp/Texinfo/XS/parsetexi/handle_commands.c | 2 +-
tp/Texinfo/XS/parsetexi/input.c | 41 ++++++-----------
tp/Texinfo/XS/parsetexi/input.h | 4 +-
tp/Texinfo/XS/parsetexi/macro.c | 4 +-
tp/Texinfo/XS/parsetexi/parser.c | 8 +++-
9 files changed, 87 insertions(+), 113 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 91b7c76c56..e2ab0079f5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -9,6 +9,20 @@
command is issued later in a document, as in
doc/texinfo-tex-test.texi.
+2023-01-07 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/ParserNonXS.pm (_input_push),
+ tp/Texinfo/XS/parsetexi/api.c,
+ tp/Texinfo/XS/parsetexi/handle_commands.c,
+ tp/Texinfo/XS/parsetexi/input.c (input_push),
+ tp/Texinfo/XS/parsetexi/parser.c: change the order of
+ input_push arguments. Get the filename from the input stack in
+ input_push. Remove input_push_text and input_push_text_with_line_nos,
+ call directly input_push. Update callers.
+
+ * tp/Texinfo/XS/parsetexi/Parsetexi.pm: simplify arguments passing
+ to parse_texi_*. Change variable name, remove comments.
+
2023-01-07 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/ParserNonXS.pm (_next_text, _new_line): do not get a
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index 775ce0c93c..9d343df133 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -788,16 +788,25 @@ sub _new_text_input($$)
'input_source_info' => $input_source_info};
}
-sub _input_push($$$$$;$)
+sub _input_push($$$;$$)
{
- my ($self, $text, $macro_name, $filename, $line_nr, $value_name) = @_;
+ my ($self, $text, $line_nr, $macro_name, $value_name) = @_;
- $self->{'input'} = [] if (not $self->{'input'});
+ my $filename;
+ if (not $self->{'input'}) {
+ $self->{'input'} = [];
+ }
my $input_source_info = {'line_nr' => $line_nr, 'macro' => '',
- 'file_name' => ''};
+ 'file_name' => ''};
+ if (scalar(@{$self->{'input'}})) {
+ $input_source_info->{'file_name'}
+ = $self->{'input'}->[0]->{'input_source_info'}->{'file_name'};
+ }
if (defined($macro_name)) {
$input_source_info->{'macro'} = $macro_name;
} elsif (not defined($value_name)) {
+ # this counteracts the increment that would follow from the next
+ # call to _next_text.
$input_source_info->{'line_nr'} -= 1;
}
$input_source_info->{'file_name'} = $filename if (defined($filename));
@@ -806,19 +815,6 @@ sub _input_push($$$$$;$)
unshift @{$self->{'input'}}, $text_input;
}
-sub _input_push_text_with_line_nos($$;$)
-{
- my ($self, $text, $line_nr) = @_;
-
- return 0 if (!defined($text));
-
- if (not defined($line_nr)) {
- $line_nr = 1;
- }
- _input_push($self, $text, undef, undef, $line_nr);
- return 1;
-}
-
# push text sharing the same input_source_info as current top input
sub _input_pushback_text($$;$)
{
@@ -828,7 +824,7 @@ sub _input_pushback_text($$;$)
## should not happen in current code
#if (not $self->{'input'} or not scalar(@{$self->{'input'}})) {
# $line_nr = 1 if (!defined($line_nr));
- # _input_push_text($self, $text, $line_nr);
+ # _input_push($self, $text, $line_nr);
#}
my $text_input = _new_text_input($text,
$self->{'input'}->[0]->{'input_source_info'});
@@ -838,29 +834,19 @@ sub _input_pushback_text($$;$)
}
}
-sub _input_push_text($$$;$$)
-{
- my ($self, $text, $line_nr, $macro_name, $value_name) = @_;
-
- if (defined($text) and $text ne '') {
- my $filename = undef;
- if (scalar(@{$self->{'input'}})) {
- $filename = $self->{'input'}->[0]->{'input_source_info'}->{'file_name'};
- }
- _input_push($self, $text, $macro_name, $filename,
- $line_nr, $value_name);
- }
-}
-
# entry point for text fragments.
# Used in some tests.
sub parse_texi_piece($$;$)
{
my ($self, $text, $line_nr) = @_;
+ return undef if (!defined($text));
+
+ $line_nr = 1 if (not defined($line_nr));
+
$self = parser() if (!defined($self));
- return undef unless (_input_push_text_with_line_nos($self, $text, $line_nr));
+ _input_push($self, $text, $line_nr);
my ($document_root, $before_node_section)
= _setup_document_root_and_before_node_section();
@@ -873,9 +859,13 @@ sub parse_texi_line($$;$)
{
my ($self, $text, $line_nr) = @_;
+ return undef if (!defined($text));
+
+ $line_nr = 1 if (not defined($line_nr));
+
$self = parser() if (!defined($self));
- return undef unless (_input_push_text_with_line_nos($self, $text, $line_nr));
+ _input_push($self, $text, $line_nr);
my $root = {'type' => 'root_line'};
my $tree = $self->_parse_texi($root, $root);
@@ -886,9 +876,13 @@ sub parse_texi_text($$;$)
{
my ($self, $text, $line_nr) = @_;
+ return undef if (!defined($text));
+
+ $line_nr = 1 if (not defined($line_nr));
+
$self = parser() if (!defined($self));
- return undef unless (_input_push_text_with_line_nos($self, $text, $line_nr));
+ _input_push($self, $text, $line_nr);
return $self->_parse_texi_document();
}
@@ -4459,11 +4453,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_text($self, $line, $source_info->{'line_nr'});
+ _input_push($self, $line, $source_info->{'line_nr'});
# then put the following macro expansion lines with information on the
# pending text
- _input_push_text($self, $expanded, $source_info->{'line_nr'},
- $expanded_macro->{'args'}->[0]->{'text'});
+ _input_push($self, $expanded, $source_info->{'line_nr'},
+ $expanded_macro->{'args'}->[0]->{'text'});
$line = '';
goto funexit;
}
@@ -4489,8 +4483,8 @@ sub _process_remaining_on_line($$$$)
goto funexit;
}
unshift @{$self->{'value_stack'}}, $value;
- _input_push_text($self, $expanded_line, $source_info->{'line_nr'},
- $source_info->{'macro'}, $value);
+ _input_push($self, $expanded_line, $source_info->{'line_nr'},
+ $source_info->{'macro'}, $value);
$line = $self->{'values'}->{$value};
goto funexit;
}
diff --git a/tp/Texinfo/XS/parsetexi/Parsetexi.pm
b/tp/Texinfo/XS/parsetexi/Parsetexi.pm
index 840fa89c6d..73f27a221a 100644
--- a/tp/Texinfo/XS/parsetexi/Parsetexi.pm
+++ b/tp/Texinfo/XS/parsetexi/Parsetexi.pm
@@ -245,7 +245,6 @@ sub get_parser_info {
use File::Basename; # for fileparse
-# Replacement for Texinfo::Parser::parse_texi_file
sub parse_texi_file ($$)
{
my $self = shift;
@@ -303,21 +302,14 @@ sub _get_errors($)
}
-# Replacement for Texinfo::Parser::parse_texi_piece
-#
# Used in tests under tp/t.
-sub parse_texi_piece($$;$$$$)
+sub parse_texi_piece($$;$)
{
- my $self = shift;
- my $text = shift;
- my $lines_nr = shift;
- my $file = shift;
- my $macro = shift;
- my $fixed_line_number = shift;
+ my ($self, $text, $line_nr) = @_;
return undef if (!defined($text));
- $lines_nr = 1 if (not defined($lines_nr));
+ $line_nr = 1 if (not defined($line_nr));
$self = parser() if (!defined($self));
@@ -325,7 +317,7 @@ sub parse_texi_piece($$;$$$$)
# it in to the XS code.
utf8::upgrade($text);
- parse_piece($text, $lines_nr);
+ parse_piece($text, $line_nr);
my $tree = build_texinfo_tree ();
get_parser_info($self);
@@ -334,21 +326,14 @@ sub parse_texi_piece($$;$$$$)
return $tree;
}
-# Replacement for Texinfo::Parser::parse_texi_text
-#
# Used in tests under tp/t.
-sub parse_texi_text($$;$$$$)
+sub parse_texi_text($$;$)
{
- my $self = shift;
- my $text = shift;
- my $lines_nr = shift;
- my $file = shift;
- my $macro = shift;
- my $fixed_line_number = shift;
+ my ($self, $text, $line_nr) = @_;
return undef if (!defined($text));
- $lines_nr = 1 if (not defined($lines_nr));
+ $line_nr = 1 if (not defined($line_nr));
$self = parser() if (!defined($self));
@@ -356,7 +341,7 @@ sub parse_texi_text($$;$$$$)
# it in to the XS code.
utf8::upgrade($text);
- parse_text($text, $lines_nr);
+ parse_text($text, $line_nr);
my $tree = build_texinfo_tree ();
get_parser_info($self);
@@ -369,23 +354,17 @@ sub parse_texi_text($$;$$$$)
return $tree;
}
-# Replacement for Texinfo::Parser::parse_texi_line
-sub parse_texi_line($$;$$$$)
+sub parse_texi_line($$;$)
{
- my $self = shift;
- my $text = shift;
- my $lines_nr = shift;
- my $file = shift;
- my $macro = shift;
- my $fixed_line_number = shift;
+ my ($self, $text, $line_nr) = @_;
return undef if (!defined($text));
- $lines_nr = 1 if (not defined($lines_nr));
+ $line_nr = 1 if (not defined($line_nr));
$self = parser() if (!defined($self));
utf8::upgrade($text);
- parse_string($text, $lines_nr);
+ parse_string($text, $line_nr);
my $tree = build_texinfo_tree ();
_set_errors_node_lists_labels_indices($self);
@@ -393,7 +372,7 @@ sub parse_texi_line($$;$$$$)
return $tree;
}
-# Public interfaces of Texinfo::Parser
+# Public interfaces of Texinfo::Parser to gather information
sub indices_information($)
{
my $self = shift;
diff --git a/tp/Texinfo/XS/parsetexi/api.c b/tp/Texinfo/XS/parsetexi/api.c
index a54707632f..08041b26e6 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_text_with_line_nos (strdup (string), line_nr);
+ input_push (strdup (string), line_nr, 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_text_with_line_nos (strdup (string), line_nr);
+ input_push (strdup (string), line_nr, 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_text_with_line_nos (strdup (string), line_nr);
+ input_push (strdup (string), line_nr, 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 88563448a9..8dfdcc1ba1 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_text (strdup (line), 0);
+ input_push (strdup (line), current_source_info.line_nr, 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 c8730b4d6a..e8cd70fce5 100644
--- a/tp/Texinfo/XS/parsetexi/input.c
+++ b/tp/Texinfo/XS/parsetexi/input.c
@@ -481,9 +481,17 @@ next_text (void)
return 0;
}
+/* Store TEXT as a source for Texinfo content. TEXT should be a UTF-8
+ 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, char *macro, char *filename, int line_number)
+input_push (char *text, int line_number, char *macro)
{
+ char *filename = 0;
+
+ if (!text)
+ return;
+
if (input_number == input_space)
{
input_space++; input_space *= 1.5;
@@ -500,6 +508,10 @@ input_push (char *text, char *macro, char *filename, int
line_number)
if (!macro)
line_number--;
input_stack[input_number].source_info.line_nr = line_number;
+ if (input_number > 0)
+ {
+ filename = input_stack[input_number - 1].source_info.file_name;
+ }
input_stack[input_number].source_info.file_name = save_string (filename);
input_stack[input_number].source_info.macro = save_string (macro);
input_number++;
@@ -544,33 +556,6 @@ free_small_strings (void)
small_strings_num = 0;
}
-
-/* Store TEXT as a source for Texinfo content. TEXT should be a UTF-8
- 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_text (char *text, char *macro)
-{
- if (text)
- {
- char *filename = 0;
- if (input_number > 0)
- {
- filename = input_stack[input_number - 1].source_info.file_name;
- }
- input_push (text, macro, filename, current_source_info.line_nr);
- }
-}
-
-/* Used in tests - like input_push_text, but the lines from the text have
- line numbers. */
-void
-input_push_text_with_line_nos (char *text, int starting)
-{
- input_push (text, 0, 0, starting);
- input_stack[input_number - 1].type = IN_text;
-}
-
void
input_reset_input_stack (void)
{
diff --git a/tp/Texinfo/XS/parsetexi/input.h b/tp/Texinfo/XS/parsetexi/input.h
index 9cf758e030..5f18222e33 100644
--- a/tp/Texinfo/XS/parsetexi/input.h
+++ b/tp/Texinfo/XS/parsetexi/input.h
@@ -9,9 +9,7 @@ char *next_text (void);
void save_line_directive (int line_nr, char *filename);
-void input_push (char *text, char *macro, char *filename, int line_number);
-void input_push_text (char *line, char *macro);
-void input_push_text_with_line_nos (char *text, int starting);
+void input_push (char *text, int line_number, char *macro);
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 29d4900817..8c9de1ab4e 100644
--- a/tp/Texinfo/XS/parsetexi/macro.c
+++ b/tp/Texinfo/XS/parsetexi/macro.c
@@ -594,9 +594,9 @@ handle_macro (ELEMENT *current, char **line_inout, enum
command_id cmd)
// 3958 Pop macro stack
/* Put expansion in front of the current line. */
- input_push_text (strdup (line), 0);
+ input_push (strdup (line), current_source_info.line_nr, 0);
line = strchr (line, '\0');
- input_push_text (expanded.text, command_name(cmd));
+ input_push (expanded.text, current_source_info.line_nr, command_name(cmd));
funexit:
*line_inout = line;
diff --git a/tp/Texinfo/XS/parsetexi/parser.c b/tp/Texinfo/XS/parsetexi/parser.c
index 3e2e534717..65c15b7f1d 100644
--- a/tp/Texinfo/XS/parsetexi/parser.c
+++ b/tp/Texinfo/XS/parsetexi/parser.c
@@ -1572,8 +1572,12 @@ superfluous_arg:
if (value)
{
expanded_line++; /* past '}' */
- input_push_text (strdup (expanded_line),
current_source_info.macro);
- input_push_text (strdup (value),
current_source_info.macro);
+ input_push (strdup (expanded_line),
+ current_source_info.line_nr,
+ current_source_info.macro);
+ input_push (strdup (value),
+ current_source_info.line_nr,
+ current_source_info.macro);
/* Move 'line' to end of string so next input to
be processed is taken from input stack. */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/ParserNonXS.pm (_input_push), tp/Texinfo/XS/parsetexi/api.c, tp/Texinfo/XS/parsetexi/handle_commands.c, tp/Texinfo/XS/parsetexi/input.c (input_push), tp/Texinfo/XS/parsetexi/parser.c: change the order of input_push arguments. Get the filename from the input stack in input_push. Remove input_push_text and input_push_text_with_line_nos, call directly input_push. Update callers.,
Patrice Dumas <=