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

From: Date: Fri, 25 Nov 2005 12:22:15 +0000
Subject: #30393 [Fbk->Opn]: 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-88944@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:           Open
-Bug Type:         IIS related
+Bug Type:         Scripting Engine problem
 Operating System: Windows XP SP2
 PHP Version:      5.0.2
 New Comment:

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


Previous Comments:
------------------------------------------------------------------------

[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.

------------------------------------------------------------------------

[2005-03-15 01:00:18] php-bugs at lists dot php dot net

No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".

------------------------------------------------------------------------

[2005-03-07 22:04:26] sniper@php.net

Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip



------------------------------------------------------------------------

[2004-10-11 10:38:27] richard dot quadling at bandvulc dot co dot uk

I may have got the CLI / ISAPI bits back to front half way through
this.

Sorry.

------------------------------------------------------------------------

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


Thread (10 messages)

« previous php.bugs (#88944) next »