develooper Front page | perl.perl5.porters | Postings from January 2010

Re: [perl #62646] Maximum string length with substr

Thread Previous | Thread Next
From:
Nicholas Clark
Date:
January 5, 2010 14:24
Subject:
Re: [perl #62646] Maximum string length with substr
Message ID:
20100105222406.GG2582@plum.flirble.org
On Tue, Jan 05, 2010 at 10:18:42PM +0000, Zefram wrote:
> Attached patch should fix bug #62646.

> +++ b/t/re/substr.t

> @@ -682,4 +682,19 @@ is($x, "\x{100}\x{200}\xFFb");
>      is(substr($a,1,1), 'b');
>  }
>  
> +# [perl #62646] offsets exceeding 32 bits on 64-bit system
> +SKIP: {
> +    skip("32-bit system", 4) unless ~0 > 0xffffffff;
> +    my $a = "abc";
> +    my $r;
> +    $w = 0;
> +    $r = substr($a, 0xffffffff, 1);
> +    is($r, undef);
> +    is($w, 1);
> +    $w = 0;
> +    $r = substr($a, 0xffffffff+1, 1);
> +    is($r, undef);
> +    is($w--, 1);
> +}
> +
>  }

Any reason for $w-- right at the end, instead of just $w?

Nicholas Clark

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