[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/ParserNonXS.pm (_process_raw_block_c
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/ParserNonXS.pm (_process_raw_block_contents) (_process_remaining_on_line, _parse_texi), tp/Texinfo/XS/parsetexi/parser.c (process_raw_block_contents) (process_remaining_on_line, parse_texi): add process_raw_block_contents to process a raw block command contents until @end line. Use it right after the block command opening. |
Date: |
Sun, 29 Sep 2024 06:42:32 -0400 |
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 8314445d8e * tp/Texinfo/ParserNonXS.pm (_process_raw_block_contents)
(_process_remaining_on_line, _parse_texi), tp/Texinfo/XS/parsetexi/parser.c
(process_raw_block_contents) (process_remaining_on_line, parse_texi): add
process_raw_block_contents to process a raw block command contents until @end
line. Use it right after the block command opening.
8314445d8e is described below
commit 8314445d8ef2cb543d51e5dcda6b6b9473a47e7a
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Thu Jun 20 21:22:56 2024 +0200
* tp/Texinfo/ParserNonXS.pm (_process_raw_block_contents)
(_process_remaining_on_line, _parse_texi),
tp/Texinfo/XS/parsetexi/parser.c (process_raw_block_contents)
(process_remaining_on_line, parse_texi): add
process_raw_block_contents to process a raw block command contents
until @end line. Use it right after the block command opening.
---
ChangeLog | 9 +++
tp/Texinfo/ParserNonXS.pm | 75 +++++++++++++++++--------
tp/Texinfo/XS/parsetexi/parser.c | 116 ++++++++++++++++++++++++---------------
3 files changed, 133 insertions(+), 67 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index a0602fe23a..a4a7d9d503 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2024-06-20 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/ParserNonXS.pm (_process_raw_block_contents)
+ (_process_remaining_on_line, _parse_texi),
+ tp/Texinfo/XS/parsetexi/parser.c (process_raw_block_contents)
+ (process_remaining_on_line, parse_texi): add
+ process_raw_block_contents to process a raw block command contents
+ until @end line. Use it right after the block command opening.
+
2024-06-20 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line, _parse_texi),
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index f8d16e6dad..b216016708 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -6783,23 +6783,20 @@ sub _new_macro($$$)
# are expanded earlier
}
-sub _process_remaining_on_line($$$$)
+# get input text to until the @end of raw block command, return the
+# @end line.
+sub _process_raw_block_contents($$)
{
my $self = shift;
my $current = shift;
- my $line = shift;
- my $source_info = shift;
-
- my $retval = $STILL_MORE_TO_PROCESS;
- #print STDERR "PROCESS "._debug_protect_eol($line)."\n"
- # if ($self->{'conf'}->{'DEBUG'});
+ my ($line, $source_info) = _next_text($self, $current);
- # in a 'raw' (verbatim, ignore, (r)macro)
- if ($current->{'cmdname'}
- and $block_commands{$current->{'cmdname'}}
- and ($block_commands{$current->{'cmdname'}} eq 'raw')) {
- my $closed_nested_raw;
+ while (1) {
+ if (!defined($line)) {
+ # unclosed block
+ return (undef, $source_info);
+ }
# r?macro may be nested
if ((($current->{'cmdname'} eq 'macro'
or $current->{'cmdname'} eq 'rmacro'
@@ -6861,19 +6858,33 @@ sub _process_remaining_on_line($$$$)
push @{$current->{'contents'}}, { 'type' => 'empty_line',
'text' => '',
'parent' => $current };
- $closed_nested_raw = 1;
+ last;
} else {
my $closed_cmdname = pop @{$self->{'raw_block_stack'}};
}
}
- if (not $closed_nested_raw) {
- push @{$current->{'contents'}},
- { 'text' => $line, 'type' => 'raw', 'parent' => $current };
- return ($current, $line, $source_info, $GET_A_NEW_LINE);
- # goto funexit; # used in XS code
- }
+ push @{$current->{'contents'}},
+ { 'text' => $line, 'type' => 'raw', 'parent' => $current };
+
+ ($line, $source_info) = _next_text($self, $current);
+ }
+ return ($line, $source_info);
+}
+
+sub _process_remaining_on_line($$$$)
+{
+ my $self = shift;
+ my $current = shift;
+ my $line = shift;
+ my $source_info = shift;
+
+ my $retval = $STILL_MORE_TO_PROCESS;
+
+ #print STDERR "PROCESS "._debug_protect_eol($line)."\n"
+ # if ($self->{'conf'}->{'DEBUG'});
+
# in ignored conditional block command
- } elsif ($current->{'cmdname'}
+ if ($current->{'cmdname'}
and $block_commands{$current->{'cmdname'}}
and ($block_commands{$current->{'cmdname'}} eq 'conditional')) {
# check for nested @ifset (so that @end ifset doesn't end the
@@ -7394,10 +7405,26 @@ sub _process_remaining_on_line($$$$)
= _handle_line_command($self, $current, $command, $data_cmdname, $line,
$source_info);
+ # in a 'raw' verbatim, ignore followed by a comment
+ if ($retval == $GET_A_NEW_LINE
+ and $current->{'cmdname'}
+ and $block_commands{$current->{'cmdname'}}
+ and ($block_commands{$current->{'cmdname'}} eq 'raw')) {
+ ($line, $source_info) = _process_raw_block_contents($self, $current);
+ $retval = $STILL_MORE_TO_PROCESS;
+ }
} elsif (exists($block_commands{$data_cmdname})) {
# @-command with matching @end opening
($current, $line, $retval, $command_element)
= _handle_block_command($self, $current, $command, $line, $source_info);
+ # in a 'raw' (r)macro
+ if ($retval == $GET_A_NEW_LINE
+ and $current->{'cmdname'}
+ and $block_commands{$current->{'cmdname'}}
+ and ($block_commands{$current->{'cmdname'}} eq 'raw')) {
+ ($line, $source_info) = _process_raw_block_contents($self, $current);
+ $retval = $STILL_MORE_TO_PROCESS;
+ }
} elsif (defined($self->{'brace_commands'}->{$data_cmdname})) {
($current, $command_element)
@@ -7512,6 +7539,11 @@ sub _process_remaining_on_line($$$$)
push @{$current->{'contents'}}, { 'type' => 'empty_line',
'text' => $1,
'parent' => $current };
+ # in a 'raw' verbatim, ignore followed by an end of line
+ } elsif ($current->{'cmdname'}
+ and $block_commands{$current->{'cmdname'}}
+ and ($block_commands{$current->{'cmdname'}} eq 'raw')) {
+ ($line, $source_info) = _process_raw_block_contents($self, $current);
} else {
$retval = $GET_A_NEW_LINE;
}
@@ -7574,8 +7606,7 @@ sub _parse_texi($$$)
# 'raw' command or ignored conditional or verb or ignored raw format
(($current->{'cmdname'}
and $block_commands{$current->{'cmdname'}}
- and ($block_commands{$current->{'cmdname'}} eq 'raw'
- or $block_commands{$current->{'cmdname'}} eq 'conditional'))
+ and $block_commands{$current->{'cmdname'}} eq 'conditional')
or
($current->{'parent'} and $current->{'parent'}->{'cmdname'}
and $current->{'parent'}->{'cmdname'} eq 'verb')
diff --git a/tp/Texinfo/XS/parsetexi/parser.c b/tp/Texinfo/XS/parsetexi/parser.c
index 116af7237d..ada2884a4d 100644
--- a/tp/Texinfo/XS/parsetexi/parser.c
+++ b/tp/Texinfo/XS/parsetexi/parser.c
@@ -1444,38 +1444,22 @@ check_valid_nesting_context (enum command_id cmd)
}
}
-/* *LINEP is a pointer into the line being processed. It is advanced past any
- bytes processed.
- Return STILL_MORE_TO_PROCESS when there is more to process on the line
- GET_A_NEW_LINE when we need to read a new line
- FINISHED_TOTALLY when @bye was found */
-int
-process_remaining_on_line (ELEMENT **current_inout, const char **line_inout)
+static const char *
+process_raw_block_contents (ELEMENT *current)
{
- ELEMENT *current = *current_inout;
- ELEMENT *macro_call_element = 0;
- const char *line = *line_inout;
- const char *line_after_command;
- int retval = STILL_MORE_TO_PROCESS;
enum command_id end_cmd;
- enum command_id from_alias = CM_NONE;
-
- enum command_id cmd = CM_NONE;
- /* remains set only if command is unknown, otherwise cmd is used */
- char *command = 0;
-
- /*
- debug_nonl ("PROCESS "); debug_print_protected_string (line); debug ("");
- */
+ const char *line = next_text (current);
- /* at this point we are necessarily in a command or container */
- /********* BLOCK_raw ******************/
- if (command_flags(current) & CF_block
- && (command_data(current->e.c->cmd).data == BLOCK_raw))
+ while (1)
{
const char *p = line;
enum command_id cmd = 0;
- int closed_nested_raw = 0;
+
+ if (!line)
+ {/* unclosed block */
+ return 0;
+ }
+
/* Check if we are using a macro within a macro. */
if (current->e.c->cmd == CM_macro || current->e.c->cmd == CM_rmacro
|| current->e.c->cmd == CM_linemacro)
@@ -1592,26 +1576,50 @@ process_remaining_on_line (ELEMENT **current_inout,
const char **line_inout)
e = new_text_element (ET_empty_line);
add_to_element_contents (current, e);
- closed_nested_raw = 1;
+ break;
}
else
pop_raw_block_stack ();
}
}
/* save the line verbatim */
- if (! closed_nested_raw)
- {
- ELEMENT *e;
- e = new_text_element (ET_raw);
- text_append (e->e.text, line);
- add_to_element_contents (current, e);
+ ELEMENT *e;
+ e = new_text_element (ET_raw);
+ text_append (e->e.text, line);
+ add_to_element_contents (current, e);
- retval = GET_A_NEW_LINE;
- goto funexit;
- }
- } /********* BLOCK_raw *************/
+ line = next_text (current);
+ }
+ return line;
+}
+
+/* *LINEP is a pointer into the line being processed. It is advanced past any
+ bytes processed.
+ Return STILL_MORE_TO_PROCESS when there is more to process on the line
+ GET_A_NEW_LINE when we need to read a new line
+ FINISHED_TOTALLY when @bye was found */
+int
+process_remaining_on_line (ELEMENT **current_inout, const char **line_inout)
+{
+ ELEMENT *current = *current_inout;
+ ELEMENT *macro_call_element = 0;
+ const char *line = *line_inout;
+ const char *line_after_command;
+ int retval = STILL_MORE_TO_PROCESS;
+ enum command_id end_cmd;
+ enum command_id from_alias = CM_NONE;
+
+ enum command_id cmd = CM_NONE;
+ /* remains set only if command is unknown, otherwise cmd is used */
+ char *command = 0;
+
+ /*
+ debug_nonl ("PROCESS "); debug_print_protected_string (line); debug ("");
+ */
+
+ /* at this point we are necessarily in a command or container */
/********* (ignored) BLOCK_conditional ******************/
- else if (command_flags(current) & CF_block
+ if (command_flags(current) & CF_block
&& (command_data(current->e.c->cmd).data == BLOCK_conditional))
{
const char *p = line;
@@ -2352,7 +2360,18 @@ process_remaining_on_line (ELEMENT **current_inout,
const char **line_inout)
int status;
current = handle_line_command (current, &line, cmd, data_cmd,
&status,
&command_element);
- if (status == GET_A_NEW_LINE || status == FINISHED_TOTALLY)
+ if (status == GET_A_NEW_LINE)
+ {
+ /* @ignore or @verbatim followed by a comment */
+ if (command_flags(current) & CF_block
+ && command_data(current->e.c->cmd).data == BLOCK_raw)
+ {
+ line = process_raw_block_contents (current);
+ }
+ else
+ retval = status;
+ }
+ else if (status == FINISHED_TOTALLY)
{
retval = status;
}
@@ -2362,11 +2381,14 @@ process_remaining_on_line (ELEMENT **current_inout,
const char **line_inout)
int new_line = 0;
current = handle_block_command (current, &line, cmd, &new_line,
&command_element);
+
+ /* For @macro, which processes the whole line */
if (new_line)
{
- /* For @macro, to get a new line. This is done instead of
- doing the EMPTY TEXT code on the next time round. */
- retval = GET_A_NEW_LINE;
+ if (command_data(data_cmd).data == BLOCK_raw)
+ {
+ line = process_raw_block_contents (current);
+ }
}
}
else if (command_data(data_cmd).flags & (CF_brace | CF_accent))
@@ -2521,6 +2543,12 @@ process_remaining_on_line (ELEMENT **current_inout,
const char **line_inout)
text_append_n (e_empty_line->e.text, line, n);
line += n;
}
+ /* @ignore and @verbatim followed by an end of line */
+ else if (command_flags(current) & CF_block
+ && command_data(current->e.c->cmd).data == BLOCK_raw)
+ {
+ line = process_raw_block_contents (current);
+ }
else
retval = GET_A_NEW_LINE;
}
@@ -2588,9 +2616,7 @@ parse_texi (ELEMENT *root_elt, ELEMENT *current_elt)
element type can be changed in 'abort_empty_line' when more text is
read. */
if (!((command_flags(current) & CF_block
- && (command_data(current->e.c->cmd).data == BLOCK_raw
- || command_data(current->e.c->cmd).data == BLOCK_conditional
- ))
+ && command_data(current->e.c->cmd).data == BLOCK_conditional)
|| (current->parent && current->parent->e.c->cmd == CM_verb))
&& current_context () != ct_def)
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/ParserNonXS.pm (_process_raw_block_contents) (_process_remaining_on_line, _parse_texi), tp/Texinfo/XS/parsetexi/parser.c (process_raw_block_contents) (process_remaining_on_line, parse_texi): add process_raw_block_contents to process a raw block command contents until @end line. Use it right after the block command opening.,
Patrice Dumas <=