php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #16535 Line breaks not correctly counted when file has Mac line endings
Submitted: 2002-04-10 16:26 UTC Modified: 2002-08-22 01:00 UTC
Votes:3
Avg. Score:4.7 ± 0.5
Reproduced:3 of 3 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: danradigan at yahoo dot com Assigned:
Status: No Feedback Package: Scripting Engine problem
PHP Version: 4.1.2 OS: Mac OS X
Private report: No CVE-ID: None
 [2002-04-10 16:26 UTC] danradigan at yahoo dot com
When a file is saved using Macintosh-style line breaks 
('\r') and there is some kind of error in the script (maybe 
a parse error, etc.) then the line number that is reported 
is always less than the line it occured on.  In my script PHP told me line 84, but it was actually 93.

It's a fairly minor thing, but annoying nonetheless. A 
workaround, obviously, is to make sure you save your 
scripts with Unix line-breaks ('\n').

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-04-10 16:27 UTC] danradigan at yahoo dot com
Related bug Bug #10631, refiled per that bug since I still see it.
 [2002-04-10 16:33 UTC] derick@php.net
Hello,

can you verify if this occurs when you have mixed line endings (other then only Mac endings) or just always (only Mac line endings).

Derick
 [2002-08-22 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a month, 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".
 [2003-06-25 17:01 UTC] dradigan at macromedia dot com
I still see this bug in 4.3.0.  I have a file that I 
will email you that shows the problem.  If I use mac 
line endings the error is at line 44.  If I use unix 
line endings it shows at 67.
 [2003-06-25 17:03 UTC] dradigan at macromedia dot com
But to be clear, this does show up with pure mac line 
endings
 [2006-02-09 17:25 UTC] mpaugh at voicenet dot com
I'm still seeing this as of PHP 5. If the file is saved using Windows line endings or Unix line endings, the line number for an error is accurate. But with Mac line endings, the line number is always way off. I cannot test with a file with mixed line endings since my text editor enforces the line endings for me based on what I choose (PC/Unix/Mac). If it's necessary I can write a program to generate a file with mixed line endings. I believe, however, that only Mac line endings (e.g. isolated \r characters) cause the problem. (My guess is the engine is looking only for \n but...)

I am using a Windows XP box with a text editor that lets me choose which line endings to save files in, if that is any help. The problem is not isolated to just the Mac OS.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 15:01:29 2024 UTC