summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-10-05 13:27:48 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-10-05 13:27:48 +0000
commit805c20a8e59315f15dbb22ac1518de6a27385039 (patch)
tree81b4d726b3ee9e06afa2f0781dfbad263c62dbff /lib
parentfab171e541f7b7373efe386ae956d7a44ce4e330 (diff)
* lib/pp.rb: Use frozen_string_literal: true.
* lib/prettyprint.rb: Ditto. * lib/resolv.rb: Ditto. * lib/tmpdir.rb: Ditto. * test/test_pp.rb: Ditto. * test/test_prettyprint.rb: Ditto. * tool/transcode-tblgen.rb: Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52042 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/pp.rb6
-rw-r--r--lib/prettyprint.rb8
-rw-r--r--lib/resolv.rb4
-rw-r--r--lib/tmpdir.rb3
4 files changed, 14 insertions, 7 deletions
diff --git a/lib/pp.rb b/lib/pp.rb
index 3c73463c9c..ef787bb764 100644
--- a/lib/pp.rb
+++ b/lib/pp.rb
@@ -1,3 +1,5 @@
+# -*- frozen_string_literal: true -*-
+
require 'prettyprint'
module Kernel
@@ -9,7 +11,7 @@ module Kernel
#
# See the PP module for more information.
def pretty_inspect
- PP.pp(self, '')
+ PP.pp(self, ''.dup)
end
private
@@ -347,7 +349,7 @@ class PP < PrettyPrint
if /\(PP::ObjectMixin\)#/ =~ Object.instance_method(:method).bind(self).call(:pretty_print).inspect
raise "pretty_print is not overridden for #{self.class}"
end
- PP.singleline_pp(self, '')
+ PP.singleline_pp(self, ''.dup)
end
end
end
diff --git a/lib/prettyprint.rb b/lib/prettyprint.rb
index 7e989374b7..dc63e49321 100644
--- a/lib/prettyprint.rb
+++ b/lib/prettyprint.rb
@@ -1,3 +1,5 @@
+# -*- frozen_string_literal: true -*-
+#
# This class implements a pretty printing algorithm. It finds line breaks and
# nice indentations for grouped structure.
#
@@ -40,7 +42,7 @@ class PrettyPrint
# output
# end
#
- def PrettyPrint.format(output='', maxwidth=79, newline="\n", genspace=lambda {|n| ' ' * n})
+ def PrettyPrint.format(output=''.dup, maxwidth=79, newline="\n", genspace=lambda {|n| ' ' * n})
q = PrettyPrint.new(output, maxwidth, newline, &genspace)
yield q
q.flush
@@ -54,7 +56,7 @@ class PrettyPrint
# The invocation of +breakable+ in the block doesn't break a line and is
# treated as just an invocation of +text+.
#
- def PrettyPrint.singleline_format(output='', maxwidth=nil, newline=nil, genspace=nil)
+ def PrettyPrint.singleline_format(output=''.dup, maxwidth=nil, newline=nil, genspace=nil)
q = SingleLine.new(output)
yield q
output
@@ -77,7 +79,7 @@ class PrettyPrint
# The block is used to generate spaces. {|width| ' ' * width} is used if it
# is not given.
#
- def initialize(output='', maxwidth=79, newline="\n", &genspace)
+ def initialize(output=''.dup, maxwidth=79, newline="\n", &genspace)
@output = output
@maxwidth = maxwidth
@newline = newline
diff --git a/lib/resolv.rb b/lib/resolv.rb
index ce36acf01f..fbfd822799 100644
--- a/lib/resolv.rb
+++ b/lib/resolv.rb
@@ -1,3 +1,5 @@
+# -*- frozen_string_literal: true -*-
+
require 'socket'
require 'timeout'
require 'thread'
@@ -1426,7 +1428,7 @@ class Resolv
class MessageEncoder # :nodoc:
def initialize
- @data = ''
+ @data = ''.dup
@names = {}
yield self
end
diff --git a/lib/tmpdir.rb b/lib/tmpdir.rb
index 494725cb33..eafde411a0 100644
--- a/lib/tmpdir.rb
+++ b/lib/tmpdir.rb
@@ -1,3 +1,4 @@
+# -*- frozen_string_literal: true -*-
#
# tmpdir - retrieve temporary directory path
#
@@ -111,7 +112,7 @@ class Dir
suffix &&= (String.try_convert(suffix) or
raise ArgumentError, "unexpected suffix: #{suffix.inspect}")
t = Time.now.strftime("%Y%m%d")
- path = "#{prefix}#{t}-#{$$}-#{rand(0x100000000).to_s(36)}"
+ path = "#{prefix}#{t}-#{$$}-#{rand(0x100000000).to_s(36)}".dup
path << "-#{n}" if n
path << suffix if suffix
path