[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/ParserNonXS.pm (_process_remaining_o
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line), tp/Texinfo/XS/parsetexi/menus.c (handle_menu): move code that sets up a menu separator before code that handles a menu separator for improved readability. |
Date: |
Thu, 02 Mar 2023 17:56:47 -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 27eb46bfcd * tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line),
tp/Texinfo/XS/parsetexi/menus.c (handle_menu): move code that sets up a menu
separator before code that handles a menu separator for improved readability.
27eb46bfcd is described below
commit 27eb46bfcd1f4563be5ae5dccbf71af00277b387
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Thu Mar 2 23:56:37 2023 +0100
* tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line),
tp/Texinfo/XS/parsetexi/menus.c (handle_menu): move code that sets up
a menu separator before code that handles a menu separator for
improved readability.
---
ChangeLog | 7 +++++++
tp/Texinfo/ParserNonXS.pm | 26 +++++++++++------------
tp/Texinfo/XS/parsetexi/menus.c | 46 ++++++++++++++++++++---------------------
3 files changed, 42 insertions(+), 37 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 8d71ff3e8c..8276af3836 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2023-03-02 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line),
+ tp/Texinfo/XS/parsetexi/menus.c (handle_menu): move code that sets up
+ a menu separator before code that handles a menu separator for
+ improved readability.
+
2023-03-02 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/ParserNonXS.pm (_parse_texi_regex)
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index 1eb1d82daf..25651b8424 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -5351,6 +5351,19 @@ sub _process_remaining_on_line($$$$)
push @{$menu_entry->{'contents'}}, $entry_name;
$current = $entry_name;
}
+ # After a separator in a menu, end of menu entry node or menu
+ # entry name (. must be followed by a space to stop the node).
+ } elsif ($menu_separator
+ # if menu separator is not ':', it is [,\t.]
+ and (($menu_separator ne ':' and $current->{'type'}
+ and $current->{'type'} eq 'menu_entry_node')
+ or ($menu_separator eq ':' and $current->{'type'}
+ and $current->{'type'} eq 'menu_entry_name'))) {
+ substr ($line, 0, 1) = '';
+ $current = $current->{'parent'};
+ push @{$current->{'contents'}}, { 'type' => 'menu_entry_separator',
+ 'text' => $menu_separator,
+ 'parent' => $current };
# after a separator in menu
} elsif ($current->{'contents'} and @{$current->{'contents'}}
and $current->{'contents'}->[-1]->{'type'}
@@ -5393,19 +5406,6 @@ sub _process_remaining_on_line($$$$)
print STDERR "MENU NODE done $separator\n" if ($self->{'DEBUG'});
$current = _enter_menu_entry_node($self, $current, $source_info);
}
- # After a separator in a menu, end of menu entry node or menu
- # entry name (. must be followed by a space to stop the node).
- } elsif ($menu_separator
- # if menu separator is not ':', it is [,\t.]
- and (($menu_separator ne ':' and $current->{'type'}
- and $current->{'type'} eq 'menu_entry_node')
- or ($menu_separator eq ':' and $current->{'type'}
- and $current->{'type'} eq 'menu_entry_name'))) {
- substr ($line, 0, 1) = '';
- $current = $current->{'parent'};
- push @{$current->{'contents'}}, { 'type' => 'menu_entry_separator',
- 'text' => $menu_separator,
- 'parent' => $current };
# Any other @-command.
} elsif ($command) {
if (!$at_command) {
diff --git a/tp/Texinfo/XS/parsetexi/menus.c b/tp/Texinfo/XS/parsetexi/menus.c
index 4bc04885b6..73e4c3570d 100644
--- a/tp/Texinfo/XS/parsetexi/menus.c
+++ b/tp/Texinfo/XS/parsetexi/menus.c
@@ -187,9 +187,27 @@ handle_menu (ELEMENT **current_inout, char **line_inout)
debug ("ABORT MENU STAR");
last_contents_child(current)->type = ET_NONE;
}
- /* After a separator in a menu, which would have been added in code below
- , tab or . after ET_menu_entry_node
- : after ET_menu_entry_name */
+ /* After a separator in a menu, end of menu entry node or menu entry name
+ (. must be followed by a space to stop the node). */
+ else if (*line != '\0'
+ && ((*line == ':' && current->type == ET_menu_entry_name)
+ || (strchr (",\t.", *line)
+ && current->type == ET_menu_entry_node)))
+ {
+ ELEMENT *e;
+ char menu_separator = *line;
+ line++;
+
+ debug ("MENU SEPARATOR %c\n", menu_separator);
+ current = current->parent;
+ e = new_element (ET_menu_entry_separator);
+ text_append_n (&e->text, &menu_separator, 1);
+ add_to_element_contents (current, e);
+
+ /* Note, if a '.' is not followed by whitespace, we revert was was
+ done here below. */
+ }
+ /* After a separator in a menu */
else if (current->contents.number > 0
&& last_contents_child (current)->type == ET_menu_entry_separator)
{
@@ -215,7 +233,7 @@ handle_menu (ELEMENT **current_inout, char **line_inout)
merge_text (current, last_child->text.text, last_child);
destroy_element (last_child);
}
- /* here we collect spaces following separators². */
+ /* here we collect spaces following separators. */
else if (strchr (whitespace_chars_except_newline, *line))
{
int n;
@@ -255,26 +273,6 @@ handle_menu (ELEMENT **current_inout, char **line_inout)
current = enter_menu_entry_node (current);
}
}
- /* After a separator in a menu, end of menu node
- (. must be followed by a space to stop the node). */
- else if (*line != '\0'
- && ((*line == ':' && current->type == ET_menu_entry_name)
- || (strchr (",\t.", *line)
- && current->type == ET_menu_entry_node)))
- {
- ELEMENT *e;
- char menu_separator = *line;
- line++;
-
- debug ("MENU SEPARATOR %c\n", menu_separator);
- current = current->parent;
- e = new_element (ET_menu_entry_separator);
- text_append_n (&e->text, &menu_separator, 1);
- add_to_element_contents (current, e);
-
- /* Note, if a '.' is not followed by whitespace, we revert was was done
here
- in code above. */
- }
else
retval = 0;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line), tp/Texinfo/XS/parsetexi/menus.c (handle_menu): move code that sets up a menu separator before code that handles a menu separator for improved readability.,
Patrice Dumas <=
- Prev by Date:
branch master updated: * tp/Texinfo/ParserNonXS.pm (_parse_texi_regex) (_process_remaining_on_line), tp/Texinfo/XS/MiscXS.xs (xs_parse_texi_regex), tp/Texinfo/XS/parsetexi/menus.c (handle_menu), tp/Texinfo/XS/parsetexi/parser.c (process_remaining_on_line), tp/Texinfo/XS/parsetexi/separator.c (handle_separator): handle menu separator separatly from other separators (with a possible overlap for comma, considered both as a menu and other separator in the perl parser), also moving the code starting the menu_entry_se [...]
- Next by Date:
branch master updated: * tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line) (_handle_menu): split _handle_menu out of _process_remaining_on_line to be more similar to XS parser.
- Previous by thread:
branch master updated: * tp/Texinfo/ParserNonXS.pm (_parse_texi_regex) (_process_remaining_on_line), tp/Texinfo/XS/MiscXS.xs (xs_parse_texi_regex), tp/Texinfo/XS/parsetexi/menus.c (handle_menu), tp/Texinfo/XS/parsetexi/parser.c (process_remaining_on_line), tp/Texinfo/XS/parsetexi/separator.c (handle_separator): handle menu separator separatly from other separators (with a possible overlap for comma, considered both as a menu and other separator in the perl parser), also moving the code starting the menu_entry_se [...]
- Next by thread:
branch master updated: * tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line) (_handle_menu): split _handle_menu out of _process_remaining_on_line to be more similar to XS parser.
- Index(es):