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
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,11 @@ The following default gems are updated.

* RubyGems 4.0.0.dev
* bundler 4.0.0.dev
* date 3.5.0
* erb 5.1.3
* etc 1.4.6
* fcntl 1.3.0
* fileutils 1.8.0
* io-console 0.8.1
* io-nonblock 0.3.2
* io-wait 0.3.2
Expand All @@ -197,6 +199,7 @@ The following default gems are updated.
* resolv 0.6.2
* stringio 3.1.8.dev
* strscan 3.1.6.dev
* timeout 0.4.4
* uri 1.0.4
* weakref 0.1.4
* zlib 3.2.2
Expand Down
6 changes: 6 additions & 0 deletions doc/maintainers.md
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,12 @@ It may needs to make consensus on ruby-core/ruby-dev before making major changes
* https://github.com/ruby/fiddle
* https://rubygems.org/gems/fiddle

#### repl_type_completor

* Tomoya Ishida ([tompng])
* https://github.com/ruby/repl_type_completor
* https://rubygems.org/gems/repl_type_completor

## Platform Maintainers

### mswin64 (Microsoft Windows)
Expand Down
2 changes: 1 addition & 1 deletion ext/date/lib/date.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
require 'date_core'

class Date
VERSION = "3.4.1" # :nodoc:
VERSION = "3.5.0" # :nodoc:

# call-seq:
# infinite? -> false
Expand Down
8 changes: 4 additions & 4 deletions ext/io/wait/wait.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ io_nread(VALUE io)
ioctl_arg n;

GetOpenFile(io, fptr);
rb_io_check_readable(fptr);
rb_io_check_char_readable(fptr);
len = rb_io_read_pending(fptr);
if (len > 0) return INT2FIX(len);

Expand Down Expand Up @@ -143,7 +143,7 @@ io_ready_p(VALUE io)
#endif

GetOpenFile(io, fptr);
rb_io_check_readable(fptr);
rb_io_check_char_readable(fptr);
if (rb_io_read_pending(fptr)) return Qtrue;

#ifndef HAVE_RB_IO_WAIT
Expand Down Expand Up @@ -178,7 +178,7 @@ io_wait_readable(int argc, VALUE *argv, VALUE io)
#endif

GetOpenFile(io, fptr);
rb_io_check_readable(fptr);
rb_io_check_char_readable(fptr);

#ifndef HAVE_RB_IO_WAIT
tv = get_timeout(argc, argv, &timerec);
Expand Down Expand Up @@ -252,7 +252,7 @@ io_wait_priority(int argc, VALUE *argv, VALUE io)
rb_io_t *fptr = NULL;

RB_IO_POINTER(io, fptr);
rb_io_check_readable(fptr);
rb_io_check_char_readable(fptr);

if (rb_io_read_pending(fptr)) return Qtrue;

Expand Down
4 changes: 2 additions & 2 deletions io.c
Original file line number Diff line number Diff line change
Expand Up @@ -9832,7 +9832,7 @@ io_wait_readable(int argc, VALUE *argv, VALUE io)
rb_io_t *fptr;

RB_IO_POINTER(io, fptr);
rb_io_check_readable(fptr);
rb_io_check_char_readable(fptr);

if (rb_io_read_pending(fptr)) return Qtrue;

Expand Down Expand Up @@ -9879,7 +9879,7 @@ io_wait_priority(int argc, VALUE *argv, VALUE io)
rb_io_t *fptr = NULL;

RB_IO_POINTER(io, fptr);
rb_io_check_readable(fptr);
rb_io_check_char_readable(fptr);

if (rb_io_read_pending(fptr)) return Qtrue;

Expand Down
2 changes: 1 addition & 1 deletion lib/fileutils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@
#
module FileUtils
# The version number.
VERSION = "1.7.3"
VERSION = "1.8.0"

def self.private_module_function(name) #:nodoc:
module_function name
Expand Down
2 changes: 1 addition & 1 deletion lib/timeout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

module Timeout
# The version
VERSION = "0.4.3"
VERSION = "0.4.4"

# Internal error raised to when a timeout is triggered.
class ExitException < Exception
Expand Down
20 changes: 8 additions & 12 deletions test/date/test_date_conv.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,21 +82,17 @@ def test_to_time__from_datetime
assert_equal([1582, 10, 13, 1, 2, 3, 456789],
[t.year, t.mon, t.mday, t.hour, t.min, t.sec, t.usec])

