Skip to content

Commit

Permalink
String.allocate/new returns a binary string
Browse files Browse the repository at this point in the history
  • Loading branch information
jfirebaugh committed Mar 10, 2012
1 parent ce5f44a commit 4203195
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
7 changes: 0 additions & 7 deletions kernel/common/string.rb
Expand Up @@ -12,13 +12,6 @@ class String
alias_method :__data__, :data
alias_method :__data__=, :data=

def self.allocate
str = super()
str.__data__ = Rubinius::ByteArray.new(1)
str.num_bytes = 0
str
end

##
# Creates a new string from copying _count_ bytes from the
# _start_ of _bytes_.
Expand Down
7 changes: 7 additions & 0 deletions kernel/common/string18.rb
Expand Up @@ -3,6 +3,13 @@
class String
include Enumerable

def self.allocate
str = super()
str.__data__ = Rubinius::ByteArray.new(1)
str.num_bytes = 0
str
end

alias_method :bytesize, :size

# Treats leading characters from <i>self</i> as a string of hexadecimal digits
Expand Down
8 changes: 8 additions & 0 deletions kernel/common/string19.rb
@@ -1,6 +1,14 @@
# -*- encoding: us-ascii -*-

class String
def self.allocate
str = super()
str.__data__ = Rubinius::ByteArray.new(1)
str.num_bytes = 0
str.force_encoding(Encoding::BINARY)
str
end

def self.try_convert(obj)
Rubinius::Type.try_convert obj, String, :to_str
end
Expand Down

0 comments on commit 4203195

Please sign in to comment.