#30393 [Fbk->Csd]: CLI and ISAPI give different line endings in ERRORS.LOG file.

From: Date: Fri, 25 Nov 2005 13:48:47 +0000
Subject: #30393 [Fbk->Csd]: CLI and ISAPI give different line endings in ERRORS.LOG file.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-88965@lists.php.net to get a copy of this message
ID: 30393 User updated by: richard dot quadling at bandvulc dot co dot uk Reported By: richard dot quadling at bandvulc dot co dot uk -Status: Feedback +Status: Closed Bug Type: *Web Server problem Operating System: Windows XP SP2 PHP Version: 5.0.2 New Comment: ARGH! Why do I work with monkeys. Hmmm. Nice mirror! Sorry. Previous Comments: ------------------------------------------------------------------------ [2005-11-25 13:28:17] tony2001@php.net Reopen when you try 5.1 for real. ------------------------------------------------------------------------ [2005-11-25 13:24:35] richard dot quadling at bandvulc dot co dot uk The main.c line I'm interested in was changed 3 months ago ... http://cvs.php.net/co.php/php-src/main/main.c?r=1.645 Revision 1.645, Wed Aug 17 03:52:17 2005 (3 months, 1 week ago) by sniper Changed since 1.644: +2 -2 Log: Fix EOLs under winblows log_file = VCWD_FOPEN(PG(error_log), "ab"); Prior to this it was just "a" ------------------------------------------------------------------------ [2005-11-25 13:22:13] richard dot quadling at bandvulc dot co dot uk NOT IIS!!!!!! I'm using Sambar Server with ISAPI and CLI. If the error log file is now being opened in binary mode, then the line endings are wrong somehow. <?php $a = 1 / 0; ?> generates different line endings when run via a browser and when run via the CLI. [25-Nov-2005 12:03:57] PHP Warning: Division by zero in Unknown on line 0 [25-Nov-2005 12:03:58] PHP Warning: Division by zero in Unknown on line 0 [25-Nov-2005 12:03:59] PHP Warning: Division by zero in Unknown on line 0 [25-Nov-2005 12:03:59] PHP Warning: Division by zero in Unknown on line 0 [25-Nov-2005 12:03:59] PHP Warning: Division by zero in Unknown on line 0 [25-Nov-2005 12:03:59] PHP Warning: Division by zero in Unknown on line 0 [25-Nov-2005 12:03:59] PHP Warning: Division by zero in Unknown on line 0 [25-Nov-2005 12:04:00] PHP Warning: Division by zero in Unknown on line 0 [25-Nov-2005 12:04:00] PHP Warning: Division by zero in Unknown on line 0 [25-Nov-2005 12:04:00] PHP Warning: Division by zero in Unknown on line 0 [25-Nov-2005 12:05:13] PHP Warning: Division by zero in Unknown on line 0 [25-Nov-2005 12:05:14] PHP Warning: Division by zero in Unknown on line 0 [25-Nov-2005 12:05:15] PHP Warning: Division by zero in Unknown on line 0 [25-Nov-2005 12:05:15] PHP Warning: Division by zero in Unknown on line 0 [25-Nov-2005 12:05:15] PHP Warning: Division by zero in Unknown on line 0 [25-Nov-2005 12:05:15] PHP Warning: Division by zero in Unknown on line 0 [25-Nov-2005 12:05:15] PHP Warning: Division by zero in Unknown on line 0 [25-Nov-2005 12:05:15] PHP Warning: Division by zero in Unknown on line 0 Additional \r when ran from ISAPI. Here is the thing. In windows, fopen("file","a") will open a file in TEXT mode. This means ANY \n will become \r\n when the file is written. This is the nature of the C library. All known and correct. So, if the line ending as defined in main\php.h says that lines endings are \r\n AND the file is opened in text mode (which it was), then \r\n will become \r\r\n which is does. BUT only for the ISAPI version. Now. I've amended the script to show DIRECTORY_SEPARATOR and PHP_EOL ... <?php var_dump(DIRECTORY_SEPARATOR); var_dump(PHP_EOL); $a = 1 / 0; ?> On both ISAPI and CLI, the output on screen is the same. The PHP_EOL is 2 bytes in size. This is correct. But when that gets to the error log file, it is wrong. An extra \r has crept in somewhere. This is on PHP 5.0.5. I'm just about to try out 5.1.0 ------------------------------------------------------------------------ [2005-11-25 13:03:51] tony2001@php.net >The function php_log_err (main\main.c line 344) only uses > append mode - "a" - to open the file. No, it doesn't: log_file = VCWD_FOPEN(PG(error_log), "ab"); >Which will be in text mode and "\r\n" will >become "\r\r\n", as "\n" => "\r\n" in a text file. Could you plz explain this? Why "\n" will suddenly become "\r\n" ? ------------------------------------------------------------------------ [2005-11-25 12:49:02] richard dot quadling at bandvulc dot co dot uk Still not working. Errors logged from CLI and ISAPI have different line endings on Windows. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/30393 -- Edit this bug report at http://bugs.php.net/?id=30393&edit=1

« previous php.bugs (#88965) next »