Skip to content

Commit a4e4d7d

Browse files
authored
Merge pull request #8695 from headius/stdlib_update_3.4.2
Update stdlib from Ruby 3.4.2
2 parents 304e7e9 + 42bba6b commit a4e4d7d

8 files changed

Lines changed: 531 additions & 63 deletions

File tree

core/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ DO NOT MODIFY - GENERATED CODE
5555
<test.results.dir>${build.dir}/test-results</test.results.dir>
5656
<tzdata.scope>provided</tzdata.scope>
5757
<tzdata.version>2019c</tzdata.version>
58-
<version.ruby>3.4.0</version.ruby>
58+
<version.ruby>3.4.2</version.ruby>
5959
<version.ruby.major>3.4</version.ruby.major>
60-
<version.ruby.minor>0</version.ruby.minor>
60+
<version.ruby.minor>2</version.ruby.minor>
6161
</properties>
6262
<dependencies>
6363
<dependency>

core/src/main/java/org/jruby/ext/socket/RubySocket.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
import org.jruby.anno.JRubyMethod;
5656
import org.jruby.api.Access;
5757
import org.jruby.api.Convert;
58+
import org.jruby.api.Create;
5859
import org.jruby.exceptions.RaiseException;
5960
import org.jruby.runtime.Arity;
6061
import org.jruby.runtime.Helpers;
@@ -99,6 +100,8 @@ static RubyClass createSocket(ThreadContext context, RubyClass BasicSocket) {
99100
RubyClass Socket = defineClass(context, "Socket", BasicSocket, RubySocket::new).
100101
defineMethods(context, RubySocket.class);
101102

103+
Socket.setInternalVariable("tcp_fast_fallback", getFastFallbackDefault(context));
104+
102105
RubyModule SocketConstants = Socket.defineModuleUnder(context, "Constants").
103106
defineConstantsFrom(context, Sock.class).
104107
defineConstantsFrom(context, SocketOption.class).
@@ -679,6 +682,27 @@ public IRubyObject close(final ThreadContext context) {
679682
return context.nil;
680683
}
681684

685+
@JRubyMethod(meta = true)
686+
public static IRubyObject tcp_fast_fallback(ThreadContext context, IRubyObject self) {
687+
return (IRubyObject) Access.getClass(context, "Socket").getInternalVariable("tcp_fast_fallback");
688+
}
689+
690+
@JRubyMethod(name = "tcp_fast_fallback=", meta = true)
691+
public static IRubyObject tcp_fast_fallback_set(ThreadContext context, IRubyObject self, IRubyObject value) {
692+
Access.getClass(context, "Socket").setInternalVariable("tcp_fast_fallback", value);
693+
return value;
694+
}
695+
696+
private static RubyBoolean getFastFallbackDefault(ThreadContext context) {
697+
IRubyObject tcpNoFastFallbackConfig = context.runtime.getENV().fastARef(Create.newString(context, "RUBY_TCP_NO_FAST_FALLBACK"));
698+
if (tcpNoFastFallbackConfig == null || tcpNoFastFallbackConfig.isNil()
699+
|| tcpNoFastFallbackConfig.toString().equals("0")) {
700+
return context.tru;
701+
} else {
702+
return context.fals;
703+
}
704+
}
705+
682706
@Override
683707
public RubyBoolean closed_p(ThreadContext context) {
684708
if (getOpenFile() == null) return context.fals;

default.build.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ rake.args=
2828
install4j.executable=/Applications/install4j9/bin/install4jc
2929

3030
# Ruby versions
31-
version.ruby=3.4.0
31+
version.ruby=3.4.2
3232
version.ruby.major=3.4
33-
version.ruby.minor=0
33+
version.ruby.minor=2
3434

lib/ruby/stdlib/pathname.rb

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
class Pathname
1717

18-
VERSION = "0.3.0"
18+
VERSION = "0.4.0"
1919

2020
# :stopdoc:
2121

@@ -580,24 +580,23 @@ def find(ignore_error: true) # :yield: pathname
580580
return to_enum(__method__, ignore_error: ignore_error) unless block_given?
581581
require 'find'
582582
if @path == '.'
583-
Find.find(@path, ignore_error: ignore_error) {|f| yield self.class.new(f.sub(%r{\A\./}, '')) }
583+
Find.find(@path, ignore_error: ignore_error) {|f| yield self.class.new(f.delete_prefix('./')) }
584584
else
585585
Find.find(@path, ignore_error: ignore_error) {|f| yield self.class.new(f) }
586586
end
587587
end
588588
end
589589

590590

591-
autoload(:FileUtils, 'fileutils')
592-
593591
class Pathname # * FileUtils *
594592
# Creates a full path, including any intermediate directories that don't yet
595593
# exist.
596594
#
597595
# See FileUtils.mkpath and FileUtils.mkdir_p
598596
def mkpath(mode: nil)
597+
require 'fileutils'
599598
FileUtils.mkpath(@path, mode: mode)
600-
nil
599+
self
601600
end
602601

603602
# Recursively deletes a directory, including all directories beneath it.
@@ -608,7 +607,23 @@ def rmtree(noop: nil, verbose: nil, secure: nil)
608607
# File::Path provides "mkpath" and "rmtree".
609608
require 'fileutils'
610609
FileUtils.rm_rf(@path, noop: noop, verbose: verbose, secure: secure)
611-
nil
610+
self
612611
end
613612
end
614613

614+
class Pathname # * tmpdir *
615+
# Creates a tmp directory and wraps the returned path in a Pathname object.
616+
#
617+
# See Dir.mktmpdir
618+
def self.mktmpdir
619+
require 'tmpdir' unless defined?(Dir.mktmpdir)
620+
if block_given?
621+
Dir.mktmpdir do |dir|
622+
dir = self.new(dir)
623+
yield dir
624+
end
625+
else
626+
self.new(Dir.mktmpdir)
627+
end
628+
end
629+
end

lib/ruby/stdlib/ripper/lexer.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def Ripper.lex(src, filename = '-', lineno = 1, **kw)
5353
end
5454

5555
class Lexer < ::Ripper #:nodoc: internal use only
56+
# :stopdoc:
5657
class State
5758
attr_reader :to_int, :to_s
5859

@@ -242,7 +243,12 @@ def on_error1(mesg)
242243
end
243244

244245
def on_error2(mesg, elem)
245-
@errors.push Elem.new(elem.pos, __callee__, elem.tok, elem.state, mesg)
246+
if elem
247+
elem = Elem.new(elem.pos, __callee__, elem.tok, elem.state, mesg)
248+
else
249+
elem = Elem.new([lineno(), column()], __callee__, token(), state(), mesg)
250+
end
251+
@errors.push elem
246252
end
247253
PARSER_EVENTS.grep(/_error\z/) do |e|
248254
arity = PARSER_EVENT_TABLE.fetch(e)
@@ -253,6 +259,7 @@ def on_error2(mesg, elem)
253259
(SCANNER_EVENTS.map {|event|:"on_#{event}"} - private_instance_methods(false)).each do |event|
254260
alias_method event, :_push_token
255261
end
262+
# :startdoc:
256263
end
257264

258265
# [EXPERIMENTAL]

0 commit comments

Comments
 (0)