Bug #13995 Updated: continuation of bug #13866: strtok() misparses empty fields

From: Date: Fri, 09 Nov 2001 07:12:03 +0000
Subject: Bug #13995 Updated: continuation of bug #13866: strtok() misparses empty fields
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-69863@lists.php.net to get a copy of this message
ID: 13995 Updated by: derick Reported By: rcpj@panix.com Old Status: Open Status: Closed Bug Type: Strings related Operating System: OpenBSD 2.9-stable PHP Version: 4.0.6 New Comment: This is the expected behavior. It conforms to alteast the C-libraries on Linux, Win32 and Solaris. Derick Previous Comments: ------------------------------------------------------------------------ [2001-11-08 20:29:57] rcpj@panix.com If a string contains two delimiters side by side (i.e. an empty field), strtok() treats the double delimiter as a single one and the results are shifted into the wrong variable. The previous version of the bug kept the second delimiter in the value returned by the function. This version does not, but it returns the wrong substring. PHP version is 4.2.0-dev (how do I report the correct version on the report form? Shouldn't there be at least a "other"?) Example of the bug: $String= "field1|field2||field4"; $Item1=strtok($String,"|"); // $Item1: field1 $Item2=strtok("|"); // $Item2: field2 $Item3=strtok("|"); // $Item3: field4 $Item4=strtok("|"); // $Item4 is empty compare the outputs of: http://www.pierrejelenc.com/PHP/test-module.php (correct) and http://www.web-ho.com/PHP/test-module.php (incorrect) ------------------------------------------------------------------------ Edit this bug report at http://bugs.php.net/?id=13995&edit=1

« previous php.dev (#69863) next »