[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Sun, 29 Sep 2024 04:02:56 -0400 (EDT) |
branch: master
commit 20c0c72d3730ef0607cdde584d930d7f4d2f6676
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Jun 8 12:51:04 2024 +0200
* tp/Texinfo/ParserNonXS.pm (_handle_brace_command),
tp/Texinfo/XS/parsetexi/handle_commands.c (handle_brace_command): have
definfoenclose always takes precedence. Rearrange code.
---
ChangeLog | 6 +++++
tp/Texinfo/ParserNonXS.pm | 35 ++++++++++++------------
tp/Texinfo/XS/parsetexi/handle_commands.c | 45 ++++++++++++++++++-------------
3 files changed, 50 insertions(+), 36 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 38f7815098..22da6a2038 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-06-08 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/ParserNonXS.pm (_handle_brace_command),
+ tp/Texinfo/XS/parsetexi/handle_commands.c (handle_brace_command): have
+ definfoenclose always takes precedence. Rearrange code.
+
2024-06-08 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XS/main/extra.c: remove add_info_element_oot,
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index c33af92725..c49eaecf42 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -6090,31 +6090,32 @@ sub _handle_brace_command($$$$)
my $command_e = { 'cmdname' => $command, 'parent' => $current,};
$command_e->{'source_info'} = {%{$source_info}};
push @{$current->{'contents'}}, $command_e;
+ # can only be sortas, which cannot be definfoenclose'd
if ($in_index_commands{$command}
and !_is_index_element($self, $current->{'parent'})) {
$self->_line_warn(
sprintf(__("\@%s should only appear in an index entry"),
$command), $source_info);
- }
- $current = $command_e;
- if ($command eq 'click') {
+ } elsif ($command eq 'click') { # click cannot be definfoenclose'd
$command_e->{'extra'} = {} if (!$command_e->{'extra'});
$command_e->{'extra'}->{'clickstyle'} = $self->{'clickstyle'};
- } elsif ($command eq 'kbd'
- and _kbd_formatted_as_code($self, $current)) {
- $command_e->{'extra'} = {} if (!$command_e->{'extra'});
- $command_e->{'extra'}->{'code'} = 1;
- }
- if ($self->{'definfoenclose'}->{$command}) {
- $command_e->{'type'} = 'definfoenclose_command';
- $command_e->{'info'} = {} if (!$command_e->{'info'});
- $command_e->{'info'}->{'command_name'} = $command;
- $command_e->{'extra'} = {} if (!$command_e->{'extra'});
- $command_e->{'extra'}->{'begin'}
- = $self->{'definfoenclose'}->{$command}->[0];
- $command_e->{'extra'}->{'end'}
- = $self->{'definfoenclose'}->{$command}->[1];
+ } else {
+ if ($self->{'definfoenclose'}->{$command}) {
+ $command_e->{'type'} = 'definfoenclose_command';
+ $command_e->{'info'} = {} if (!$command_e->{'info'});
+ $command_e->{'info'}->{'command_name'} = $command;
+ $command_e->{'extra'} = {} if (!$command_e->{'extra'});
+ $command_e->{'extra'}->{'begin'}
+ = $self->{'definfoenclose'}->{$command}->[0];
+ $command_e->{'extra'}->{'end'}
+ = $self->{'definfoenclose'}->{$command}->[1];
+ } elsif ($command eq 'kbd'
+ and _kbd_formatted_as_code($self, $command_e)) {
+ $command_e->{'extra'} = {} if (!$command_e->{'extra'});
+ $command_e->{'extra'}->{'code'} = 1;
+ }
}
+ $current = $command_e;
return ($current, $command_e);
}
diff --git a/tp/Texinfo/XS/parsetexi/handle_commands.c
b/tp/Texinfo/XS/parsetexi/handle_commands.c
index 46989612ab..bd6b4a0e42 100644
--- a/tp/Texinfo/XS/parsetexi/handle_commands.c
+++ b/tp/Texinfo/XS/parsetexi/handle_commands.c
@@ -1179,6 +1179,10 @@ funexit:
return current;
}
+/* in that case command_element always point to the returned current
+ element and therefore only one of the two could be used, but we
+ prefer consistently using the same prototype as other
+ handle_*_command functions */
ELEMENT *
handle_brace_command (ELEMENT *current, const char **line_inout,
enum command_id cmd, ELEMENT **command_element)
@@ -1187,7 +1191,9 @@ handle_brace_command (ELEMENT *current, const char
**line_inout,
debug ("OPEN BRACE @%s", command_name(cmd));
- if (command_data(cmd).data == BRACE_context)
+ if (command_data(cmd).flags & CF_INFOENCLOSE)
+ command_e = new_command_element (ET_definfoenclose_command, cmd);
+ else if (command_data(cmd).data == BRACE_context)
command_e = new_command_element (ET_context_brace_command, cmd);
else if (command_data(cmd).data == BRACE_arguments)
command_e = new_command_element (ET_brace_args_command, cmd);
@@ -1201,6 +1207,7 @@ handle_brace_command (ELEMENT *current, const char
**line_inout,
add_to_element_contents (current, command_e);
+ /* sortas cannot be definfoenclose'd */
if (cmd == CM_sortas)
{
if (!(command_flags(current->parent) & CF_index_entry_command)
@@ -1210,33 +1217,33 @@ handle_brace_command (ELEMENT *current, const char
**line_inout,
command_name(cmd));
}
}
-
- current = command_e;
-
- if (cmd == CM_click)
+ /* click cannot be definfoenclose'd */
+ else if (cmd == CM_click)
{
add_extra_string_dup (command_e, "clickstyle", global_clickstyle);
}
- else if (cmd == CM_kbd)
+ else
{
- if (kbd_formatted_as_code (current))
+ if (command_data(cmd).flags & CF_INFOENCLOSE)
{
- add_extra_integer (command_e, "code", 1);
+ INFO_ENCLOSE *ie = lookup_infoenclose (cmd);
+ if (ie)
+ {
+ add_extra_string_dup (command_e, "begin", ie->begin);
+ add_extra_string_dup (command_e, "end", ie->end);
+ }
+ add_info_string_dup (command_e, "command_name",
+ command_name(cmd));
}
- }
- else if (command_data(cmd).flags & CF_INFOENCLOSE)
- {
- INFO_ENCLOSE *ie = lookup_infoenclose (cmd);
- if (ie)
+ else if (cmd == CM_kbd)
{
- add_extra_string_dup (command_e, "begin", ie->begin);
- add_extra_string_dup (command_e, "end", ie->end);
+ if (kbd_formatted_as_code (command_e))
+ {
+ add_extra_integer (command_e, "code", 1);
+ }
}
- command_e->type = ET_definfoenclose_command;
- add_info_string_dup (current, "command_name",
- command_name(cmd));
}
-
+ current = command_e;
*command_element = command_e;
return current;
}
- master updated (61cfca59c3 -> 59ddbc416b), Patrice Dumas, 2024/09/29
- [no subject], Patrice Dumas, 2024/09/29
- [no subject], Patrice Dumas, 2024/09/29
- [no subject], Patrice Dumas, 2024/09/29
- [no subject],
Patrice Dumas <=
- [no subject], Patrice Dumas, 2024/09/29
- [no subject], Patrice Dumas, 2024/09/29