Re: [PHP-DEV] string functions

2003-01-07 Thread Derick Rethans
On Sun, 5 Jan 2003, Leon Atkinson wrote:

  Because this behavior is not documented
 
 For the record, it is documented:
 http://www.php.net/manual/en/function.strstr.php
 
 If needle is not a string, it is converted to an integer and applied as the
 ordinal value of a character. 

Okay, a -1 on breaking this then.

Derick

-- 

-
 Derick Rethans http://derickrethans.nl/ 
 PHP Magazine - PHP Magazine for Professionals   http://php-mag.net/
-



-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DEV] string functions

2003-01-05 Thread Ilia A.
While converting the functions inside string.c to the new parameter parsing 
API and doing some general cleanup, I've come across an interesting 
'feature'.

Three string functions: stristr(), strstr() and strpos() have peculiar way of 
handling non string values passed as 'needle'. Instead of converting the 
needle to a string they instead convert it to an integer and search for a 
character equivalent to that integer.
This behavior causes a problem such as strstr(abc123, 1) returning false 
rather then returning 123 as one may expect. Because this behavior is not 
documented, I believe we could safely change it back to the behavior listed 
in the manual and the one defined in the function's prototype.
The con of this approach is that it may break scripts that really on the 
undocumented behavior, therefor I propose that this change would only go into 
the 4.4/5.0 branch at which point people will expect small behavioral 
changes.

Ilia

-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] string functions

2003-01-05 Thread Sascha Schumann
On Sun, 5 Jan 2003, Ilia A. wrote:

 While converting the functions inside string.c to the new parameter parsing
 API and doing some general cleanup, I've come across an interesting
 'feature'.

Ilia, there is a consensus that the new (slower) parameter
parsing is only supposed to be used for new functions.  It
makes little sense to replace faster, correct, working code
with its worse counterpart.

 Three string functions: stristr(), strstr() and strpos() have peculiar way of
 handling non string values passed as 'needle'. Instead of converting the
 needle to a string they instead convert it to an integer and search for a
 character equivalent to that integer.
 This behavior causes a problem such as strstr(abc123, 1) returning false
 rather then returning 123 as one may expect. Because this behavior is not
 documented, I believe we could safely change it back to the behavior listed

This should be documented then.

- Sascha

-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] string functions

2003-01-05 Thread Moriyoshi Koizumi
I mentioned a similar inconsistency of range() parameters in the past
and pointed out a possible BC breaking issue raised by your recent patch
on array.c in HEAD.

http://news.php.net/article.php?group=php.devarticle=91489
http://news.php.net/article.php?group=php.devarticle=92910

I meant no tricks by is_numeric_string() were needed and
the passed string values should always be regarded as a single character,
just as it was.

Moriyoshi 

On Sun, Jan 05, 2003 at 01:40:31PM -0500, Ilia A. wrote:
 While converting the functions inside string.c to the new parameter parsing 
 API and doing some general cleanup, I've come across an interesting 
 'feature'.
 
 Three string functions: stristr(), strstr() and strpos() have peculiar way of 
 handling non string values passed as 'needle'. Instead of converting the 
 needle to a string they instead convert it to an integer and search for a 
 character equivalent to that integer.
 This behavior causes a problem such as strstr(abc123, 1) returning false 
 rather then returning 123 as one may expect. Because this behavior is not 
 documented, I believe we could safely change it back to the behavior listed 
 in the manual and the one defined in the function's prototype.
 The con of this approach is that it may break scripts that really on the 
 undocumented behavior, therefor I propose that this change would only go into 
 the 4.4/5.0 branch at which point people will expect small behavioral 
 changes.
 
 Ilia

-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] string functions

2003-01-05 Thread Leon Atkinson
 Because this behavior is not documented

For the record, it is documented:
http://www.php.net/manual/en/function.strstr.php

If needle is not a string, it is converted to an integer and applied as the
ordinal value of a character. 

And I'm sure it's worked this way for at least three years.

Leon





-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php