]> granicus.if.org Git - php/commitdiff
Those casts are really necessary.
authorMoriyoshi Koizumi <moriyoshi@php.net>
Sun, 7 Dec 2003 21:55:16 +0000 (21:55 +0000)
committerMoriyoshi Koizumi <moriyoshi@php.net>
Sun, 7 Dec 2003 21:55:16 +0000 (21:55 +0000)
# Heads up; please be careful using is*() functions. The function of that kind
# takes an integer value as its argument and expects the value to be range of
# 0-255 as a parameter. So if you pass a plain char value to it, the char
# value will be converted implicitly to an integer value of the range
# -128 ~ 127, which will end up with an unwanted result, most likely with
# non-ASCII characters. This has been considered to be a big flaw in the
# specification of the ctype functions. However, the malfunction is not
# reproducible with the recent versions of the GNU C library because it is
# made to deal with such exceptional cases, while Microsoft's C library
# and several standard C libraries of BSD origin aren't.
#
# See also bug #10896, #12127, #18318, and #21689.
#

ext/standard/file.c

index 068c2b91512e0f2f53d452788182c8e2ff310710..5a8011cd9df13a5fd2b8a7832269cb9847dd149a 100644 (file)
@@ -2257,11 +2257,11 @@ PHP_FUNCTION(fgetcsv)
        re = e = buf + buf_len;
 
        /* strip leading spaces */
-       while (isspace(*s) && *s != delimiter) {
+       while (isspace((int)*(unsigned char *)s) && *s != delimiter) {
                s++;
        }
        /* strip trailing spaces */
-       while (isspace(*(--e)) && *e != delimiter);
+       while (isspace((int)*(unsigned char *)(--e)) && *e != delimiter);
        e++;
 
        array_init(return_value);
@@ -2305,7 +2305,7 @@ enclosure:
                        s = p = buf;
                        re = e = buf + buf_len;
                        /* strip trailing spaces */
-                       while (isspace(*(--e)) && *e != delimiter);
+                       while (isspace((int)*(unsigned char *)(--e)) && *e != delimiter);
                        e++;
                }