Skip to content
Merged
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
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@ tool/update-deps diff=ruby
tool/make-snapshot diff=ruby
tool/format-release diff=ruby
tool/leaked-globals diff=ruby

# To strip CR from the batch files, set the `diff.dos.textconv` filter
# like as `git config diff.dos.textconv $'sed \'s/\r$//\''`.
*.bat diff=dos
*.cmd diff=dos
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ releases.
* debug 1.11.1
* mutex_m 0.3.0
* resolv-replace 0.2.0
* syslog 0.4.0
* rdoc 7.1.0

### RubyGems and Bundler
Expand Down
7 changes: 6 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,12 @@ AS_CASE(["$GCC:${warnflags+set}:${extra_warnflags:+set}:"],
AS_CASE([ $CFLAGS ], [*" -save-temps="*|*" -save-temps "*], [], [
extra_warnflags="$extra_warnflags -Werror=misleading-indentation"
])
AS_CASE([$target_os], [mingw*], [
# 64bit Windows is IL32P64; shorten-64-to-32 causes tons of warnigs
extra_warnflags="$extra_warnflags -Wno-shorten-64-to-32"
], [
extra_warnflags="$extra_warnflags -Werror=shorten-64-to-32"
])

# ICC doesn't support -Werror=
AS_IF([test $icc_version -gt 0], [
Expand All @@ -756,7 +762,6 @@ AS_CASE(["$GCC:${warnflags+set}:${extra_warnflags:+set}:"],
-Werror=implicit-function-declaration \
-Werror=implicit-int \
-Werror=pointer-arith \
-Werror=shorten-64-to-32 \
-Werror=write-strings \
-Werror=old-style-definition \
-Wimplicit-fallthrough=0 \
Expand Down
2 changes: 1 addition & 1 deletion gems/bundled_gems
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ resolv-replace 0.2.0 https://github.com/ruby/resolv-replace
rinda 0.2.0 https://github.com/ruby/rinda
drb 2.2.3 https://github.com/ruby/drb
nkf 0.2.0 https://github.com/ruby/nkf
syslog 0.3.0 https://github.com/ruby/syslog
syslog 0.4.0 https://github.com/ruby/syslog
csv 3.3.5 https://github.com/ruby/csv
repl_type_completor 0.1.12 https://github.com/ruby/repl_type_completor 26b8e964557690c0b539cff8940bcfb1591f1fe6
ostruct 0.6.3 https://github.com/ruby/ostruct
Expand Down
11 changes: 0 additions & 11 deletions include/ruby/internal/fl_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,6 @@
#define RB_OBJ_FREEZE_RAW RB_OBJ_FREEZE_RAW
#define RB_OBJ_FROZEN RB_OBJ_FROZEN
#define RB_OBJ_FROZEN_RAW RB_OBJ_FROZEN_RAW
#define RB_OBJ_UNTRUST RB_OBJ_TAINT
#define RB_OBJ_UNTRUSTED RB_OBJ_TAINTED
/** @endcond */

/**
Expand All @@ -134,15 +132,6 @@
#define OBJ_FREEZE_RAW RB_OBJ_FREEZE_RAW /**< @old{RB_OBJ_FREEZE_RAW} */
#define OBJ_FROZEN RB_OBJ_FROZEN /**< @old{RB_OBJ_FROZEN} */
#define OBJ_FROZEN_RAW RB_OBJ_FROZEN_RAW /**< @old{RB_OBJ_FROZEN_RAW} */
#define OBJ_INFECT RB_OBJ_INFECT /**< @old{RB_OBJ_INFECT} */
#define OBJ_INFECT_RAW RB_OBJ_INFECT_RAW /**< @old{RB_OBJ_INFECT_RAW} */
#define OBJ_TAINT RB_OBJ_TAINT /**< @old{RB_OBJ_TAINT} */
#define OBJ_TAINTABLE RB_OBJ_TAINTABLE /**< @old{RB_OBJ_TAINT_RAW} */
#define OBJ_TAINTED RB_OBJ_TAINTED /**< @old{RB_OBJ_TAINTED} */
#define OBJ_TAINTED_RAW RB_OBJ_TAINTED_RAW /**< @old{RB_OBJ_TAINTED_RAW} */
#define OBJ_TAINT_RAW RB_OBJ_TAINT_RAW /**< @old{RB_OBJ_TAINT_RAW} */
#define OBJ_UNTRUST RB_OBJ_UNTRUST /**< @old{RB_OBJ_TAINT} */
#define OBJ_UNTRUSTED RB_OBJ_UNTRUSTED /**< @old{RB_OBJ_TAINTED} */
/** @} */

/**
Expand Down
68 changes: 27 additions & 41 deletions spec/ruby/core/io/buffer/map_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,33 @@

describe "IO::Buffer.map" do
before :all do
@big_file_name = tmp("big_file")
# Usually 4 kibibytes + 16 bytes
File.write(@big_file_name, "12345678" * (IO::Buffer::PAGE_SIZE / 8 + 2))
@tmp_files = []

@big_file_name = nil
@small_file_name = nil
end

after :all do
File.delete(@big_file_name)
@tmp_files.each {|file| File.delete(file)}
end

def open_fixture
File.open("#{__dir__}/../fixtures/read_text.txt", "r+")
unless @small_file_name
@small_file_name = tmp("read_text.txt")
File.copy_stream(fixture(__dir__, "read_text.txt"), @small_file_name)
@tmp_files << @small_file_name
end
File.open(@small_file_name, "rb+")
end

def open_big_file_fixture
File.open(@big_file_name, "r+")
unless @big_file_name
@big_file_name = tmp("big_file")
# Usually 4 kibibytes + 16 bytes
File.write(@big_file_name, "12345678" * (IO::Buffer::PAGE_SIZE / 8 + 2))
@tmp_files << @big_file_name
end
File.open(@big_file_name, "rb+")
end

after :each do
Expand Down Expand Up @@ -89,24 +101,19 @@ def open_big_file_fixture
end

context "with an empty file" do
ruby_version_is ""..."4.0" do
it "raises a SystemCallError" do
@file = File.open("#{__dir__}/../fixtures/empty.txt", "r+")
-> { IO::Buffer.map(@file) }.should raise_error(SystemCallError)
end
end

ruby_version_is "4.0" do
it "raises ArgumentError" do
@file = File.open("#{__dir__}/../fixtures/empty.txt", "r+")
file_name = tmp("empty.txt")
@file = File.open(file_name, "wb+")
@tmp_files << file_name
-> { IO::Buffer.map(@file) }.should raise_error(ArgumentError, "Invalid negative or zero file size!")
end
end
end

context "with a file opened only for reading" do
it "raises a SystemCallError if no flags are used" do
@file = File.open("#{__dir__}/../fixtures/read_text.txt", "r")
it "raises a SystemCallError unless read-only" do
@file = File.open(fixture(__dir__, "read_text.txt"), "rb")
-> { IO::Buffer.map(@file) }.should raise_error(SystemCallError)
end
end
Expand All @@ -128,15 +135,6 @@ def open_big_file_fixture
end

context "if size is 0" do
ruby_version_is ""..."4.0" do
platform_is_not :windows do
it "raises a SystemCallError" do
@file = open_fixture
-> { IO::Buffer.map(@file, 0) }.should raise_error(SystemCallError)
end
end
end

ruby_version_is "4.0" do
it "raises ArgumentError" do
@file = open_fixture
Expand Down Expand Up @@ -247,18 +245,6 @@ def open_big_file_fixture
-> { IO::Buffer.map(@file, 4, nil) }.should raise_error(TypeError, /no implicit conversion/)
end

it "raises a SystemCallError if offset is not an allowed value" do
@file = open_fixture
-> { IO::Buffer.map(@file, 4, 3) }.should raise_error(SystemCallError)
end

ruby_version_is ""..."4.0" do
it "raises a SystemCallError if offset is negative" do
@file = open_fixture
-> { IO::Buffer.map(@file, 4, -1) }.should raise_error(SystemCallError)
end
end

ruby_version_is "4.0" do
it "raises ArgumentError if offset is negative" do
@file = open_fixture
Expand All @@ -279,7 +265,7 @@ def open_big_file_fixture
end

it "allows mapping read-only files" do
@file = File.open("#{__dir__}/../fixtures/read_text.txt", "r")
@file = File.open(fixture(__dir__, "read_text.txt"), "rb")
@buffer = IO::Buffer.map(@file, nil, 0, IO::Buffer::READONLY)

@buffer.should.readonly?
Expand Down Expand Up @@ -308,11 +294,11 @@ def open_big_file_fixture
@buffer.set_string("test12345")
@buffer.get_string.should == "test12345".b

@file.read.should == "abcâdef\n"
@file.read.should == "abcâdef\n".b
end

it "allows mapping read-only files and modifying the buffer" do
@file = File.open("#{__dir__}/../fixtures/read_text.txt", "r")
@file = File.open(fixture(__dir__, "read_text.txt"), "rb")
@buffer = IO::Buffer.map(@file, nil, 0, IO::Buffer::PRIVATE)

@buffer.should.private?
Expand All @@ -323,7 +309,7 @@ def open_big_file_fixture
@buffer.set_string("test12345")
@buffer.get_string.should == "test12345".b

@file.read.should == "abcâdef\n"
@file.read.should == "abcâdef\n".b
end

platform_is_not :windows do
Expand Down
9 changes: 7 additions & 2 deletions spec/ruby/core/io/buffer/shared_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,15 @@
end

it "is true for a non-private buffer created with .map" do
file = File.open("#{__dir__}/../fixtures/read_text.txt", "r+")
path = tmp("read_text.txt")
File.copy_stream(fixture(__dir__, "read_text.txt"), path)
file = File.open(path, "r+")
@buffer = IO::Buffer.map(file)
file.close
@buffer.shared?.should be_true
ensure
@buffer.free
file.close
File.unlink(path)
end

it "is false for an unshared buffer" do
Expand Down
Loading