]> granicus.if.org Git - php/commitdiff
Fix EOL markers for file() so that Mac EOL work correctly.
authorWez Furlong <wez@php.net>
Tue, 24 Sep 2002 02:46:38 +0000 (02:46 +0000)
committerWez Furlong <wez@php.net>
Tue, 24 Sep 2002 02:46:38 +0000 (02:46 +0000)
ext/standard/file.c

index 12d15a3b4583c1e7ac0cf8ac96d09b721f346476..c19a0977bd07c9fb00ec9caf5c4af8a50e765f89 100644 (file)
@@ -468,6 +468,7 @@ PHP_FUNCTION(file)
        char *slashed, *target_buf;
        register int i = 0;
        int target_len, len;
+       char eol_marker = '\n';
        zend_bool use_include_path = 0;
        zend_bool reached_eof = 0;
        php_stream *stream;
@@ -507,9 +508,14 @@ PHP_FUNCTION(file)
                                reached_eof = 1;
                        }
                }
+               
+               /* mini-hack because I don't feel like re-writing this whole function */
+               if (stream->flags & PHP_STREAM_FLAG_EOL_MAC)
+                       eol_marker = '\r';
+               
                if (!reached_eof) {
                        target_len += strlen(target_buf+target_len);
-                       if (target_buf[target_len-1] != '\n') {
+                       if (target_buf[target_len-1] != eol_marker) {
                                continue;
                        }
                }