summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-07-10 09:43:07 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-07-10 09:43:07 +0000
commitcbdcd886863d456ccc3c055c5c118fbc9a61d917 (patch)
tree628a68088633321b77256b68c06996898f396814
parent82a63f3daa7472ce6c03bd7b68ea73fde1046754 (diff)
merge revision(s) 17881:
* lib/erb.rb (PercentScanner#scan): fix %% line bug. [ruby-core:17491] * test/erb/test_erb.rb (test_percent): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@18002 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog6
-rw-r--r--lib/erb.rb21
-rw-r--r--test/erb/test_erb.rb2
-rw-r--r--version.h2
4 files changed, 26 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 4a8b1f5..d288a86 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Thu Jul 10 18:42:37 2008 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
+
+ * lib/erb.rb (PercentScanner#scan): fix %% line bug. [ruby-core:17491]
+
+ * test/erb/test_erb.rb (test_percent): ditto.
+
Thu Jul 10 18:40:22 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/net/ftp.rb (Net::FTP#sendport): use divmod. [ruby-core:17557]
diff --git a/lib/erb.rb b/lib/erb.rb
index 2ae5a1a..f1661f9 100644
--- a/lib/erb.rb
+++ b/lib/erb.rb
@@ -427,7 +427,7 @@ class ERB
Scanner.regist_scanner(SimpleScanner2, nil, false)
class PercentScanner < Scanner # :nodoc:
- def scan
+ def scan(&blk)
stag_reg = /(.*?)(^%%|^%|<%%|<%=|<%#|<%|\z)/m
etag_reg = /(.*?)(%%>|%>|\z)/m
scanner = StringScanner.new(@src)
@@ -437,11 +437,24 @@ class ERB
elem = scanner[2]
if elem == '%%'
- elem = '%'
+ yield('%')
+ inline_scan(scanner.scan(/.*?(\n|\z)/), &blk)
elsif elem == '%'
- elem = PercentLine.new(scanner.scan(/.*?(\n|\z)/).chomp)
+ yield(PercentLine.new(scanner.scan(/.*?(\n|\z)/).chomp))
+ else
+ yield(elem)
end
- yield(elem)
+ end
+ end
+
+ def inline_scan(line)
+ stag_reg = /(.*?)(<%%|<%=|<%#|<%|\z)/m
+ etag_reg = /(.*?)(%%>|%>|\z)/m
+ scanner = StringScanner.new(line)
+ while ! scanner.eos?
+ scanner.scan(@stag ? etag_reg : stag_reg)
+ yield(scanner[1])
+ yield(scanner[2])
end
end
end
diff --git a/test/erb/test_erb.rb b/test/erb/test_erb.rb
index 48bd7b5..9359984 100644
--- a/test/erb/test_erb.rb
+++ b/test/erb/test_erb.rb
@@ -209,11 +209,13 @@ EOS
n.times do |i|%>
%% %%><%%<%= i%><%
end%>
+%%%
EOS
ans = <<EOS
%
% %%><%0
% %%><%1
+%%
EOS
assert_equal(ans, ERB.new(src, nil, '%').result)
end
diff --git a/version.h b/version.h
index cea836b..867558a 100644
--- a/version.h
+++ b/version.h
@@ -2,7 +2,7 @@
#define RUBY_RELEASE_DATE "2008-07-10"
#define RUBY_VERSION_CODE 187
#define RUBY_RELEASE_CODE 20080710
-#define RUBY_PATCHLEVEL 53
+#define RUBY_PATCHLEVEL 54
#define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 8