From: Moriyoshi Koizumi Date: Sun, 7 Dec 2003 21:55:16 +0000 (+0000) Subject: Those casts are really necessary. X-Git-Tag: php-4.3.5RC1~92 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6771367c95c34106590e43b190469c0b51a3a4de;p=php Those casts are really necessary. # 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. # --- diff --git a/ext/standard/file.c b/ext/standard/file.c index 068c2b9151..5a8011cd9d 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -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++; }