if Time.allocate.respond_to?(:nsec)
d = DateTime.new(2004, 9, 19, 1, 2, 3, 0) + 456789123.to_r/86400000000000
t = d.to_time.utc
assert_equal([2004, 9, 19, 1, 2, 3, 456789123],
[t.year, t.mon, t.mday, t.hour, t.min, t.sec, t.nsec])
end
d = DateTime.new(2004, 9, 19, 1, 2, 3, 0) + 456789123.to_r/86400000000000
t = d.to_time.utc
assert_equal([2004, 9, 19, 1, 2, 3, 456789123],
[t.year, t.mon, t.mday, t.hour, t.min, t.sec, t.nsec])

# TruffleRuby does not support more than nanoseconds
unless RUBY_ENGINE == 'truffleruby'
if Time.allocate.respond_to?(:subsec)
d = DateTime.new(2004, 9, 19, 1, 2, 3, 0) + 456789123456789123.to_r/86400000000000000000000
t = d.to_time.utc
assert_equal([2004, 9, 19, 1, 2, 3, Rational(456789123456789123,1000000000000000000)],
[t.year, t.mon, t.mday, t.hour, t.min, t.sec, t.subsec])
end
d = DateTime.new(2004, 9, 19, 1, 2, 3, 0) + 456789123456789123.to_r/86400000000000000000000
t = d.to_time.utc
assert_equal([2004, 9, 19, 1, 2, 3, Rational(456789123456789123,1000000000000000000)],
[t.year, t.mon, t.mday, t.hour, t.min, t.sec, t.subsec])
end
end

Expand Down
30 changes: 30 additions & 0 deletions test/io/wait/test_io_wait_uncommon.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# frozen_string_literal: true
require 'test/unit'
require 'io/wait'

# test uncommon device types to check portability problems
# We may optimize IO#wait_*able for non-Linux kernels in the future
Expand Down Expand Up @@ -74,4 +75,33 @@ def test_wait_readable_zero
def test_wait_writable_null
check_dev(IO::NULL, :wait_writable)
end

def test_after_ungetc_ready?
check_dev(IO::NULL, mode: "r") {|fp|
assert_respond_to fp, :ready?
fp.ungetc(?a)
assert_predicate fp, :ready?
}
end

def test_after_ungetc_wait_readable
check_dev(IO::NULL, mode: "r") {|fp|
fp.ungetc(?a)
assert_predicate fp, :wait_readable
}
end

def test_after_ungetc_in_text_ready?
check_dev(IO::NULL, mode: "rt") {|fp|
fp.ungetc(?a)
assert_predicate fp, :ready?
}
end

def test_after_ungetc_in_text_wait_readable
check_dev(IO::NULL, mode: "rt") {|fp|
fp.ungetc(?a)
assert_predicate fp, :wait_readable
}
end
end
4 changes: 4 additions & 0 deletions test/ruby/test_namespace.rb
Original file line number Diff line number Diff line change
Expand Up @@ -690,5 +690,9 @@ def test_root_and_main_methods
assert !$LOADED_FEATURES.include?("/tmp/barbaz")
assert !Object.const_defined?(:FooClass)
end;
ensure
tmp = ENV["TMPDIR"] || ENV["TMP"] || Etc.systmpdir || "/tmp"
pat = "_ruby_ns_*."+RbConfig::CONFIG["DLEXT"]
File.unlink(*Dir.glob(pat, base: tmp).map {|so| "#{tmp}/#{so}"})
end
end
57 changes: 29 additions & 28 deletions win32/win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -4724,27 +4724,36 @@ waitpid(rb_pid_t pid, int *stat_loc, int options)

#include <sys/timeb.h>

/* License: Ruby's */
#define filetime_unit (10UL * 1000 * 1000)
#define filetime_diff_days ((1970-1601)*3652425UL/10000)
#define filetime_diff_secs (filetime_diff_days * (24ULL * 60 * 60))
#define unix_to_filetime(sec) (((sec) + filetime_diff_secs) * filetime_unit)
#define filetime_unix_offset unix_to_filetime(0ULL)

/* License: Ruby's */
typedef union {
/* FILETIME and ULARGE_INTEGER::u are the same layout */
FILETIME ft;
ULARGE_INTEGER i;
} FILETIME_INTEGER;

