summaryrefslogtreecommitdiff
path: root/ext/ctype
diff options
context:
space:
mode:
authorIlia Alshanetsky <iliaa@php.net>2004-11-30 16:55:55 +0000
committerIlia Alshanetsky <iliaa@php.net>2004-11-30 16:55:55 +0000
commit349c134061c8936f3caec52073b691f9a8196d5b (patch)
tree600ed0ffaef1e2897b082d8279652159c3cdd903 /ext/ctype
parent5f949d21c20a9e5debe91843318f82c0b379b400 (diff)
downloadphp-git-349c134061c8936f3caec52073b691f9a8196d5b.tar.gz
Fixed bug #30945 (make ctype_* functions return FALSE on empty strings).
Slight performance improvement of multi-byte string checking via ctype_*.
Diffstat (limited to 'ext/ctype')
-rw-r--r--ext/ctype/ctype.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/ext/ctype/ctype.c b/ext/ctype/ctype.c
index 78f6d293e3..834ace200b 100644
--- a/ext/ctype/ctype.c
+++ b/ext/ctype/ctype.c
@@ -106,11 +106,11 @@ PHP_MINFO_FUNCTION(ctype)
convert_to_string(c); \
case IS_STRING: \
{ \
- char *p; \
- int n, len; \
- p=Z_STRVAL_P(c); \
- len = Z_STRLEN_P(c); \
- for(n=0;n<len;n++) { \
+ char *p = Z_STRVAL_P(c), *e = Z_STRVAL_P(c) + Z_STRLEN_P(c); \
+ if (e == p) { \
+ RETURN_FALSE; \
+ } \
+ while (p < e) { \
if(!iswhat((int)*(unsigned char *)(p++))) RETURN_FALSE; \
} \
RETURN_TRUE; \