Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rubinius/rubinius
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: c936f673b15f
Choose a base ref
...
head repository: rubinius/rubinius
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: f96be9400730
Choose a head ref

Commits on Jan 19, 2015

  1. Copy the full SHA
    98a88a7 View commit details
  2. Merge pull request #3289 from jasonrclark/rbxopt-help

    Adding RBXOPT information to help on -X options
    jc00ke committed Jan 19, 2015
    Copy the full SHA
    bf7db36 View commit details

Commits on Jan 20, 2015

  1. Document all ways of passing -X options in -Xhelp,

    using the same description found in vm/environment.cpp
    jemc committed Jan 20, 2015
    Copy the full SHA
    e0f904a View commit details
  2. Copy the full SHA
    c0812a6 View commit details
  3. Fixed Enumerable#flat_map.

    brixen committed Jan 20, 2015
    Copy the full SHA
    178174a View commit details

Commits on Jan 21, 2015

  1. Copy the full SHA
    6d1c999 View commit details
  2. 4
    Copy the full SHA
    db5a44e View commit details

Commits on Jan 22, 2015

  1. Copy the full SHA
    bb5a1eb View commit details

Commits on Jan 23, 2015

  1. Copy the full SHA
    5f35e00 View commit details
  2. Copy the full SHA
    7e9db0c View commit details
  3. Copy the full SHA
    b20d2df View commit details
  4. Copy the full SHA
    200e892 View commit details
  5. Copy the full SHA
    d2a2e24 View commit details
  6. Copy the full SHA
    3eb0672 View commit details
  7. Copy the full SHA
    d545ebb View commit details
  8. passes most read specs

    chuckremes committed Jan 23, 2015
    Copy the full SHA
    706385f View commit details
  9. Copy the full SHA
    425823c View commit details
  10. Copy the full SHA
    3c5b581 View commit details
  11. Copy the full SHA
    6af8087 View commit details
  12. Copy the full SHA
    77b0f42 View commit details
  13. Copy the full SHA
    9e3a630 View commit details
  14. Copy the full SHA
    4cffe04 View commit details
  15. Copy the full SHA
    abebac0 View commit details
  16. Copy the full SHA
    f1893d2 View commit details
  17. fix merge conflicts

    chuckremes committed Jan 23, 2015
    Copy the full SHA
    f96be94 View commit details
Showing with 165 additions and 108 deletions.
  1. +1 −0 .travis.yml
  2. +2 −1 kernel/bootstrap/io.rb
  3. +11 −3 kernel/common/enumerable.rb
  4. +61 −76 kernel/common/io.rb
  5. +10 −0 kernel/loader.rb
  6. +33 −19 spec/ruby/core/enumerable/shared/collect_concat.rb
  7. +24 −2 vm/builtin/system.cpp
  8. +5 −0 vm/console.cpp
  9. +2 −2 vm/environment.cpp
  10. +15 −5 vm/metrics.cpp
  11. +1 −0 vm/metrics.hpp
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -20,6 +20,7 @@ branches:
- master
- 1.8.7
notifications:
email: false
irc:
channels:
- "chat.freenode.net#rubinius"
3 changes: 2 additions & 1 deletion kernel/bootstrap/io.rb
Original file line number Diff line number Diff line change
@@ -344,6 +344,7 @@ def read(length, output_string=nil)
ensure_open

storage = FFI::MemoryPointer.new(length)
raise IOError, "read(2) failed to malloc a buffer for read length #{length}" if storage.null?
bytes_read = read_into_storage(length, storage)

if bytes_read == -1
@@ -365,7 +366,7 @@ def read(length, output_string=nil)
if output_string
output_string.replace(storage.read_string(bytes_read))
else
output_string = storage.read_string(bytes_read)
output_string = storage.read_string(bytes_read).force_encoding(Encoding::ASCII_8BIT)
end

@offset += bytes_read
14 changes: 11 additions & 3 deletions kernel/common/enumerable.rb
Original file line number Diff line number Diff line change
@@ -90,12 +90,20 @@ def each_with_object(memo)
def flat_map
return to_enum(:flat_map) unless block_given?

a = []
array = []
each do |*args|
result = yield(*args)
Rubinius::Type.object_respond_to_ary?(result) ? a.concat(result) : a.push(result)

value = Rubinius::Type.try_convert(result, Array, :to_ary) || result

