Permalink
Browse files

Fixed parsing of FFI's libffi ChangeLog

Time.parse doesn't handle arbitrary input well.  This caused a bug when
it couldn't figure out the format of the time properly.  Now we fall
back to splitting on two spaces to find the time when Time raises a
NoMethodError.

Fixes #165
  • Loading branch information...
1 parent bada629 commit 6dd8d41eb0b316af38a79ed43eb8e0bcd382ea8e @drbrain drbrain committed Jan 4, 2013
Showing with 36 additions and 3 deletions.
  1. +2 −1 History.rdoc
  2. +9 −1 lib/rdoc/parser/changelog.rb
  3. +25 −1 test/test_rdoc_parser_changelog.rb
View
@@ -1,4 +1,4 @@
-=== 4.0.0.preview3 / ??
+=== 4.0.0.preview3.1 / ??
As a preview release, please file bugs for any problems you have with rdoc at
https://github.com/rdoc/rdoc/issues
@@ -25,6 +25,7 @@ to build HTML documentation when installing gems.)
by Marcus Stollsteimer
* RDoc now ignores methods defined on constants instead of creating a fake
module. Bug #163 by Zachary Scott.
+ * Fixed ChangeLog parsing for FFI gem. Bug #165 by Zachary Scott.
=== 4.0.0.preview2.1 / 2012-12-14
@@ -102,7 +102,12 @@ def create_items items
def group_entries entries
entries.group_by do |title, _|
- Time.parse(title).strftime "%Y-%m-%d"
+ begin
+ Time.parse(title).strftime '%Y-%m-%d'
+ rescue NoMethodError, ArgumentError
+ time, = title.split ' ', 2
+ Time.parse(time).strftime '%Y-%m-%d'
+ end
end
end
@@ -139,6 +144,9 @@ def parse_entries
time = Time.parse entry_name
# HACK Ruby 1.8 does not raise ArgumentError for Time.parse "Other"
entry_name = nil unless entry_name =~ /#{time.year}/
+ rescue NoMethodError
+ time, = entry_name.split ' ', 2
+ time = Time.parse time
rescue ArgumentError
entry_name = nil
end
@@ -182,7 +182,9 @@ def test_group_entries
[ 'Tue Dec 4 08:32:10 2012 Eric Hodel <drbrain@segment7.net>',
%w[three four]],
[ 'Mon Dec 3 20:28:02 2012 Koichi Sasada <ko1@atdot.net>',
- %w[five six]]]
+ %w[five six]],
+ [ '2008-01-30 H.J. Lu <hongjiu.lu@intel.com>',
+ %w[seven eight]]]
expected = {
'2012-12-04' => [
@@ -193,6 +195,9 @@ def test_group_entries
'2012-12-03' => [
['Mon Dec 3 20:28:02 2012 Koichi Sasada <ko1@atdot.net>',
%w[five six]]],
+ '2008-01-30' => [
+ ['2008-01-30 H.J. Lu <hongjiu.lu@intel.com>',
+ %w[seven eight]]],
}
assert_equal expected, parser.group_entries(entries)
@@ -226,6 +231,25 @@ def test_parse_entries
assert_equal expected, parser.parse_entries
end
+ def test_parse_entries_bad_time
+ parser = util_parser <<-ChangeLog
+2008-01-30 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR libffi/34612
+ * src/x86/sysv.S (ffi_closure_SYSV): Pop 4 byte from stack when
+ returning struct.
+
+ ChangeLog
+
+ expected = [
+ [ '2008-01-30 H.J. Lu <hongjiu.lu@intel.com>',
+ [ 'src/x86/sysv.S (ffi_closure_SYSV): Pop 4 byte from stack when ' +
+ 'returning struct.']]
+ ]
+
+ assert_equal expected, parser.parse_entries
+ end
+
def test_parse_entries_gnu
parser = util_parser <<-ChangeLog
1998-08-17 Richard Stallman <rms@gnu.org>

0 comments on commit 6dd8d41

Please sign in to comment.