summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--lib/irb/ruby-lex.rb23
2 files changed, 24 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 916d556571..44e094fe8c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Thu Dec 27 21:30:21 2012 Keiju Ishitsuka <keiju@ishitsuka.com>
+
+ * lib/irb/ruby-lex.rb: allow to handle recursive heredocs on
+ irb[Bug #5648].
+
Thu Dec 27 20:45:29 2012 Masaki Matsushita <glass.saga@gmail.com>
* ext/stringio/stringio.c (strio_getline): fix not to raise TypeError
diff --git a/lib/irb/ruby-lex.rb b/lib/irb/ruby-lex.rb
index 295dc9fa06..19b7b9198b 100644
--- a/lib/irb/ruby-lex.rb
+++ b/lib/irb/ruby-lex.rb
@@ -907,10 +907,25 @@ class RubyLex
end
@here_header = false
- while l = gets
- l = l.sub(/(:?\r)?\n\z/, '')
- if (indent ? l.strip : l) == quoted
- break
+# while l = gets
+# l = l.sub(/(:?\r)?\n\z/, '')
+# if (indent ? l.strip : l) == quoted
+# break
+# end
+# end
+
+ line = ""
+ while ch = getc
+ if ch == "\n"
+ if line == quoted
+ break
+ end
+ line = ""
+ else
+ line.concat ch unless indent && line == "" && /\s/ =~ ch
+ if @ltype != "'" && ch == "#" && peek(0) == "{"
+ identify_string_dvar
+ end
end
end