develooper Front page | perl.perl5.porters | Postings from March 2008

Re: [perl #52104] Text::Wrap::wrap() generates a segfault withCyrillic characters when the utf8 flag is turned on

Thread Previous | Thread Next
From:
Aristotle Pagaltzis
Date:
March 29, 2008 00:12
Subject:
Re: [perl #52104] Text::Wrap::wrap() generates a segfault withCyrillic characters when the utf8 flag is turned on
Message ID:
20080329071247.GX22144@klangraum
* Robin Barker <Robin.Barker@npl.co.uk> [2008-03-29 00:00]:
> From: Frédéric Buclin [mailto:lpsolit@gmail.com]
> > For all installations which do not have the not-yet-released
> > Perl 5.8.9, which workaround(s) do they have? On critical
> > installations, it's hard to upgrade Perl as it's a pretty
> > heavy change.
> 
> I have rewritten Text::Tabs to avoid s//pos/ The code is at
> work and I haven't had a chance to test it. From memory, the
> code for C<sub expand> is below.

I wrote the version of `expand` with s//pos/e; it is the way it
is for maximum performance. The old code ran in O(n^2) but was
fast for short strings; my goal was O(n) without significantly
higher overhead. I had some variants I liked better, code quality
wise, but they were slower.

Your version is O(n) too, but if you benchmark it you’ll find it
is measurably slower than mine in all cases, and much slower than
the old Text::Tabs code for short strings.

There have been some fixes in Text::Wrap since my performance
patch, but none in Text::Tabs, so if you have a buggy version
of perl I suggest you simply downgrade Text::Tabs to the version
from the Text-Tabs+Wrap-2001.0929 distribution.

Regards,
-- 
Aristotle Pagaltzis // <http://plasmasturm.org/>

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About