/* License: Ruby's */
/* split FILETIME value into UNIX time and sub-seconds in NT ticks */
static time_t
filetime_split(const FILETIME* ft, long *subsec)
{
ULARGE_INTEGER tmp;
unsigned LONG_LONG lt;
const unsigned LONG_LONG subsec_unit = (unsigned LONG_LONG)10 * 1000 * 1000;

tmp.LowPart = ft->dwLowDateTime;
tmp.HighPart = ft->dwHighDateTime;
lt = tmp.QuadPart;
FILETIME_INTEGER fi = {.ft = *ft};
ULONGLONG lt = fi.i.QuadPart;

/* lt is now 100-nanosec intervals since 1601/01/01 00:00:00 UTC,
convert it into UNIX time (since 1970/01/01 00:00:00 UTC).
the first leap second is at 1972/06/30, so we doesn't need to think
about it. */
lt -= (LONG_LONG)((1970-1601)*365.2425) * 24 * 60 * 60 * subsec_unit;
lt -= unix_to_filetime(0);

*subsec = (long)(lt % subsec_unit);
return (time_t)(lt / subsec_unit);
*subsec = (long)(lt % filetime_unit);
return (time_t)(lt / filetime_unit);
}

/* License: Ruby's */
Expand All @@ -4762,15 +4771,6 @@ gettimeofday(struct timeval *tv, struct timezone *tz)
}

/* License: Ruby's */
static FILETIME
filetimes_plus(FILETIME t1, FILETIME t2)
{
ULARGE_INTEGER i1 = {.u = {.LowPart = t1.dwLowDateTime, .HighPart = t1.dwHighDateTime}};
ULARGE_INTEGER i2 = {.u = {.LowPart = t2.dwLowDateTime, .HighPart = t2.dwHighDateTime}};
ULARGE_INTEGER i = {.QuadPart = i1.QuadPart + i2.QuadPart};
return (FILETIME){.dwLowDateTime = i.LowPart, .dwHighDateTime = i.HighPart};
}

static void
filetime_to_timespec(FILETIME ft, struct timespec *sp)
{
Expand Down Expand Up @@ -4800,11 +4800,11 @@ clock_gettime(clockid_t clock_id, struct timespec *sp)
{
LARGE_INTEGER freq;
LARGE_INTEGER count;
if (!QueryPerformanceFrequency(&freq)) {
if (UNLIKELY(!QueryPerformanceFrequency(&freq))) {
errno = map_errno(GetLastError());
return -1;
}
if (!QueryPerformanceCounter(&count)) {
if (UNLIKELY(!QueryPerformanceCounter(&count))) {
errno = map_errno(GetLastError());
return -1;
}
Expand All @@ -4818,19 +4818,20 @@ clock_gettime(clockid_t clock_id, struct timespec *sp)
case CLOCK_PROCESS_CPUTIME_ID:
case CLOCK_THREAD_CPUTIME_ID:
{
FILETIME ct, et, kt, ut;
FILETIME_INTEGER c, e, k, u, total;
BOOL ok;
if (clock_id == CLOCK_PROCESS_CPUTIME_ID) {
ok = GetProcessTimes(GetCurrentProcess(), &ct, &et, &kt, &ut);
ok = GetProcessTimes(GetCurrentProcess(), &c.ft, &e.ft, &k.ft, &u.ft);
}
else {
ok = GetThreadTimes(GetCurrentThread(), &ct, &et, &kt, &ut);
ok = GetThreadTimes(GetCurrentThread(), &c.ft, &e.ft, &k.ft, &u.ft);
}
if (!ok) {
if (UNLIKELY(!ok)) {
errno = map_errno(GetLastError());
return -1;
}
filetime_to_timespec(filetimes_plus(kt, ut), sp);
total.i.QuadPart = k.i.QuadPart + u.i.QuadPart;
filetime_to_timespec(total.ft, sp);
return 0;
}
default:
Expand Down Expand Up @@ -7598,7 +7599,7 @@ unixtime_to_filetime(time_t time, FILETIME *ft)
{
ULARGE_INTEGER tmp;

tmp.QuadPart = ((LONG_LONG)time + (LONG_LONG)((1970-1601)*365.2425) * 24 * 60 * 60) * 10 * 1000 * 1000;
tmp.QuadPart = unix_to_filetime((ULONGLONG)time);
ft->dwLowDateTime = tmp.LowPart;
ft->dwHighDateTime = tmp.HighPart;
return 0;
Expand All @@ -7611,7 +7612,7 @@ timespec_to_filetime(const struct timespec *ts, FILETIME *ft)
{
ULARGE_INTEGER tmp;

tmp.QuadPart = ((LONG_LONG)ts->tv_sec + (LONG_LONG)((1970-1601)*365.2425) * 24 * 60 * 60) * 10 * 1000 * 1000;
tmp.QuadPart = unix_to_filetime((ULONGLONG)ts->tv_sec);
tmp.QuadPart += ts->tv_nsec / 100;
ft->dwLowDateTime = tmp.LowPart;
ft->dwHighDateTime = tmp.HighPart;
Expand Down