Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get tests passing with frozen-string-literals enabled. #52

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/gettext/mo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ class HeaderRev1 < Header
: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".dup.force_encoding("ASCII-8BIT")
MAGIC_LITTLE_ENDIAN = "\xde\x12\x04\x95".dup.force_encoding("ASCII-8BIT")

def self.open(arg = nil, output_charset = nil)
result = self.new(output_charset)
Expand Down Expand Up @@ -325,7 +325,7 @@ def convert_encoding(string, original_string)
end

def generate_original_string(msgid, options)
string = ""
string = "".dup

msgctxt = options.delete(:msgctxt)
msgid_plural = options.delete(:msgid_plural)
Expand Down
2 changes: 1 addition & 1 deletion lib/gettext/po.rb
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def set_comment(msgid, comment, msgctxt=nil)
# @return [String] Formatted and joined PO entries. It is used for
# creating .po files.
def to_s(options={})
po_string = ""
po_string = "".dup

header_entry = @entries[[nil, ""]]
unless header_entry.nil?
Expand Down
14 changes: 7 additions & 7 deletions lib/gettext/po_entry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def initialize(type)
# @return [void]
def add_comment(new_comment)
if (new_comment and ! new_comment.empty?)
@extracted_comment ||= ""
@extracted_comment ||= "".dup
@extracted_comment << "\n" unless @extracted_comment.empty?
@extracted_comment << new_comment
end
Expand Down Expand Up @@ -366,7 +366,7 @@ def include_previous_comment?
end

def format_comments
formatted_comment = ""
formatted_comment = "".dup
if include_translator_comment?
formatted_comment << format_translator_comment
end
Expand Down Expand Up @@ -395,7 +395,7 @@ def format_extracted_comment

def format_reference_comment
max_line_width = @options[:max_line_width]
formatted_reference = ""
formatted_reference = "".dup
if not @entry.references.nil? and not @entry.references.empty?
formatted_reference << REFERENCE_COMMENT_MARK
line_width = 2
Expand All @@ -417,7 +417,7 @@ def format_reference_comment
end

def format_flag_comment
formatted_flags = ""
formatted_flags = "".dup
@entry.flags.each do |flag|
formatted_flags << format_comment(FLAG_MARK, flag)
end
Expand All @@ -431,7 +431,7 @@ def format_previous_comment
def format_comment(mark, comment)
return "" if comment.nil?

formatted_comment = ""
formatted_comment = "".dup
comment.each_line do |comment_line|
if comment_line == "\n"
formatted_comment << "#{mark}\n"
Expand All @@ -446,7 +446,7 @@ def format_obsolete_comment(comment)
mark = "#~"
return "" if comment.nil?

formatted_comment = ""
formatted_comment = "".dup
comment.each_line do |comment_line|
if /\A#[^~]/ =~ comment_line or comment_line.start_with?(mark)
formatted_comment << "#{comment_line.chomp}\n"
Expand All @@ -466,7 +466,7 @@ def format_message(message)
chunks = wrap_message(message)
return empty_formatted_message if chunks.empty?

formatted_message = ""
formatted_message = "".dup
if chunks.size > 1 or chunks.first.end_with?("\n")
formatted_message << empty_formatted_message
end
Expand Down
2 changes: 1 addition & 1 deletion lib/gettext/tools/msgcat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def remove_header_fields!(header_entry)
msgstr = header_entry.msgstr
return if msgstr.nil?

new_msgstr = ""
new_msgstr = "".dup
msgstr.each_line do |line|
case line
when /\A([\w\-]+):/
Expand Down
4 changes: 2 additions & 2 deletions lib/gettext/tools/parser/ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def parse_source(source)

po_entry = nil
line_no = nil
last_comment = ""
last_comment = "".dup
reset_comment = false
ignore_next_comma = false
rl.parse do |tk|
Expand Down Expand Up @@ -287,7 +287,7 @@ def parse_source(source)

case tk
when RubyToken::TkCOMMENT_WITH_CONTENT
last_comment = "" if reset_comment
last_comment = "".dup if reset_comment
if last_comment.empty?
comment1 = tk.value.lstrip
if comment_to_be_extracted?(comment1)
Expand Down
6 changes: 3 additions & 3 deletions test/test_po.rb
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class TestOrder < self
def setup
@po = GetText::PO.new
parser = GetText::POParser.new
parser.parse(<<-PO, @po)
parser.parse(<<-PO.dup, @po)
#: hello.rb:2
msgid "World"
msgstr ""
Expand Down Expand Up @@ -300,7 +300,7 @@ def setup

class TestHeader < self
def test_no_entry
@po[""] = <<-HEADER
@po[""] = <<-HEADER.dup
Project-Id-Version: test 1.0.0
POT-Creation-Date: 2012-10-31 12:40+0900
PO-Revision-Date: 2012-11-01 17:46+0900
Expand All @@ -312,7 +312,7 @@ def test_no_entry
Content-Transfer-Encoding: 8bit
Plural-Forms: nplurals=2; plural=(n != 1)
HEADER
@po[""].translator_comment = <<-HEADER_COMMENT
@po[""].translator_comment = <<-HEADER_COMMENT.dup
Japanese translations for test package.
Copyright (C) 2012 THE PACKAGE'S COPYRIGHT HOLDER
This file is distributed under the same license as the PACKAGE package.
Expand Down
2 changes: 1 addition & 1 deletion test/tools/test_msginit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def pot_header(options)
options = default_po_header_options.merge(options)
package_name = options[:package_name] || default_package_name
have_plural_forms = options[:have_plural_forms] || true
header = <<EOF
header = <<EOF.dup
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
Expand Down
8 changes: 4 additions & 4 deletions test/tools/test_msgmerge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ def merge

class TestUpdate < self
def test_msgstr
pot = <<-POT
pot = <<-POT.dup
msgid "hello"
msgstr ""
POT
po = <<-PO
po = <<-PO.dup
msgid "hello"
msgstr "bonjour"
PO
Expand All @@ -67,11 +67,11 @@ def merge(pot, po)

class TestObosleteEntry < self
def test_in_po
pot = <<-POT
pot = <<-POT.dup
msgid "hello"
msgstr ""
POT
po = <<-PO
po = <<-PO.dup
msgid "hello"
msgstr "bonjour"

Expand Down