[DRE-commits] [ruby-gettext] 03/04: remove patch restoring compatibility with ruby1.8

Hleb Valoshka tsfgnu-guest at moszumanska.debian.org
Sun Apr 13 19:16:51 UTC 2014


This is an automated email from the git hooks/post-receive script.

tsfgnu-guest pushed a commit to branch master
in repository ruby-gettext.

commit 9a15fd71072f99a23ca3acfa15155b2564147654
Author: Hleb Valoshka <375gnu at gmail.com>
Date:   Sun Apr 13 22:10:56 2014 +0300

    remove patch restoring compatibility with ruby1.8
---
 .../0005-Restore-compatibility-with-Ruby-1.8.patch | 530 ---------------------
 debian/patches/series                              |   1 -
 2 files changed, 531 deletions(-)

diff --git a/debian/patches/0005-Restore-compatibility-with-Ruby-1.8.patch b/debian/patches/0005-Restore-compatibility-with-Ruby-1.8.patch
deleted file mode 100644
index 306a7bb..0000000
--- a/debian/patches/0005-Restore-compatibility-with-Ruby-1.8.patch
+++ /dev/null
@@ -1,530 +0,0 @@
-From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Bobbio?= <lunar at debian.org>
-Date: Mon, 2 Sep 2013 09:48:15 +0200
-Subject: Restore compatibility with Ruby 1.8
-
----
- lib/gettext/core_ext/iconv.rb    |  110 ++++++++++++++++++++++++++++++++++++++
- lib/gettext/core_ext/string.rb   |   91 +++++++++++++++++++++++++++++++
- lib/gettext/locale_path.rb       |    1 +
- lib/gettext/mo.rb                |   54 +++++++++++++------
- lib/gettext/tools/parser/erb.rb  |   16 +++---
- lib/gettext/tools/parser/ruby.rb |    7 ++-
- lib/gettext/tools/xgettext.rb    |    6 ++-
- test/gettext-test-utils.rb       |   23 ++++++++
- test/test_parser.rb              |    2 +
- test/test_po_parser.rb           |    4 ++
- test/tools/parser/test_ruby.rb   |    2 +
- test/tools/test_xgettext.rb      |   24 +++++----
- 12 files changed, 304 insertions(+), 36 deletions(-)
- create mode 100644 lib/gettext/core_ext/iconv.rb
- create mode 100644 lib/gettext/core_ext/string.rb
-
---- /dev/null
-+++ b/lib/gettext/core_ext/iconv.rb
-@@ -0,0 +1,110 @@
-+# encoding: utf-8
-+=begin
-+  iconv.rb - Pseudo Iconv class. Supports Iconv.iconv, Iconv.conv.
-+
-+  For Matz Ruby:
-+  If you don't have iconv but glib2, this library uses glib2 iconv functions.
-+
-+  For JRuby:
-+  Use Java String class to convert strings.
-+
-+  Copyright (C) 2004-2009  Masao Mutoh
-+
-+  You may redistribute it and/or modify it under the same
-+  license terms as Ruby or LGPL.
-+=end
-+
-+begin
-+  require 'iconv.so'
-+rescue LoadError
-+  # Pseudo Iconv class
-+  #
-+  # ==== For Matz Ruby:
-+  # If you don't have iconv but Ruby/GLib2, this library uses Ruby/GLib2's
-+  # iconv functions.
-+  #
-+  # Ruby/GLib is a module which is provided from Ruby-GNOME2 Project.
-+  # You can get binaries for Win32(One-Click Ruby Installer).
-+  # <URL: http://ruby-gnome2.sourceforge.jp/>
-+  # ==== For JRuby:
-+  # Use Java String class to convert strings.
-+  class Iconv
-+    module Failure; end
-+    class InvalidEncoding < ArgumentError;  include Failure; end
-+    class IllegalSequence < ArgumentError;  include Failure; end
-+    class InvalidCharacter < ArgumentError; include Failure; end
-+
-+    if RUBY_PLATFORM =~ /java/
-+      def self.conv(to, from, str)
-+        raise InvalidCharacter, "the 3rd argument is nil" unless str
-+        begin
-+          str = java.lang.String.new(str.unpack("C*").to_java(:byte), from)
-+          str.getBytes(to).to_ary.pack("C*")
-+        rescue java.io.UnsupportedEncodingException
-+          raise InvalidEncoding
-+        end
-+      end
-+    else
-+      begin
-+        require 'glib2'
-+
-+        def self.check_glib_version?(major, minor, micro) # :nodoc:
-+          (GLib::BINDING_VERSION[0] > major ||
-+           (GLib::BINDING_VERSION[0] == major &&
-+            GLib::BINDING_VERSION[1] > minor) ||
-+           (GLib::BINDING_VERSION[0] == major &&
-+            GLib::BINDING_VERSION[1] == minor &&
-+            GLib::BINDING_VERSION[2] >= micro))
-+        end
-+
-+        if check_glib_version?(0, 11, 0)
-+          # This is a function equivalent of Iconv.iconv.
-+          # * to: encoding name for destination
-+          # * from: encoding name for source
-+          # * str: strings to be converted
-+          # * Returns: Returns an Array of converted strings.
-+          def self.conv(to, from, str)
-+            begin
-+              GLib.convert(str, to, from)
-+            rescue GLib::ConvertError => e
-+              case e.code
-+              when GLib::ConvertError::NO_CONVERSION
-+                raise InvalidEncoding.new(str)
-+              when GLib::ConvertError::ILLEGAL_SEQUENCE
-+                raise IllegalSequence.new(str)
-+              else
-+                raise InvalidCharacter.new(str)
-+              end
-+            end
-+          end
-+        else
-+          def self.conv(to, from, str) # :nodoc:
-+            begin
-+              GLib.convert(str, to, from)
-+            rescue
-+              raise IllegalSequence.new(str)
-+            end
-+          end
-+        end
-+      rescue LoadError
-+        def self.conv(to, from, str) # :nodoc:
-+          warn "Iconv was not found." if $DEBUG
-+          str
-+        end
-+      end
-+    end
-+    def self.iconv(to, from, str)
-+      conv(to, from, str).split(//)
-+    end
-+  end
-+end
-+
-+if __FILE__ == $0
-+  puts Iconv.iconv("EUC-JP", "UTF-8", "ほげ").join
-+  begin
-+    puts Iconv.iconv("EUC-JP", "EUC-JP", "ほげ").join
-+  rescue Iconv::Failure
-+    puts $!
-+    puts $!.class
-+  end
-+end
---- /dev/null
-+++ b/lib/gettext/core_ext/string.rb
-@@ -0,0 +1,91 @@
-+# encoding: utf-8
-+
-+=begin
-+  string.rb - Extension for String.
-+
-+  Copyright (C) 2005-2009 Masao Mutoh
-+
-+  You may redistribute it and/or modify it under the same
-+  license terms as Ruby or LGPL.
-+=end
-+
-+# Extension for String class. This feature is included in Ruby 1.9 or later but not occur TypeError.
-+#
-+# String#% method which accept "named argument". The translator can know
-+# the meaning of the msgids using "named argument" instead of %s/%d style.
-+class String
-+
-+  unless instance_methods.find {|m| m.to_s == 'bytesize'}
-+    # For older ruby (such as ruby-1.8.5)
-+    alias :bytesize :size
-+  end
-+
-+  begin
-+    formatted = "%{key}" % {:key => "value"}
-+    raise ArgumentError if formatted != "value"
-+  rescue ArgumentError
-+    alias :_old_format_m :% # :nodoc:
-+
-+    PERCENT_MATCH_RE = Regexp.union(
-+        /%%/,
-+        /%\{(.+?)\}/,
-+        /%<(.+?)>(.*?\d*\.?\d*[bBdiouxXeEfgGcps])/
-+    )
-+
-+    # call-seq:
-+    #  %(arg)
-+    #  %(hash)
-+    #
-+    # Format - Uses str as a format specification, and returns the result of applying it to arg.
-+    # If the format specification contains more than one substitution, then arg must be
-+    # an Array containing the values to be substituted. See Kernel::sprintf for details of the
-+    # format string. This is the default behavior of the String class.
-+    # * arg: an Array or other class except Hash.
-+    # * Returns: formatted String
-+    #
-+    #  (e.g.) "%s, %s" % ["Masao", "Mutoh"]
-+    #
-+    # Also you can use a Hash as the "named argument". This is recommanded way for Ruby-GetText
-+    # because the translators can understand the meanings of the msgids easily.
-+    # * hash: {:key1 => value1, :key2 => value2, ... }
-+    # * Returns: formatted String
-+    #
-+    #  (e.g.)
-+    #         For strings.
-+    #         "%{firstname}, %{familyname}" % {:firstname => "Masao", :familyname => "Mutoh"}
-+    #
-+    #         With field type to specify format such as d(decimal), f(float),...
-+    #         "%<age>d, %<weight>.1f" % {:age => 10, :weight => 43.4}
-+    def %(args)
-+      if args.kind_of?(Hash)
-+        ret = dup
-+        ret.gsub!(PERCENT_MATCH_RE) {|match|
-+          if match == '%%'
-+            '%'
-+          elsif $1
-+            key = $1.to_sym
-+            args.has_key?(key) ? args[key] : match
-+          elsif $2
-+            key = $2.to_sym
-+            args.has_key?(key) ? sprintf("%#{$3}", args[key]) : match
-+          end
-+        }
-+        ret
-+      else
-+        ret = gsub(/%([{<])/, '%%\1')
-+        begin
-+          ret._old_format_m(args)
-+        rescue ArgumentError => e
-+          if $DEBUG
-+            $stderr.puts "  The string:#{ret}"
-+            $stderr.puts "  args:#{args.inspect}"
-+            puts e.backtrace
-+          else
-+            raise ArgumentError, e.message
-+          end
-+        end
-+      end
-+    end
-+  end
-+end
-+
---- a/lib/gettext/locale_path.rb
-+++ b/lib/gettext/locale_path.rb
-@@ -11,6 +11,7 @@
- =end
- 
- require 'rbconfig'
-+require 'gettext/core_ext/string'
- 
- module GetText
-   # Treats locale-path for mo-files.
---- a/lib/gettext/mo.rb
-+++ b/lib/gettext/mo.rb
-@@ -43,8 +43,12 @@
-       :trans_sysdep_tab_offset
-     end
- 
--    MAGIC_BIG_ENDIAN    = "\x95\x04\x12\xde".force_encoding("ASCII-8BIT")
--    MAGIC_LITTLE_ENDIAN = "\xde\x12\x04\x95".force_encoding("ASCII-8BIT")
-+    MAGIC_BIG_ENDIAN    = "\x95\x04\x12\xde"
-+    MAGIC_LITTLE_ENDIAN = "\xde\x12\x04\x95"
-+    if "".respond_to?(:force_encoding)
-+      MAGIC_BIG_ENDIAN.force_encoding("ASCII-8BIT")
-+      MAGIC_LITTLE_ENDIAN.force_encoding("ASCII-8BIT")
-+    end
- 
-     def self.open(arg = nil, output_charset = nil)
-       result = self.new(output_charset)
-@@ -308,24 +312,40 @@
-     attr_reader :charset, :nplurals, :plural
- 
-     private
--    def convert_encoding(string, original_string)
--      return string if @output_charset.nil? or @charset.nil?
-+    if "".respond_to?(:encode)
-+      def convert_encoding(string, original_string)
-+        return string if @output_charset.nil? or @charset.nil?
-+
-+        if Encoding.find(@output_charset) == Encoding.find(@charset)
-+          string.force_encoding(@output_charset)
-+          return string
-+        end
- 
--      if Encoding.find(@output_charset) == Encoding.find(@charset)
--        string.force_encoding(@output_charset)
--        return string
-+        begin
-+          string.encode(@output_charset, @charset)
-+        rescue EncodingError
-+          if $DEBUG
-+            warn "@charset = ", @charset
-+            warn "@output_charset = ", @output_charset
-+            warn "msgid = ", original_string
-+            warn "msgstr = ", string
-+          end
-+          string
-+        end
-       end
--
--      begin
--        string.encode(@output_charset, @charset)
--      rescue EncodingError
--        if $DEBUG
--          warn "@charset = ", @charset
--          warn "@output_charset = ", @output_charset
--          warn "msgid = ", original_string
--          warn "msgstr = ", string
-+    else
-+      require 'gettext/core_ext/iconv'
-+      def convert_encoding(string, original_string)
-+        begin
-+          Iconv.conv(@output_charset, @charset, string)
-+        rescue Iconv::Failure
-+          if $DEBUG
-+            warn "@charset = ", @charset
-+            warn "@output_charset = ", @output_charset
-+            warn "msgid = ", original_string
-+            warn "msgstr = ", str
-+          end
-         end
--        string
-       end
-     end
- 
---- a/lib/gettext/tools/parser/erb.rb
-+++ b/lib/gettext/tools/parser/erb.rb
-@@ -64,13 +64,15 @@
-       content = IO.read(@path)
-       src = ERB.new(content).src
- 
--      # Force the src encoding back to the encoding in magic comment
--      # or original content.
--      encoding = detect_encoding(src) || content.encoding
--      src.force_encoding(encoding)
-+      if src.respond_to?(:encode)
-+        # Force the src encoding back to the encoding in magic comment
-+        # or original content.
-+        encoding = detect_encoding(src) || content.encoding
-+        src.force_encoding(encoding)
- 
--      # Remove magic comment prepended by erb in Ruby 1.9.
--      src = src.gsub(MAGIC_COMMENT, "")
-+        # Remove magic comment prepended by erb in Ruby 1.9.
-+        src = src.gsub(MAGIC_COMMENT, "")
-+      end
- 
-       RubyParser.new(@path, @options).parse_source(src)
-     end
---- a/lib/gettext/tools/parser/ruby.rb
-+++ b/lib/gettext/tools/parser/ruby.rb
-@@ -211,13 +211,16 @@
-     def parse
-       source = IO.read(@path)
- 
--      encoding = detect_encoding(source) || source.encoding
--      source.force_encoding(encoding)
-+      if source.respond_to?(:encode)
-+        encoding = detect_encoding(source) || source.encoding
-+        source.force_encoding(encoding)
-+      end
- 
-       parse_source(source)
-     end
- 
-     def detect_encoding(source)
-+      return nil unless source.respond_to?(:force_encoding)
-       binary_source = source.dup.force_encoding("ASCII-8BIT")
-       if /\A.*coding\s*[=:]\s*([[:alnum:]\-_]+)/ =~ binary_source
-         $1.gsub(/-(?:unix|mac|dos)\z/, "")
---- a/test/gettext-test-utils.rb
-+++ b/test/gettext-test-utils.rb
-@@ -22,6 +22,10 @@
- require "tempfile"
- require "time"
- 
-+unless String.method_defined?(:encode)
-+  require "iconv"
-+end
-+
- require "gettext"
- 
- module GetTextTestUtils
-@@ -41,4 +45,23 @@
-   def teardown_tmpdir
-     FileUtils.rm_rf(@tmpdir, :secure => true) if @tmpdir
-   end
-+
-+  def need_encoding
-+    unless defined?(Encoding)
-+      omit("This test needs encoding.")
-+    end
-+  end
-+
-+  def set_encoding(string, encoding)
-+    return unless string.respond_to?(:force_encoding)
-+    string.force_encoding(encoding)
-+  end
-+
-+  def encode(string, encoding)
-+    if string.respond_to?(:encode)
-+      string.encode(encoding)
-+    else
-+      Iconv.iconv(encoding, "UTF-8", string).join("")
-+    end
-+  end
- end
---- a/test/test_parser.rb
-+++ b/test/test_parser.rb
-@@ -133,6 +133,8 @@
-     include GetTextTestUtils
- 
-     def test_detect_encoding
-+      need_encoding
-+
-       euc_file = Tempfile.new("euc-jp.rhtml")
-       euc_file.open
-       euc_file.puts("<%#-*- coding: euc-jp -*-%>")
---- a/test/test_po_parser.rb
-+++ b/test/test_po_parser.rb
-@@ -306,6 +306,8 @@
-     end
-   end
- 
-+  if defined?(Encoding)
-+
-   class TestHeader < self
-     class TestEncoding < self
-       def test_known
-@@ -337,4 +339,6 @@
-       end
-     end
-   end
-+
-+  end
- end
---- a/test/tools/parser/test_ruby.rb
-+++ b/test/tools/parser/test_ruby.rb
-@@ -68,6 +68,8 @@
-   end
- 
-   class TestDetectEncoding < self
-+    setup :need_encoding
-+
-     def test_ascii_and_hyphen
-       assert_equal("euc-jp", detect_encoding("# coding: euc-jp"))
-     end
---- a/test/tools/test_xgettext.rb
-+++ b/test/tools/test_xgettext.rb
-@@ -120,6 +120,8 @@
- 
-   class TestEncoding < self
-     def test_different_encoding_from_current_locale
-+      need_encoding
-+
-       rhtml = <<-EOR
- <%#-*- coding: sjis -*-%>
- <html>
-@@ -132,34 +134,36 @@
- </html>
- EOR
-       File.open(@rhtml_file_path, "w") do |rhtml_file|
--        rhtml_file.puts(rhtml.encode("sjis"))
-+        rhtml_file.puts(encode(rhtml, "sjis"))
-       end
- 
-       @xgettext.run("--output", @pot_file_path, @rhtml_file_path)
- 
-       encoding = "UTF-8"
-       pot_content = File.read(@pot_file_path)
--      pot_content.force_encoding(encoding)
-+      set_encoding(pot_content, encoding)
-       expected_content = <<-EOP
- #{header}
- #: ../templates/xgettext.rhtml:7
- msgid "わたし"
- msgstr ""
- EOP
--      expected_content = expected_content.encode(encoding)
-+      expected_content = encode(expected_content, encoding)
-       assert_equal(expected_content, pot_content)
-     end
- 
-     def test_multiple_encodings
-+      need_encoding
-+
-       File.open(@rb_file_path, "w") do |rb_file|
--        rb_file.puts(<<-EOR.encode("euc-jp"))
-+        rb_file.puts(encode(<<-EOR, "euc-jp"))
- # -*- coding: euc-jp -*-
- _("こんにちは")
- EOR
-       end
- 
-       File.open(@rhtml_file_path, "w") do |rhtml_file|
--        rhtml_file.puts(<<-EOR.encode("cp932"))
-+        rhtml_file.puts(encode(<<-EOR, "cp932"))
- <%# -*- coding: cp932 -*-%>
- <h1><%= _("わたし") %></h1>
- EOR
-@@ -169,7 +173,7 @@
- 
-       encoding = "UTF-8"
-       pot_content = File.read(@pot_file_path)
--      pot_content.force_encoding(encoding)
-+      set_encoding(pot_content, encoding)
-       expected_content = <<-EOP
- #{header}
- #: ../lib/xgettext.rb:2
-@@ -180,7 +184,7 @@
- msgid "わたし"
- msgstr ""
- EOP
--      expected_content = expected_content.encode(encoding)
-+      expected_content = encode(expected_content, encoding)
-       assert_equal(expected_content, pot_content)
-     end
-   end
-@@ -351,13 +355,15 @@
-     end
- 
-     def test_to_code
-+      need_encoding
-+
-       output_encoding = "EUC-JP"
-       pot_content = generate(<<-EOR, "--output-encoding", output_encoding)
- # -*- coding: utf-8 -*-
- 
- _("わたし")
- EOR
--      pot_content.force_encoding(output_encoding)
-+      set_encoding(pot_content, output_encoding)
- 
-       options = {:to_code => output_encoding}
-       expected_pot = <<-EOP
-@@ -366,7 +372,7 @@
- msgid "わたし"
- msgstr ""
- EOP
--      expected_pot = expected_pot.encode(output_encoding)
-+      expected_pot = encode(expected_pot, output_encoding)
- 
-       assert_equal(expected_pot, pot_content)
-     end
diff --git a/debian/patches/series b/debian/patches/series
index 5353464..5674133 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -2,4 +2,3 @@
 0002-Make-test-unit-notify-and-test-unit-rr-optional-to-r.patch
 0003-Do-not-use-Bundler-in-Rakefile.patch
 0004-Use-system-racc-in-Rakefile.patch
-0005-Restore-compatibility-with-Ruby-1.8.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/ruby-gettext.git



More information about the Pkg-ruby-extras-commits mailing list