#35427 [Opn]: str_word_count handles() '-' incorrectly

From: Date: Tue, 29 Nov 2005 08:45:36 +0000
Subject: #35427 [Opn]: str_word_count handles() '-' incorrectly
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-89361@lists.php.net to get a copy of this message
 ID:               35427
 User updated by:  tomas_matousek at hotmail dot com
 Reported By:      tomas_matousek at hotmail dot com
 Status:           Open
 Bug Type:         Strings related
 Operating System: *
 PHP Version:      5.1.0
 New Comment:

One more correction:

while (isalpha(*p) || *p == '\'' || (*p == '-' && (isalpha(*(p+1))
||
char_list && ch[(unsigned char)*(p+1)]))
|| (char_list && ch[(unsigned char)*p]))


Previous Comments:
------------------------------------------------------------------------

[2005-11-29 09:43:46] tomas_matousek at hotmail dot com

Sorry, this should be correct:

while (isalpha(*p) || *p == '\'' || (*p == '-' && (isalpha(*(p+1))
||
char_list && ch[(unsigned char)*p])) || (char_list && ch[(unsigned
char)*p]))

------------------------------------------------------------------------

[2005-11-29 09:41:04] tomas_matousek at hotmail dot com

File string.c, line 4744:

while (isalpha(*p) || *p == '\'' || (*p == '-' && isalpha(*(p+1)))
||
(char_list && ch[(unsigned char)*p])) 

should be:

while (isalpha(*p) || *p == '\'' || (*p == '-' && (isalpha(*(p+1)
||
(char_list && ch[(unsigned char)*p])))) || (char_list && ch[(unsigned
char)*p]))

------------------------------------------------------------------------

[2005-11-28 21:50:24] sniper@php.net

Really, where? Do you have a patch to fix this?

------------------------------------------------------------------------

[2005-11-28 21:27:28] tomas_matousek at hotmail dot com

No, I needn't. str_word_count("bar-var") returns 1, so '-' is
considered as a part of the word if it is followed by 'word'
character.

See the source code. The bug is clear there.

------------------------------------------------------------------------

[2005-11-28 09:47:30] sniper@php.net

Yes, you need to add the - in the list.

------------------------------------------------------------------------

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/35427

-- 
Edit this bug report at http://bugs.php.net/?id=35427&edit=1


Thread (13 messages)

« previous php.bugs (#89361) next »