From:             cschneid at cschneid dot com
Operating system: 
PHP version:      5.2.2
PHP Bug Type:     Feature/Change Request
Bug description:  file() should support FILE_SKIP_EMPTY_LINES without 
FILE_IGNORE_NEW_LINES

Description:
------------
Currently file() only skips (FILE_SKIP_EMPTY_LINES) when also using      
FILE_IGNORE_NEW_LINES at the same time. I think it would be      
preferable if it would work without that flag too, ignoring lines      
only consisting of a newline.     
 
Patch  
diff -u -r1.409.2.6.2.17 file.c 
--- ext/standard/file.c 23 Feb 2007 16:22:20 -0000      
1.409.2.6.2.17 
+++ ext/standard/file.c 7 May 2007 16:17:27 -0000 
@@ -750,6 +750,10 @@ 
                        do { 
                                p++; 
 parse_eol: 
+                               if (skip_blank_lines && (p-s == 1) 
&& (*s == eol_marker)) { 
+                                       s = p; 
+                                       continue; 
+                               } 
                                if (PG(magic_quotes_runtime)) { 
                                        /* s is in target_buf which 
is freed at the end of the function */ 
                                        slashed = php_addslashes(s, 
(p-s), &len, 0 TSRMLS_CC); 
 

Reproduce code:
---------------
Input file x:
a   
   
b

Code:
var_dump(file("x", FILE_SKIP_EMPTY_LINES));

Expected result:
----------------
a 
b 
 

Actual result:
--------------
a 
 
b 
 

-- 
Edit bug report at http://bugs.php.net/?id=41315&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=41315&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=41315&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=41315&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=41315&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=41315&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=41315&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=41315&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=41315&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=41315&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=41315&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=41315&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=41315&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=41315&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=41315&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=41315&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=41315&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=41315&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=41315&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=41315&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=41315&r=mysqlcfg

Reply via email to