[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/ParserNonXS.pm(_check_empty_expansio
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/ParserNonXS.pm(_check_empty_expansion), tp/Texinfo/XS/parsetexi/parser.c (check_space_element): do not check especially space container types, they are unlikely to happen where expansion is checked and should only contain spaces anyway. |
Date: |
Sun, 11 Sep 2022 05:34:00 -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 869ea9fae8 * tp/Texinfo/ParserNonXS.pm(_check_empty_expansion),
tp/Texinfo/XS/parsetexi/parser.c (check_space_element): do not check especially
space container types, they are unlikely to happen where expansion is checked
and should only contain spaces anyway.
869ea9fae8 is described below
commit 869ea9fae8e2113897cfbd3214eb9e534f93ed61
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Sep 11 11:33:48 2022 +0200
* tp/Texinfo/ParserNonXS.pm(_check_empty_expansion),
tp/Texinfo/XS/parsetexi/parser.c (check_space_element):
do not check especially space container types, they are
unlikely to happen where expansion is checked and should only
contain spaces anyway.
* tp/Texinfo/ParserNonXS.pm (_abort_empty_line),
tp/Texinfo/XS/misc.c (xs_abort_empty_line),
tp/Texinfo/XS/parsetexi/parser.c (abort_empty_line):
setup associated element where needed and simplify.
---
ChangeLog | 13 +++++++++++++
tp/Texinfo/ParserNonXS.pm | 16 ++++------------
tp/Texinfo/XS/misc.c | 38 ++++++++++++++++----------------------
tp/Texinfo/XS/parsetexi/parser.c | 16 ++++++----------
4 files changed, 39 insertions(+), 44 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 16055f34ea..1cc624e687 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2022-09-11 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/ParserNonXS.pm(_check_empty_expansion),
+ tp/Texinfo/XS/parsetexi/parser.c (check_space_element):
+ do not check especially space container types, they are
+ unlikely to happen where expansion is checked and should only
+ contain spaces anyway.
+
+ * tp/Texinfo/ParserNonXS.pm (_abort_empty_line),
+ tp/Texinfo/XS/misc.c (xs_abort_empty_line),
+ tp/Texinfo/XS/parsetexi/parser.c (abort_empty_line):
+ setup associated element where needed and simplify.
+
2022-09-10 Patrice Dumas <pertusus@free.fr>
Use array references on pairs [name, value] for attributes
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index 4228b2ddd2..d2bdf5cf80 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -2297,7 +2297,7 @@ sub _set_non_ignored_space_in_index_before_command($)
and $in_index_commands{$content->{'cmdname'}}
and defined($brace_commands{$content->{'cmdname'}}))
or ($content->{'type'}
- and $content->{'type'} eq 'empty_spaces_after_close_brace'))
+ and $content->{'type'} eq 'empty_spaces_after_close_brace'))
and (! _check_empty_expansion([$content]))) {
delete $pending_spaces_element->{'type'};
$pending_spaces_element = 0;
@@ -2323,12 +2323,6 @@ sub _abort_empty_line {
my $spaces_element = $current->{'contents'}->[-1];
- my $owning_element;
- if ($spaces_element->{'extra'}
- and $spaces_element->{'extra'}->{'spaces_associated_command'}) {
- $owning_element =
$spaces_element->{'extra'}->{'spaces_associated_command'};
- }
-
print STDERR "ABORT EMPTY "
.$spaces_element->{'type'}
." additional text |$additional_spaces|,"
@@ -2336,6 +2330,7 @@ sub _abort_empty_line {
if ($self->{'DEBUG'});
$spaces_element->{'text'} .= $additional_spaces;
+
# remove empty 'empty*before'.
if ($spaces_element->{'text'} eq '') {
pop @{$current->{'contents'}};
@@ -2353,6 +2348,8 @@ sub _abort_empty_line {
# the 'extra' hash as 'spaces_before_argument'.
pop @{$current->{'contents'}};
+ my $owning_element
+ = $spaces_element->{'extra'}->{'spaces_associated_command'};
$owning_element->{'extra'}->{'spaces_before_argument'}
= $spaces_element->{'text'};
}
@@ -3670,12 +3667,7 @@ sub _check_empty_expansion($)
or $content->{'cmdname'} eq 'c'
or $content->{'cmdname'} eq 'comment'
or $content->{'cmdname'} eq ':'))
- or ($content->{'type'}
- and ($content->{'type'} eq 'empty_spaces_before_argument'
- or $content->{'type'} eq 'spaces_at_end'))
or (defined($content->{'text'}) and $content->{'text'} !~ /\S/))) {
- #or (not $content->{'cmdname'} and not $content->{'type'}
- # and defined($content->{'text'}) and $content->{'text'} eq '')
return 0;
}
}
diff --git a/tp/Texinfo/XS/misc.c b/tp/Texinfo/XS/misc.c
index 73e074aa01..6a9971629e 100644
--- a/tp/Texinfo/XS/misc.c
+++ b/tp/Texinfo/XS/misc.c
@@ -53,11 +53,7 @@ xs_abort_empty_line (HV *self, HV *current, SV
*additional_spaces_in)
SV **svp;
int contents_num;
HV *spaces_elt;
- //char *key;
- HV *test_extra = 0;
- HV *command_extra = 0;
- HV *owning_elt = 0;
char *type;
SV *existing_text_sv;
@@ -110,21 +106,6 @@ xs_abort_empty_line (HV *self, HV *current, SV
*additional_spaces_in)
//fprintf (stderr, "ABORT EMPTY\n");
- svp = hv_fetch (spaces_elt, "extra", strlen ("extra"), 0);
- if (svp)
- {
- test_extra = (HV *) SvRV (*svp);
- svp = hv_fetch (test_extra, "spaces_associated_command",
- strlen ("spaces_associated_command"), 0);
- if (svp)
- {
- owning_elt = (HV *) SvRV (*svp);
- svp = hv_fetch (owning_elt, "extra", strlen ("extra"), 0);
- if (svp)
- command_extra = (HV *) SvRV (*svp);
- }
- }
-
svp = hv_fetch (spaces_elt, "text", strlen ("text"), 0);
if (!svp)
return 0; /* or create it? change last arg from 0 to 1 */
@@ -198,19 +179,32 @@ delete_type:
|| !strcmp (type, "empty_spaces_before_argument"))
{
STRLEN len;
+ HV *owning_elt = 0;
+ HV *command_extra = 0;
+ HV *test_extra = 0;
char *ptr;
/* Remove spaces_elt */
av_pop (contents_array);
- ptr = SvPV(existing_text_sv, len);
- /* Replace element reference with a simple string. */
- if (!command_extra)
+ /* add spaces to associated element extra "spaces_before_argument" */
+ svp = hv_fetch (spaces_elt, "extra", strlen ("extra"), 0);
+ test_extra = (HV *) SvRV (*svp);
+ svp = hv_fetch (test_extra, "spaces_associated_command",
+ strlen ("spaces_associated_command"), 0);
+ owning_elt = (HV *) SvRV (*svp);
+
+ svp = hv_fetch (owning_elt, "extra", strlen ("extra"), 0);
+ if (svp)
+ command_extra = (HV *) SvRV (*svp);
+ else
{
command_extra = newHV ();
hv_store (owning_elt, "extra", strlen ("extra"),
newRV_inc((SV *)command_extra), 0);
}
+
+ ptr = SvPV(existing_text_sv, len);
hv_store (command_extra,
"spaces_before_argument",
strlen ("spaces_before_argument"),
diff --git a/tp/Texinfo/XS/parsetexi/parser.c b/tp/Texinfo/XS/parsetexi/parser.c
index 788a4659db..fccb2d5f42 100644
--- a/tp/Texinfo/XS/parsetexi/parser.c
+++ b/tp/Texinfo/XS/parsetexi/parser.c
@@ -98,8 +98,6 @@ check_space_element (ELEMENT *e)
|| e->cmd == CM_c
|| e->cmd == CM_comment
|| e->cmd == CM_COLON
- || e->type == ET_empty_spaces_before_argument
- || e->type == ET_spaces_at_end
|| (!e->cmd && !e->type && e->text.end == 0)
|| (e->text.end > 0
&& !*(e->text.text + strspn (e->text.text, whitespace_chars)))
@@ -618,15 +616,8 @@ abort_empty_line (ELEMENT **current_inout, char
*additional_spaces)
|| last_child->type == ET_empty_spaces_before_argument
|| last_child->type == ET_empty_spaces_after_close_brace))
{
- ELEMENT *owning_element = 0, *e;
- KEY_PAIR *k;
-
retval = 1;
- k = lookup_extra (last_child, "spaces_associated_command");
- if (k)
- owning_element = (ELEMENT *) k->value;
-
debug ("ABORT EMPTY %s additional text |%s| "
"current |%s|",
element_type_name(last_child),
@@ -637,7 +628,7 @@ abort_empty_line (ELEMENT **current_inout, char
*additional_spaces)
/* Remove element altogether if it's empty. */
if (last_child->text.end == 0)
{
- e = pop_element_from_contents (current);
+ ELEMENT *e = pop_element_from_contents (current);
destroy_element (e);
}
else if (last_child->type == ET_empty_line)
@@ -650,7 +641,12 @@ abort_empty_line (ELEMENT **current_inout, char
*additional_spaces)
{
/* Remove element from main tree. It will still be referenced in
the 'extra' hash as 'spaces_before_argument'. */
+ ELEMENT *owning_element;
+ KEY_PAIR *k;
ELEMENT *e = pop_element_from_contents (current);
+
+ k = lookup_extra (last_child, "spaces_associated_command");
+ owning_element = (ELEMENT *) k->value;
add_extra_string_dup (owning_element, "spaces_before_argument",
e->text.text);
destroy_element (e);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/ParserNonXS.pm(_check_empty_expansion), tp/Texinfo/XS/parsetexi/parser.c (check_space_element): do not check especially space container types, they are unlikely to happen where expansion is checked and should only contain spaces anyway.,
Patrice Dumas <=