[Bps-public-commit] r10454 - Text-Quoted
ruz at bestpractical.com
ruz at bestpractical.com
Wed Jan 23 10:43:43 EST 2008
Author: ruz
Date: Wed Jan 23 10:43:42 2008
New Revision: 10454
Modified:
Text-Quoted/Makefile.PL
Text-Quoted/Quoted.pm
Log:
* replace Text::Tabs with own function that don't segfault
Modified: Text-Quoted/Makefile.PL
==============================================================================
--- Text-Quoted/Makefile.PL (original)
+++ Text-Quoted/Makefile.PL Wed Jan 23 10:43:42 2008
@@ -8,6 +8,5 @@
all_from 'Quoted.pm';
requires 'Text::Autoformat';
-requires 'Text::Tabs';
WriteAll;
Modified: Text-Quoted/Quoted.pm
==============================================================================
--- Text-Quoted/Quoted.pm (original)
+++ Text-Quoted/Quoted.pm Wed Jan 23 10:43:42 2008
@@ -10,7 +10,6 @@
our @EXPORT = qw(extract);
use Text::Autoformat(); # Provides the Hang package, heh, heh.
-use Text::Tabs();
=head1 NAME
@@ -169,11 +168,9 @@
# If the user passes in a null string, we really want to end up with _something_
# DETABIFY
- my @lines = Text::Tabs::expand( split /\n/, $text );
-
+ my @lines = expand_tabs( split /\n/, $text );
# PARSE EACH LINE
-
foreach (splice @lines) {
my %line = ( raw => $_ );
@line{'quoter', 'text'} = (/\A *($quoter?) *(.*?)\s*\Z/o);
@@ -233,4 +230,22 @@
return @paras;
}
+# we don't use Text::Tabs anymore as it may segfault on perl 5.8.x with
+# UTF-8 strings and tabs mixed. http://rt.perl.org/rt3/Public/Bug/Display.html?id=40989
+# This bug unlikely to be fixed in 5.8.x, however we use workaround.
+# As soon as Text::Tabs will be fixed we can return back to it
+my $tabstop = 8;
+sub expand_tabs {
+ my $pad;
+ for ( @_ ) {
+ my $offs = 0;
+ s{(.*?)\t}{
+ $pad = $tabstop - (length($1) + $offs) % $tabstop;
+ $offs += length($1)+$pad;
+ $1 . (" " x $pad);
+ }eg;
+ }
+ return @_;
+}
+
1;
More information about the Bps-public-commit
mailing list