if value.kind_of? Array
array.concat value
else
array.push value
end
end
a

array
end

alias_method :collect_concat, :flat_map
137 changes: 61 additions & 76 deletions kernel/common/io.rb
Original file line number Diff line number Diff line change
@@ -944,7 +944,7 @@ def dup
class EachReader
def initialize(io, separator, limit)
@io = io
@separator = separator
@separator = separator ? separator.force_encoding("ASCII-8BIT") : separator
@limit = limit
@skip = nil
end
@@ -975,6 +975,19 @@ def each(&block)
end
end

def do_skip(buffer)
return 0 unless @skip

skip_count = 0
skip_count += 1 while buffer[skip_count].ord == @skip
if skip_count > 0
slice = buffer.slice!(0, skip_count)
slice.bytesize
else
0
end
end

# method A, D
def read_to_separator
str = ""
@@ -989,9 +1002,13 @@ def read_to_separator
end

break unless buffer.size > 0

if count = buffer.index(@separator)
substring = buffer.slice!(0, count + separator_size)
# #index returns a 0-based location but we want a length (so +1) and it should include
# the pattern/separator which may be >1. therefore, add the separator size.
count += separator_size

substring = buffer.slice!(0, count)
consumed_bytes += substring.bytesize
str << substring

@@ -1000,19 +1017,12 @@ def read_to_separator

$. = @io.increment_lineno

if @skip
skip_count = 0
skip_count += 1 while buffer[skip_count].ord == @skip
if skip_count > 0
slice = buffer.slice!(0, skip_count)
consumed_bytes += slice.bytesize
end
end
consumed_bytes += do_skip(buffer)

# Must update position before we yield since yielded block *could*
# return directly and rob us of a chance to do our housekeeping
@io.pos = starting_position + consumed_bytes
yield str
yield str

str = ""
else
@@ -1025,7 +1035,7 @@ def read_to_separator

str << buffer

consumed_bytes += buffer.size + 1
consumed_bytes += buffer.size
@io.pos = starting_position + consumed_bytes

unless str.empty?
@@ -1048,97 +1058,83 @@ def try_to_force_encoding(io, str)

def read_to_char_boundary(io, str, buffer)
str.force_encoding(io.external_encoding || Encoding.default_external)
return IO.read_encode(io, str) if str.valid_encoding?
return [IO.read_encode(io, str), 0] if str.valid_encoding?

peek_ahead = 0
while buffer.size > 0 and peek_ahead < PEEK_AHEAD_LIMIT
str.force_encoding Encoding::ASCII_8BIT
str << buffer.slice!(0, 1)
substring = buffer.slice!(0, 1)
str << substring
peek_ahead += 1

str.force_encoding(io.external_encoding || Encoding.default_external)
if str.valid_encoding?
return IO.read_encode io, str
return [IO.read_encode(io, str), peek_ahead]
end
end

IO.read_encode io, str
[IO.read_encode(io, str), peek_ahead]
end

def read_to_separator_with_limit
str = ""
buffer = ""
separator_size = @separator.bytesize

#TODO: implement ignoring encoding with negative limit
wanted = limit = @limit.abs

until buffer.size == 0 && @io.eof?
if buffer.size == 0
consumed_chars = 0
consumed_bytes = 0
starting_position = @io.pos
buffer = @io.read
buffer = @io.read(IO.pagesize)
end


if @skip
skip_count = 0
skip_count += 1 while buffer[skip_count].ord == @skip
if skip_count > 0
slice = buffer.slice!(0, skip_count)
consumed_bytes += slice.bytesize
end
end
break unless buffer.size > 0
break unless buffer && buffer.size > 0

if count = buffer.index(@separator)
consumed_chars += count
str << buffer.slice!(0, count + 1)
# #index returns a 0-based location but we want a length (so +1) and it should include
# the pattern/separator which may be >1. therefore, add the separator size.
count += separator_size
bytes = count < wanted ? count : wanted
substring = buffer.slice!(0, bytes)
consumed_bytes += substring.bytesize
str << substring

str = IO.read_encode(@io, str)
str.taint

$. = @io.increment_lineno
consumed_bytes += do_skip(buffer)
@io.pos = starting_position + consumed_bytes

if @skip
skip_count = 0
skip_count += 1 while buffer[skip_count].ord == @skip
if skip_count > 0
slice = buffer.slice!(0, skip_count)
consumed_bytes += slice.bytesize
end
end

