#31324 [Opn->Bgs]: function strlen miscounts
| From: | iliaa@php.net | Date: | Wed, 29 Dec 2004 20:42:54 +0000 |
| Subject: | #31324 [Opn->Bgs]: function strlen miscounts | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-71253@lists.php.net to get a copy of this message | ||
ID: 31324
Updated by: iliaa@php.net
Reported By: phpbug at tore dot cc
-Status: Open
+Status: Bogus
Bug Type: Strings related
Operating System: Solaris 10
PHP Version: 5.0.2
New Comment:
Sounds like either a compiler or libc bug. I cannot replicate this on
my systems either.
Previous Comments:
------------------------------------------------------------------------
[2004-12-29 19:13:28] phpbug at tore dot cc
I might add that I tried php-5.0.3 on an intel-based solaris 10 machine
and there were no problems with the strlen.
------------------------------------------------------------------------
[2004-12-29 07:34:41] phpbug at tore dot cc
I have used gcc2 and gcc3 to compile.
The machine is a sparc.
The problem occurs on solaris 9 and solaris 10.
If you suspect that this is a solaris problem, can you extract the code
for 'strlen' in php. I could make some tests in C....
------------------------------------------------------------------------
[2004-12-28 23:59:37] derick@php.net
It still works fine for me on Linux. Which compiler did you use to
compile PHP (gcc or sun workshop), and what kind of platform do you
use? intel (32/64), sparc...
------------------------------------------------------------------------
[2004-12-28 23:40:36] phpbug at tore dot cc
Sorry, my mistake!
It seems to work on one char long strings.
I made a better script (still avoiding loops...).
<?php
$s=pack("C*",0x8e,0x8f);
$t=pack("C*",0x8e);
$u=pack("C*",0x8e,0x8f,0x90);
print "The variable s has the length: " . strlen($s) . "\n";
print "The variable t has the length: " . strlen($t) . "\n";
print "The variable u has the length: " . strlen($u) . "\n";
?>
Result:
The variable s has the length: 1
The variable t has the length: 1
The variable u has the length: 2
The result should be:
The variable s has the length: 2
The variable t has the length: 1
The variable u has the length: 3
Since s=2 chars, t=1 char and u 3 chars long.
Lets try another test with 7 bit chars.
<?php
$s=pack("C*",0x30,0x31);
$t=pack("C*",0x30);
$u=pack("C*",0x30,0x31,0x32);
print "The variable s has the length: " . strlen($s) . "\n";
print "The variable t has the length: " . strlen($t) . "\n";
print "The variable u has the length: " . strlen($u) . "\n";
?>
Result:
The variable s has the length: 2
The variable t has the length: 1
The variable u has the length: 3
As expected. No problem with low values on the chars.
------------------------------------------------------------------------
[2004-12-28 23:07:29] derick@php.net
Please try using this CVS snapshot:
http://snaps.php.net/php5-STABLE-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5.0-win32-latest.zip
Both in 4.3.10RC2, 5.0.3-dev, and 5.1.0-dev it prints as expected:
The variable s has the length: 1 (actual length) 1
So please try a snapshot.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/31324
--
Edit this bug report at http://bugs.php.net/?id=31324&edit=1