• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Line-number references wrong by several lines
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Line-number references wrong by several lines


  • Subject: Re: Line-number references wrong by several lines
  • From: Steve Sisak <email@hidden>
  • Date: Fri, 1 Feb 2008 10:08:32 -0500

At 12:47 PM +0100 2/1/08, Markus Hitter wrote:
Am 01.02.2008 um 05:09 schrieb Michael Rice:

It amazes me that this problem, which has been around forever, still plagues development environments and editors in general.

Because there is no definite solution to this? Is \n\r\n an empty Unix line followed by an empty DOS line or is it a Unix line followed by a Mac line and another Unix line?

There's a very simple algorithm:

1) As you're parsing through a stream and see either \n or \r treat it an end of line and remember which you saw.

2) If the next character in the stream is the other, drop it.

This handles any of \n \r \r\n or \n\r with a worst case failure of an extra blank line or dropped blank line in a file with mixed line endings which, for most things (including code) isn't an issue.

-Steve
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Line-number references wrong by several lines
      • From: Jeffrey Oleander <email@hidden>
References: 
 >Re: Line-number references wrong by several lines (From: Markus Hitter <email@hidden>)

  • Prev by Date: Re: Line-number references wrong by several lines
  • Next by Date: Re: Return key in Find dialog
  • Previous by thread: Re: Line-number references wrong by several lines
  • Next by thread: Re: Line-number references wrong by several lines
  • Index(es):
    • Date
    • Thread