@io.pos = starting_position + consumed_chars + 1
yield str

str = ""
wanted = limit
else
if wanted < buffer.size
consumed_chars += wanted
str << buffer.slice!(0, wanted + 1)
str << buffer.slice!(0, wanted)
consumed_bytes += wanted

str = read_to_char_boundary(@io, str, buffer)
str, bytes_read = read_to_char_boundary(@io, str, buffer)
str.taint

$. = @io.increment_lineno
if @skip
skip_count = 0
skip_count += 1 while buffer[skip_count].ord == @skip
if skip_count > 0
slice = buffer.slice!(0, skip_count)
consumed_bytes += slice.bytesize
end
end
consumed_bytes += do_skip(buffer)
consumed_bytes += bytes_read
@io.pos = starting_position + consumed_bytes

@io.pos = starting_position + consumed_chars + 1
yield str

str = ""
wanted = limit
else
str << buffer
consumed_bytes += buffer.size
@io.pos = starting_position + consumed_bytes
wanted -= buffer.size
consumed_chars += buffer.size
buffer.clear
end
end
@@ -1178,18 +1174,13 @@ def read_to_limit
until @io.eof?
str << @io.read(wanted)

if str.size < wanted
str = try_to_force_encoding(@io, str)
str.taint
str = try_to_force_encoding(@io, str)
str.taint

$. = @io.increment_lineno
yield str
$. = @io.increment_lineno
yield str

str = ""
wanted = limit
else
wanted -= str.size
end
str = ""
end

unless str.empty?
@@ -1245,7 +1236,7 @@ def each(sep_or_limit=$/, limit=nil, &block)
end
end

return if eof? #@ibuffer.exhausted?
return if eof?

EachReader.new(self, sep, limit).each(&block)

@@ -1703,37 +1694,31 @@ def read(length=nil, buffer=nil)

str = ""
needed = length

if length > 0
# FIXME: need to twiddle @pos or @offset too
#STDERR.puts "read length is [#{length}], @unget_buffer.size [#{@unget_buffer.size}]"
if !@unget_buffer.empty?
if length >= @unget_buffer.size
unget_buffer = @unget_buffer.inject("") { |sum, val| val.chr + sum }
length -= @unget_buffer.size
@offset += @unget_buffer.size
STDERR.puts "1 @offset [#{@offset}], pos [#{sysseek(0, SEEK_CUR)}]"
@unget_buffer.clear
# STDERR.puts "1 unget_buffer [#{unget_buffer.inspect}], length [#{length}]"
else
unget_buffer = ""
length.times do
unget_buffer << @unget_buffer.pop
end
# STDERR.puts "2 unget_buffer [#{unget_buffer.inspect}], @unget_buffer #{@unget_buffer.inspect}"
@offset += length
STDERR.puts "2 @offset [#{@offset}], pos [#{sysseek(0, SEEK_CUR)}]"
length = 0
end
end
end

result = prim_read(length, str)
#str = nil if str.empty? && needed > 0

if unget_buffer
str = unget_buffer + str.to_s
elsif str.empty? && needed > 0
STDERR.puts "str [#{str.inspect}] was empty, str.nil? [#{str.nil?}]"
str = nil
end
# while needed > 0 and not @ibuffer.exhausted?
@@ -2298,7 +2283,7 @@ def ungetbyte(obj)
end

# str.bytes.reverse_each { |byte| @ibuffer.put_back byte }
str.bytes.reverse_each do |byte|
str.bytes.reverse_each do |byte|
@unget_buffer << byte
end

@@ -2322,7 +2307,7 @@ def ungetc(obj)
end

# str.bytes.reverse_each { |b| @ibuffer.put_back b }
str.bytes.reverse_each do |byte|
str.bytes.reverse_each do |byte|
@unget_buffer << byte
end

10 changes: 10 additions & 0 deletions kernel/loader.rb
Original file line number Diff line number Diff line change
@@ -426,6 +426,16 @@ def options(argv=ARGV)
All variables, even ones that the VM doesn't understand, are available
in Rubinius::Config.
Options are parsed from these sources, in this order:
1. The file .rbxrc in the current working directory.
2. The RBXOPT environment variable.
3. The command line options.
This order permits environment and command line options to override
"application" configuration. Likewise, command line options can override
environment configuration.
A number of Rubinius features are driven by setting these variables.
DOC

Loading