[DRE-commits] [SCM] ruby-locale.git branch, master, updated. debian/2.0.5-5-4-g264af45
Hleb Valoshka
375GNU at Gmail.COM
Wed Aug 22 19:30:13 UTC 2012
The following commit has been merged in the master branch:
commit 7f2d76988bbedaae4b051093ed560325de34fe97
Author: Hleb Valoshka <375GNU at Gmail.COM>
Date: Wed Aug 22 11:39:32 2012 +0300
correct patch for charset hanling, fix set_locale in jruby test
diff --git a/debian/patches/0004-fix-bugs-with-charset-handling.patch b/debian/patches/0004-fix-bugs-with-charset-handling.patch
index d41f362..1ea0e63 100644
--- a/debian/patches/0004-fix-bugs-with-charset-handling.patch
+++ b/debian/patches/0004-fix-bugs-with-charset-handling.patch
@@ -1,39 +1,15 @@
From: Hleb Valoshka <375GNU at Gmail.COM>
-Date: Sat, 14 Jul 2012 00:00:47 +0300
+Date: Wed, 22 Aug 2012 11:36:29 +0300
Subject: fix bugs with charset handling
-Fixes #520181, #521169
+ Fixes #520181
---
- lib/locale.rb | 6 +++---
- lib/locale/driver/env.rb | 4 ++--
- lib/locale/tag/posix.rb | 5 +++--
- lib/locale/tag/simple.rb | 2 +-
- 4 files changed, 9 insertions(+), 8 deletions(-)
+ lib/locale/driver/env.rb | 4 ++--
+ lib/locale/tag/posix.rb | 23 ++++++++++++++++-------
+ lib/locale/taglist.rb | 6 +-----
+ test/test_detect_general.rb | 10 +++++-----
+ 4 files changed, 24 insertions(+), 19 deletions(-)
-diff --git a/lib/locale.rb b/lib/locale.rb
-index 10bc71e..e4f44bf 100644
---- a/lib/locale.rb
-+++ b/lib/locale.rb
-@@ -94,7 +94,7 @@ module Locale
- @@locale_driver_module
- end
-
-- DEFAULT_LANGUAGE_TAG = Locale::Tag::Simple.new("en") #:nodoc:
-+ DEFAULT_LANGUAGE_TAG = Locale::Tag::Simple.new("C") #:nodoc:
-
- # Sets the default locale as the language tag
- # (Locale::Tag's class or String(such as "ja_JP")).
-@@ -196,8 +196,8 @@ module Locale
- # Returns the language tags which are variations of the current locales order by priority.
- #
- # For example, if the current locales are ["fr", "ja_JP", "en_US", "en-Latn-GB-VARIANT"],
-- # then returns ["fr", "ja_JP", "en_US", "en-Latn-GB-VARIANT", "en_Latn_GB", "en_GB", "ja", "en"].
-- # "en" is the default locale(You can change it using set_default).
-+ # then returns ["fr", "ja_JP", "en_US", "en-Latn-GB-VARIANT", "en_Latn_GB", "en_GB", "ja", "C"].
-+ # "C" is the default locale(You can change it using set_default).
- # The default locale is added at the end of the list even if it isn't exist.
- #
- # Usually, this method is used to find the locale data as the path(or a kind of IDs).
diff --git a/lib/locale/driver/env.rb b/lib/locale/driver/env.rb
index 3d08500..78df8c5 100644
--- a/lib/locale/driver/env.rb
@@ -53,36 +29,115 @@ index 3d08500..78df8c5 100644
return Locale::Tag::Posix.parse(loc)
end
diff --git a/lib/locale/tag/posix.rb b/lib/locale/tag/posix.rb
-index b04aa54..c23dd0a 100644
+index b04aa54..1ce944a 100644
--- a/lib/locale/tag/posix.rb
+++ b/lib/locale/tag/posix.rb
-@@ -26,13 +26,14 @@ module Locale
-
- def initialize(language, region = nil, charset = nil, modifier = nil)
- @charset, @modifier = charset, modifier
-+ @charset ||= `locale charmap`.chomp rescue nil
- super(language, region)
+@@ -30,9 +30,9 @@ module Locale
end
def self.parse(tag)
- if tag =~ /^(C|POSIX)$/
+- if tag =~ /^(C|POSIX)$/
- ret = self.new("en", "US")
- ret.tag = tag
-+ ret = self.new("C")
-+ ret.tag = "C"
++ if tag =~ /\A(C|POSIX)(?:\.([^@]+))?\Z/
++ ret = self.new("en", "US", $2)
++ ret.tag = $1
ret
elsif tag =~ TAG_RE
ret = self.new($1, $2, $3, $4)
-diff --git a/lib/locale/tag/simple.rb b/lib/locale/tag/simple.rb
-index bf3719b..d52268e 100644
---- a/lib/locale/tag/simple.rb
-+++ b/lib/locale/tag/simple.rb
-@@ -75,7 +75,7 @@ module Locale
- def initialize(language, region = nil)
- raise "language can't be nil." unless language
- @language, @region = language, region
-- @language = @language.downcase if @language
-+ @language = @language.downcase unless @language == 'C'
- @region = @region.upcase if @region
+@@ -47,10 +47,15 @@ module Locale
+ # <language>_<COUNTRY>.<CHARSET>@<MODIFIER>
+ # (e.g.) "ja_JP.EUC-JP at Modifier"
+ def to_s
+- s = @language.dup
+- s << "_#{@region}" if @region
+- s << ".#{@charset}" if @charset
+- s << "@#{@modifier}" if @modifier
++ if posix?
++ s = tag.dup
++ s << ".#{@charset}" if @charset
++ else
++ s = @language.dup
++ s << "_#{@region}" if @region
++ s << ".#{@charset}" if @charset
++ s << "@#{@modifier}" if @modifier
++ end
+ s
end
+@@ -92,6 +97,10 @@ module Locale
+ end
+ end
+
++ def posix?
++ ['POSIX', 'C'].include? tag
++ end
++
+ end
+ end
+ end
+diff --git a/lib/locale/taglist.rb b/lib/locale/taglist.rb
+index e5d879c..2b6c8e7 100644
+--- a/lib/locale/taglist.rb
++++ b/lib/locale/taglist.rb
+@@ -46,11 +46,7 @@ module Locale
+ end
+ # Returns the top priority charset. (posix)
+ def charset
+- if self[0].respond_to? :charset
+- self[0].charset
+- else
+- ::Locale.driver_module.charset
+- end
++ self[0].respond_to?(:charset) and self[0].charset or ::Locale.driver_module.charset
+ end
+ memoize :charset
+
+diff --git a/test/test_detect_general.rb b/test/test_detect_general.rb
+index 08b912d..ab71857 100644
+--- a/test/test_detect_general.rb
++++ b/test/test_detect_general.rb
+@@ -6,14 +6,14 @@ class TestDetectGeneral < Test::Unit::TestCase
+ def setup
+ Locale.clear_all
+ ENV["LC_ALL"] = nil
+- ENV["LC_MESSAGES"] = nil
++ ENV["LC_CTYPE"] = nil
+ ENV["LANG"] = nil
+ ENV["LANGUAGE"] = nil
+ end
+
+ def test_lc_all
+ ENV["LC_ALL"] = "ja_JP.eucJP"
+- ENV["LC_MESSAGES"] = "zh_CN.UTF-8" #Ignored.
++ ENV["LC_CTYPE"] = "zh_CN.UTF-8" #Ignored.
+ ENV["LANG"] = "ko_KR.UTF-8" #Ignored.
+ ENV["LANGUAGE"] = nil
+
+@@ -29,7 +29,7 @@ class TestDetectGeneral < Test::Unit::TestCase
+
+ def test_lc_messages
+ ENV["LC_ALL"] = nil
+- ENV["LC_MESSAGES"] = "ja_JP.eucJP"
++ ENV["LC_CTYPE"] = "ja_JP.eucJP"
+ ENV["LANG"] = "ko_KR.UTF-8" #Ignored.
+ ENV["LANGUAGE"] = nil
+
+@@ -45,7 +45,7 @@ class TestDetectGeneral < Test::Unit::TestCase
+
+ def test_lang
+ ENV["LC_ALL"] = nil
+- ENV["LC_MESSAGES"] = nil
++ ENV["LC_CTYPE"] = nil
+ ENV["LANG"] = "ja_JP.eucJP"
+ ENV["LANGUAGE"] = nil
+
+@@ -61,7 +61,7 @@ class TestDetectGeneral < Test::Unit::TestCase
+
+ def test_lang_complex
+ ENV["LC_ALL"] = "zh_CN.UTF-8" # Ignored.
+- ENV["LC_MESSAGES"] = "ko_KR.UTF-8" #Ingored.
++ ENV["LC_CTYPE"] = "ko_KR.UTF-8" #Ingored.
+ ENV["LANG"] = "en_US.UTF-8" # Ignored.
+ ENV["LANGUAGE"] ="ja_JP.eucJP:zh_CN.UTF-8"
+
diff --git a/debian/patches/0005-fix-call-to-java.util.Locale.new.patch b/debian/patches/0005-fix-call-to-java.util.Locale.new.patch
new file mode 100644
index 0000000..cdb71d4
--- /dev/null
+++ b/debian/patches/0005-fix-call-to-java.util.Locale.new.patch
@@ -0,0 +1,22 @@
+From: Hleb Valoshka <375GNU at Gmail.COM>
+Date: Wed, 22 Aug 2012 11:37:03 +0300
+Subject: fix call to java.util.Locale.new
+
+ see: http://docs.oracle.com/javase/7/docs/api/java/util/Locale.html#def_variant
+---
+ test/test_driver_jruby.rb | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/test/test_driver_jruby.rb b/test/test_driver_jruby.rb
+index 692d340..6fe7bbf 100644
+--- a/test/test_driver_jruby.rb
++++ b/test/test_driver_jruby.rb
+@@ -12,7 +12,7 @@ begin
+ end
+
+ def set_locale(tag)
+- java.util.Locale.setDefault(java.util.Locale.new(tag.language, tag.region, tag.variants.to_s))
++ java.util.Locale.setDefault(java.util.Locale.new(tag.language, tag.region, tag.variants.join('_')))
+ end
+
+ def test_charset
diff --git a/debian/patches/series b/debian/patches/series
index 343da39..ed2fbe6 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -2,3 +2,4 @@
0002-fix-better-check-of-current-locale-setter-input.patch
0003-fix-untainted-path-under-safe-1.patch
0004-fix-bugs-with-charset-handling.patch
+0005-fix-call-to-java.util.Locale.new.patch
--
ruby-locale.git
More information about the Pkg-ruby-extras-commits
mailing list