Parsing Ruby files with CRLF as the line termination does not report to
SCRIPT_LINES__ correctly
------------------------------------------------------------------------------------------------
Key: JRUBY-4922
URL: http://jira.codehaus.org/browse/JRUBY-4922
Project: JRuby
Issue Type: Bug
Components: Parser
Affects Versions: JRuby 1.5.1
Environment: windows
Reporter: Jay McGaffigan
Assignee: Thomas E Enebo
running : jruby -e "SCRIPT_LINES__={}; load 'fixtures/parse_sample1.rb';p
SCRIPT_LINES__"
on a source file with CRLF as line terminators fills up script_lines__
incorrectly. There appears to be a problem with the captureFeature and the
read() in the \r part of the switch statement in ByteArrayLexerSource.java
A fix is below. I also have created a few rubyspec tests for this case.
(working on getting that submitted now)
PATCH:
{noc}
--- a/src/org/jruby/lexer/yacc/ByteArrayLexerSource.java
+++ b/src/org/jruby/lexer/yacc/ByteArrayLexerSource.java
@@ -163,9 +163,16 @@ public class ByteArrayLexerSource extends LexerSource {
line++;
break;
case '\r':
+ // We are peeking ahead. but we need to make sure we
uncapture after this read. Ot
+ // we double report \n
if ((c = read()) != '\n') {
unread(c);
c = '\n';
+ } else {
+ if (captureSource){
+ uncaptureFeature(c);
+ captureFeature('\r');
+ }
}
break;
}
{noc}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email