]> granicus.if.org Git - php/commitdiff
Fixed bug #30945 (make ctype_* functions return FALSE on empty strings).
authorIlia Alshanetsky <iliaa@php.net>
Tue, 30 Nov 2004 16:55:55 +0000 (16:55 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Tue, 30 Nov 2004 16:55:55 +0000 (16:55 +0000)
Slight performance improvement of multi-byte string checking via ctype_*.

ext/ctype/ctype.c

index 78f6d293e3b7c8c68bd960e9d19480869c1707bd..834ace200b7abb80b687482a4781cfe1ba43afa6 100644 (file)
@@ -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; \