Project

General

Profile

Actions

Feature #8699

closed

Feature request: Detect line encoding problems

Added by mattsains (Matthew Sainsbury) over 10 years ago. Updated over 10 years ago.

Status:
Closed
Target version:
-
[ruby-core:56240]

Description

This is a feature which would have saved me hours of debugging.

If you give ruby a file with old mac line endings, ruby does not recognise them as new lines. I think this is ok because it's easy to convert to a format that ruby can deal with, but it would be great if ruby would recognise all these \r characters without any new lines and give a warning that there's probably an encoding problem.

For example, given this code:

hi "hello"[\r]
def hi(x)[\r]
puts x[\r]
end

instead of returning:

test.rb:1: syntax error, unexpected keyword_def, expecting end-of-input
end puts x
^

it would return

test.rb: Warning: Have you got the wrong line endings in this file? Both UNIX-style (\n) and Windows-style (\r\n) are recognised by ruby, but your file has something different.

Not really an urgent feature but it would be helpful in some cases. Shouldn't be too hard to implement

Updated by ko1 (Koichi Sasada) over 10 years ago

  • Assignee set to naruse (Yui NARUSE)
Actions #2

Updated by nobu (Nobuyoshi Nakada) over 10 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r42691.
Matthew, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


parse.y: warn CR

Actions

Also available in: Atom PDF

Like0
Like0Like0