From:             zoe dot slattery at googlemail dot com
Operating system: Linux/Windows/OSX
PHP version:      5CVS-2007-10-05 (snap)
PHP Bug Type:     Scripting Engine problem
Bug description:  Inconsistent return values from strspn()

Description:
------------
I'm not sure if this is one defect or two (or none:-)) - it would be good
to understand the expected behaviour as there are a number of other MAC OSX
test failures. 

(1) strspn() does not return consistent values on Linux/Windows if
"$start"> PHP_INT_MAX

(2) The values returned on MAC OSX (10.4) are different to the values
returned on Linux & Windows.

It's reasonably easy to see what is happening in the Windows/Linux case.
The double that is passed to strspn() is cast as a long in
zend_parse_parameters, and in some cases this means that the resulting long
happens to be within a reasonable range (see comments in reproduce code).

>From the users' point of view it would be better if strspn() returned the
same thing for all values of $start which are outside the expected range.

I'm not sure why the behaviour is different on Mac, it appears that what
comes back from zend_parse_parameters is "-1" in example 3 & 4.

Reproduce code:
---------------
<?php
$str = '2468 who do we appreciate';
$mask = '1234567890';

//Linux result, after zend_parse_parameters start = 2147483647, expect
bool(false)
//Mac result, start = 2147483647, bool(false)
$start = PHP_INT_MAX;
var_dump( strspn($str,$mask,$start) );

//Linux result, after zend_parse_parameters start = -23, expect
bool(false)?, get int(2)
//Mac result, start = -23, int(2)
$start = PHP_INT_MAX * 2 - 21;
var_dump( strspn($str,$mask,$start) );

//Linux result, after zend_parse_parameters start = 0, expect
bool(false)?, get int(4)
//Mac result, start = -1, int(0)
$start = PHP_INT_MAX * 2 + 2;
var_dump( strspn($str,$mask,$start) );

//Linux result, after zend_parse_parameters start = -3, expect
bool(false)?, get int(0)
//Mac result, start = -1, int(0)
$start = PHP_INT_MAX * 4 + 1;
var_dump( strspn($str,$mask,$start) );
?>


Expected result:
----------------
I'd expect to see
(1) the same result for every invalid value of $start on (Win/Lin)
(2) the same result on Mac as I see on Win/Lin

Actual result:
--------------
Lin/Win

bool(false)
int(2)
int(4)
int(0)

Mac
bool(false)
int(2)
int(0)
int(0)

-- 
Edit bug report at http://bugs.php.net/?id=42868&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=42868&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=42868&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=42868&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=42868&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=42868&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=42868&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=42868&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=42868&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=42868&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=42868&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=42868&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=42868&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=42868&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=42868&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=42868&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=42868&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=42868&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=42868&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=42868&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=42868&r=mysqlcfg

Reply via email to