php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24367 strspn('rRc', 'R') returns 0
Submitted: 2003-06-27 15:21 UTC Modified: 2003-06-30 04:51 UTC
From: php at projectjj dot com Assigned:
Status: Not a bug Package: Strings related
PHP Version: 4.3.2 OS: Windows 2k SP3
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: php at projectjj dot com
New email:
PHP Version: OS:

 

 [2003-06-27 15:21 UTC] php at projectjj dot com
Description:
------------
echo strspn('rRc', 'R'); // returns 0
echo strspn('Rrc', 'R'); // returns 1

Shouldn't both of these return 1?

Reproduce code:
---------------
echo strspn('rRc', 'R');

Expected result:
----------------
1


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-06-27 17:36 UTC] marcot at tabini dot ca
No, because strspn is case-sensitive. In the first instance, there is no initial string that contains characters from your second parameter (the string begins with 'r', which doesn't match any of the characters in 'R'). In the second case, the first character of 'Rrc' contains characters from 'R', and therefore the function returns 1.
 [2003-06-27 17:45 UTC] sniper@php.net
It works exactly the same as the libc counterpart,
that's the expected way. Not bug.


 [2003-06-27 19:05 UTC] php at projectjj dot com
I did expect it to be case-sensitive, but by your description that means it will only search from the start of the string.
A matching substring does not count.

From the manual:
"strspn --  Find length of initial segment matching mask"
The use of 'segment' made me think otherwise.

Perhaps a re-wording is needed...
 [2003-06-30 04:51 UTC] mgf@php.net
What about "initial segment" do you find unclear?  Why would you think the use of "segment" in any way contradicts the use of "initial"?  I cannot think of any way of rewording this that would be appreciably clearer.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 05:01:28 2024 UTC