[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: Override _default_format_protect_text instead
From: |
Gavin D. Smith |
Subject: |
branch master updated: Override _default_format_protect_text instead |
Date: |
Sat, 04 Jun 2022 06:44:21 -0400 |
This is an automated email from the git hooks/post-receive script.
gavin pushed a commit to branch master
in repository texinfo.
The following commit(s) were added to refs/heads/master by this push:
new 2ac1711124 Override _default_format_protect_text instead
2ac1711124 is described below
commit 2ac17111243e2ec96e1a4eb9b150f24f9729b262
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Sat Jun 4 11:44:11 2022 +0100
Override _default_format_protect_text instead
* tp/Texinfo/XS/misc.c, tp/Texinfo/XS/MiscXS.xs
(xs_xml_protect_text, xs_default_format_protect_text): Rename and
also handle form feeds.
* tp/Texinfo/Convert/HTML.pm: Override _default_format_protect_text.
* tp/Texinfo/Convert/Converter.pm: Do not override xml_protect_text.
* tp/texi2any.pl: Call import method on dynamically loaded modules.
---
ChangeLog | 11 +++++++++++
tp/Texinfo/Convert/Converter.pm | 16 +---------------
tp/Texinfo/Convert/HTML.pm | 16 +++++++++++++++-
tp/Texinfo/XS/MiscXS.xs | 4 ++--
tp/Texinfo/XS/misc.c | 7 +++++--
tp/Texinfo/XS/miscxs.h | 2 +-
tp/texi2any.pl | 6 ++++--
7 files changed, 39 insertions(+), 23 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 0397720527..58f90f8571 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2022-06-05 Gavin Smith <gavinsmith0123@gmail.com>
+
+ Override _default_format_protect_text instead
+
+ * tp/Texinfo/XS/misc.c, tp/Texinfo/XS/MiscXS.xs
+ (xs_xml_protect_text, xs_default_format_protect_text): Rename and
+ also handle form feeds.
+ * tp/Texinfo/Convert/HTML.pm: Override _default_format_protect_text.
+ * tp/Texinfo/Convert/Converter.pm: Do not override xml_protect_text.
+ * tp/texi2any.pl: Call import method on dynamically loaded modules.
+
2022-06-05 Gavin Smith <gavinsmith0123@gmail.com>
texi2any --html performance improvement - XS override
diff --git a/tp/Texinfo/Convert/Converter.pm b/tp/Texinfo/Convert/Converter.pm
index c4e8528e63..630708d1c9 100644
--- a/tp/Texinfo/Convert/Converter.pm
+++ b/tp/Texinfo/Convert/Converter.pm
@@ -57,19 +57,6 @@ xml_accents
$VERSION = '6.8dev';
-our $module_loaded = 0;
-sub import {
- if (!$module_loaded) {
- Texinfo::XSLoader::override(
- "Texinfo::Convert::Converter::xml_protect_text",
- "Texinfo::MiscXS::xml_protect_text");
- $module_loaded = 1;
- }
- # The usual import method
- goto &Exporter::import;
-}
-
-
my %defaults = (
'documentlanguage' => undef,
);
@@ -1395,8 +1382,7 @@ sub xml_format_text_with_numeric_entities($$)
return $text;
}
-# Note: has an XS override
-sub xml_protect_text
+sub xml_protect_text($$)
{
my $self = shift;
my $text = shift;
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 98ad78c731..028be492d6 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -76,6 +76,19 @@ use vars qw($VERSION @ISA);
$VERSION = '6.8dev';
+our $module_loaded = 0;
+sub import {
+ if (!$module_loaded) {
+ Texinfo::XSLoader::override(
+ "Texinfo::Convert::HTML::_default_format_protect_text",
+ "Texinfo::MiscXS::default_format_protect_text");
+ $module_loaded = 1;
+ }
+ # The usual import method
+ goto &Exporter::import;
+}
+
+
# misc commands that are of use for formatting.
my %formatted_misc_commands = %Texinfo::Common::formatted_misc_commands;
@@ -3026,7 +3039,8 @@ sub _default_format_comment($$) {
return $self->xml_comment(' '.$text);
}
-sub _default_format_protect_text($$) {
+# Note: has an XS override
+sub _default_format_protect_text {
my $self = shift;
my $text = shift;
my $result = $self->xml_protect_text($text);
diff --git a/tp/Texinfo/XS/MiscXS.xs b/tp/Texinfo/XS/MiscXS.xs
index cd1307ff48..6b19907f9c 100644
--- a/tp/Texinfo/XS/MiscXS.xs
+++ b/tp/Texinfo/XS/MiscXS.xs
@@ -134,7 +134,7 @@ xs_parse_texi_regex (text)
SvUTF8_on(ST(5));
SV *
-xs_xml_protect_text (self, text_in)
+xs_default_format_protect_text (self, text_in)
SV *self
SV *text_in
PREINIT:
@@ -147,7 +147,7 @@ xs_xml_protect_text (self, text_in)
text = SvPV_nolen (text_in);
- retval = xs_xml_protect_text (text);
+ retval = xs_default_format_protect_text (text);
RETVAL = newSVpv (retval, 0);
SvUTF8_on (RETVAL);
diff --git a/tp/Texinfo/XS/misc.c b/tp/Texinfo/XS/misc.c
index c3b3427043..ff134edb3d 100644
--- a/tp/Texinfo/XS/misc.c
+++ b/tp/Texinfo/XS/misc.c
@@ -636,7 +636,7 @@ void xs_parse_texi_regex (SV *text_in,
}
char *
-xs_xml_protect_text (char *text)
+xs_default_format_protect_text (char *text)
{
char *p, *q;
static char *new;
@@ -660,7 +660,7 @@ xs_xml_protect_text (char *text)
while (1)
{
- q = p + strcspn (p, "<>&\"");
+ q = p + strcspn (p, "<>&\"\f");
ADDN(p, q - p);
if (!*q)
break;
@@ -678,6 +678,9 @@ xs_xml_protect_text (char *text)
case '"':
ADDN(""", 6);
break;
+ case '\f':
+ ADDN("", 5);
+ break;
}
p = q + 1;
}
diff --git a/tp/Texinfo/XS/miscxs.h b/tp/Texinfo/XS/miscxs.h
index 4eca89ccf3..65b3be870a 100644
--- a/tp/Texinfo/XS/miscxs.h
+++ b/tp/Texinfo/XS/miscxs.h
@@ -9,4 +9,4 @@ void xs_parse_texi_regex (SV *text,
char **,
char **,
char **);
-char *xs_xml_protect_text (char *);
+char *xs_default_format_protect_text (char *);
diff --git a/tp/texi2any.pl b/tp/texi2any.pl
index 68b28f8ddb..04e5d3c68e 100755
--- a/tp/texi2any.pl
+++ b/tp/texi2any.pl
@@ -1161,8 +1161,10 @@ my %converter_defaults;
if (defined($formats_table{$format}->{'module'})) {
# Speed up initialization by only loading the module we need.
- eval "require $formats_table{$format}->{'module'};"
- or die "$@";
+ my $module = $formats_table{$format}->{'module'};
+ eval "require $module" or die "$@";
+ eval "$module->import;";
+
eval '$formats_table{$format}->{\'converter\'} = sub{'.
$formats_table{$format}->{'module'}
.'->converter(@_)};';
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: Override _default_format_protect_text instead,
Gavin D. Smith <=