develooper Front page | perl.perl5.porters | Postings from February 2013

Re: [perl #116086] split "\x20" doesn't work as documented

Thread Previous | Thread Next
From:
demerphq
Date:
February 24, 2013 15:16
Subject:
Re: [perl #116086] split "\x20" doesn't work as documented
Message ID:
CANgJU+X4EQ0eEB2xkGEbMYej1ByKvFag72qYVPFVQ9+ZRAYu5w@mail.gmail.com
On 15 December 2012 20:40, James E Keenan via RT
<perlbug-followup@perl.org> wrote:
> On Sat Dec 15 05:29:48 2012, sprout wrote:
>> On Fri Dec 14 19:03:21 2012, jkeenan wrote:
>> > Here is a patch for the regression test part of the solution.  Please
>> > review.
>>
>> Thank you.  That looks good to me.
>>
>
> Patch applied in cd346b2859236d69de687d1baa46c23e19af2202.
>
> We still need the fix for the problem.
>
> Note that some of the tests added were TODO-ed.  This may need
> mentioning in pod/perldelta.pod if the underlying problem is not fixed
> before the upcoming release.

I just pushed a patch sequence to get this fixed. My working copy is
at yves/revert_skipwhite, and I am smoking it at
smoke-me/yves-revert_skipwhite.

It is mostly a revert of 5255171e6cd0accee6f76ea2980e32b3b5b8e171.

I think FC's patch had some merit BTW, just didnt work out in the game
of Jenga that is perl.

We maybe will have to reopen RT# 94490 if it is merged. It depends how
you look at things.

The root of this patch sequence is the fact that:

split 0 || " ", $thing; #1

and

my $x=0; split $x || " ", $thing; #2

behave differently. The former behaves like:

split " ", $thing; #3

and the latter behaves like

split / /, $thing; #4

The patch that caused all these problems made #1 behave the same as #2
and #4, instead of its current behavior like #3.

Now, besides from the breakage in this ticket I personally think that
#2 should behave like #3, which means that the behavior of #1 is just
fine.

Anyway, its an interesting question, and I could not find an easy way
to make split $x || " " behave like split " " when $x is false. The
"special" behavior of #3 (called RXf_SKIPWHITE) is triggered only when
the pattern can be compile time determined. So far I don't understand
the optree logic involved to figure out how to make it work like I
expect.

An unrelated follow up for this patch sequence might be to look into
RXf_SPLIT and RXf_WHITE and RXf_SKIPWHITE. We use more bits
than we need. RXf_SKIPWHITE is only relevant when RXf_SPLIT is set,
and both RXf_WHITE and RXf_SKIPWHITE are used only in pp_split().
RXf_SPLIT is set only when dealing with a split "..", $thing and not
when dealing with split /../, $thing. (IOW it is badly named, it
should be called RXf_SKIPWHITE_ALLOWED or something like that.)
Simplifying this mess, and putting some or all of these flags
somewhere else, might free up some RXf_ bits (which are scarce).

Yves


-- 
perl -Mre=debug -e "/just|another|perl|hacker/"

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