]> granicus.if.org Git - php/commitdiff
Pointer arithmetic with char * rather than void *
authorRolland Santimano <rolland@php.net>
Mon, 5 Sep 2005 16:37:45 +0000 (16:37 +0000)
committerRolland Santimano <rolland@php.net>
Mon, 5 Sep 2005 16:37:45 +0000 (16:37 +0000)
ext/standard/string.c

index 0969130611d2c2d65c71c8bd85107b7aea29f312..c474d9d27bcba828a648097b2c8e7d165a82f360 100644 (file)
@@ -5273,20 +5273,20 @@ PHP_FUNCTION(substr_count)
        if (haystack_type == IS_UNICODE) {
                while ((p = zend_u_memnstr((UChar *)p, (UChar *)needle, needle_len, (UChar *)endp)) != NULL) {
                        /*(UChar *)p += needle_len; // GCC 4.0.0 cannot compile this */
-                       p += UBYTES(needle_len);
+                       p = (UChar *)p + UBYTES(needle_len);
                        count++;
                }
        } else {
                if (needle_len == 1) {
                        cmp = ((char *)needle)[0];
-                       while ((p = memchr(p, cmp, endp - p))) {
+                       while ((p = memchr(p, cmp, (char *)endp - (char *)p))) {
                                count++;
-                               (char *)p++;
+                               p = (char *)p + 1;
                        }
                } else {
                        while ((p = php_memnstr((char *)p, (char *)needle, needle_len, (char *)endp))) {
                                /*(char *)p += needle_len; // GCC 4.0.0 cannot compile this */
-                               p += needle_len;
+                               p = (char *)p + needle_len;
                                count++;
                        }
                }
@@ -5420,7 +5420,7 @@ PHP_FUNCTION(str_pad)
        } else {
                for (i = 0; i < left_pad; i++)
                        *((char *)result + result_len++) = *((char *)padstr + (i % padstr_len));
-               memcpy(result + result_len, input, input_len);
+               memcpy((char *)result + result_len, input, input_len);
                result_len += input_len;
                for (i = 0; i < right_pad; i++)
                        *((char *)result + result_len++) = *((char *)padstr + (i % padstr_len));