diff --git a/ChangeLog b/ChangeLog index eb8ef2d64f..421178595c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Tue Oct 23 06:04:07 2012 Aaron Patterson + + * ext/psych/lib/psych/scalar_scanner.rb: Fix scalar_scanner to + understand strings starting with an underscore and containing only + digits. Thanks Kelley Reynolds. + + * test/psych/test_scalar_scanner.rb: test for fix + Tue Oct 23 06:00:41 2012 Aaron Patterson * ext/psych/lib/psych.rb: Changed comment in psych.rb to update new diff --git a/ext/psych/lib/psych/scalar_scanner.rb b/ext/psych/lib/psych/scalar_scanner.rb index fa2d385a63..8727adecb4 100644 --- a/ext/psych/lib/psych/scalar_scanner.rb +++ b/ext/psych/lib/psych/scalar_scanner.rb @@ -24,7 +24,7 @@ module Psych return string if @string_cache.key?(string) case string - when /^[A-Za-z~]/ + when /^[A-Za-z_~]/ if string.length > 5 @string_cache[string] = true return string diff --git a/test/psych/test_scalar_scanner.rb b/test/psych/test_scalar_scanner.rb index cf0dfff6aa..1397020c88 100644 --- a/test/psych/test_scalar_scanner.rb +++ b/test/psych/test_scalar_scanner.rb @@ -87,5 +87,9 @@ module Psych def test_scan_true assert_equal true, ss.tokenize('true') end + + def test_scan_strings_starting_with_underscores + assert_equal "_100", ss.tokenize('_100') + end end end