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
1 change: 1 addition & 0 deletions .document
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ marshal.rb
numeric.rb
nilclass.rb
pack.rb
pathname_builtin.rb
ractor.rb
string.rb
symbol.rb
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check_misc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
- name: Generate docs
id: docs
run: |
ruby -W0 --disable-gems -I./lib tool/rdoc-srcdir -q --op html .
ruby -W0 --disable-gems tool/rdoc-srcdir -q --op html .
echo htmlout=ruby-html-${GITHUB_SHA:0:10} >> $GITHUB_OUTPUT
# Generate only when document commit/PR
if: >-
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ The following default gems are updated.
* RubyGems 3.7.0.dev
* bundler 2.7.0.dev
* erb 5.0.1
* etc 1.4.6
* io-console 0.8.1
* io-nonblock 0.3.2
* json 2.12.2
Expand Down
6 changes: 3 additions & 3 deletions common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -1228,7 +1228,7 @@ BUILTIN_RB_SRCS = \
$(srcdir)/array.rb \
$(srcdir)/hash.rb \
$(srcdir)/kernel.rb \
$(srcdir)/pathname.rb \
$(srcdir)/pathname_builtin.rb \
$(srcdir)/ractor.rb \
$(srcdir)/symbol.rb \
$(srcdir)/timev.rb \
Expand Down Expand Up @@ -11247,7 +11247,7 @@ miniinit.$(OBJEXT): {$(VPATH)}numeric.rb
miniinit.$(OBJEXT): {$(VPATH)}onigmo.h
miniinit.$(OBJEXT): {$(VPATH)}oniguruma.h
miniinit.$(OBJEXT): {$(VPATH)}pack.rb
miniinit.$(OBJEXT): {$(VPATH)}pathname.rb
miniinit.$(OBJEXT): {$(VPATH)}pathname_builtin.rb
miniinit.$(OBJEXT): {$(VPATH)}prelude.rb
miniinit.$(OBJEXT): {$(VPATH)}prism/ast.h
miniinit.$(OBJEXT): {$(VPATH)}prism/diagnostic.h
Expand Down Expand Up @@ -13037,7 +13037,7 @@ pathname.$(OBJEXT): {$(VPATH)}missing.h
pathname.$(OBJEXT): {$(VPATH)}onigmo.h
pathname.$(OBJEXT): {$(VPATH)}oniguruma.h
pathname.$(OBJEXT): {$(VPATH)}pathname.c
pathname.$(OBJEXT): {$(VPATH)}pathname.rbinc
pathname.$(OBJEXT): {$(VPATH)}pathname_builtin.rbinc
pathname.$(OBJEXT): {$(VPATH)}ruby.h
pathname.$(OBJEXT): {$(VPATH)}st.h
pathname.$(OBJEXT): {$(VPATH)}subst.h
Expand Down
2 changes: 0 additions & 2 deletions ext/.document
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ openssl/ossl_x509name.c
openssl/ossl_x509req.c
openssl/ossl_x509revoked.c
openssl/ossl_x509store.c
pathname/lib
pathname/pathname.c
psych/lib
psych/psych.c
psych/psych_emitter.c
Expand Down
2 changes: 1 addition & 1 deletion ext/etc/etc.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ static VALUE sGroup;
#endif
RUBY_EXTERN char *getlogin(void);

#define RUBY_ETC_VERSION "1.4.5"
#define RUBY_ETC_VERSION "1.4.6"

#define SYMBOL_LIT(str) ID2SYM(rb_intern_const(str ""))

Expand Down
2 changes: 1 addition & 1 deletion ext/socket/lib/socket.rb
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ def self.tcp_with_fast_fallback(host, port, local_host = nil, local_port = nil,

if resolving_family_names.size == 1
family_name = resolving_family_names.first
addrinfos = Addrinfo.getaddrinfo(host, port, family_name, :STREAM, timeout: resolv_timeout)
addrinfos = Addrinfo.getaddrinfo(host, port, ADDRESS_FAMILIES[:family_name], :STREAM, timeout: resolv_timeout)
resolution_store.add_resolved(family_name, addrinfos)
hostname_resolution_result = nil
hostname_resolution_notifier = nil
Expand Down
28 changes: 8 additions & 20 deletions id_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,9 @@ static const rb_data_type_t managed_id_table_type = {
static inline struct rb_id_table *
managed_id_table_ptr(VALUE obj)
{
RUBY_ASSERT(RB_TYPE_P(obj, T_DATA));
RUBY_ASSERT(rb_typeddata_inherited_p(RTYPEDDATA_TYPE(obj), &managed_id_table_type));

return RTYPEDDATA_GET_DATA(obj);
}

Expand All @@ -381,12 +384,9 @@ managed_id_table_dup_i(ID id, VALUE val, void *data)
VALUE
rb_managed_id_table_dup(VALUE old_table)
{
RUBY_ASSERT(RB_TYPE_P(old_table, T_DATA));
RUBY_ASSERT(rb_typeddata_inherited_p(RTYPEDDATA_TYPE(old_table), &managed_id_table_type));

struct rb_id_table *new_tbl;
VALUE obj = TypedData_Make_Struct(0, struct rb_id_table, &managed_id_table_type, new_tbl);
struct rb_id_table *old_tbl = RTYPEDDATA_GET_DATA(old_table);
struct rb_id_table *old_tbl = managed_id_table_ptr(old_table);
rb_id_table_init(new_tbl, old_tbl->num + 1);
rb_id_table_foreach(old_tbl, managed_id_table_dup_i, new_tbl);
return obj;
Expand All @@ -395,35 +395,23 @@ rb_managed_id_table_dup(VALUE old_table)
int
rb_managed_id_table_lookup(VALUE table, ID id, VALUE *valp)
{
RUBY_ASSERT(RB_TYPE_P(table, T_DATA));
RUBY_ASSERT(rb_typeddata_inherited_p(RTYPEDDATA_TYPE(table), &managed_id_table_type));

return rb_id_table_lookup(RTYPEDDATA_GET_DATA(table), id, valp);
return rb_id_table_lookup(managed_id_table_ptr(table), id, valp);
}

int
rb_managed_id_table_insert(VALUE table, ID id, VALUE val)
{
RUBY_ASSERT(RB_TYPE_P(table, T_DATA));
RUBY_ASSERT(rb_typeddata_inherited_p(RTYPEDDATA_TYPE(table), &managed_id_table_type));

return rb_id_table_insert(RTYPEDDATA_GET_DATA(table), id, val);
return rb_id_table_insert(managed_id_table_ptr(table), id, val);
}

size_t
rb_managed_id_table_size(VALUE table)
{
RUBY_ASSERT(RB_TYPE_P(table, T_DATA));
RUBY_ASSERT(rb_typeddata_inherited_p(RTYPEDDATA_TYPE(table), &managed_id_table_type));

return rb_id_table_size(RTYPEDDATA_GET_DATA(table));
return rb_id_table_size(managed_id_table_ptr(table));
}

void
rb_managed_id_table_foreach(VALUE table, rb_id_table_foreach_func_t *func, void *data)
{
RUBY_ASSERT(RB_TYPE_P(table, T_DATA));
RUBY_ASSERT(rb_typeddata_inherited_p(RTYPEDDATA_TYPE(table), &managed_id_table_type));

rb_id_table_foreach(RTYPEDDATA_GET_DATA(table), func, data);
rb_id_table_foreach(managed_id_table_ptr(table), func, data);
}
2 changes: 1 addition & 1 deletion inits.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ rb_call_builtin_inits(void)
BUILTIN(ast);
BUILTIN(trace_point);
BUILTIN(pack);
BUILTIN(pathname);
BUILTIN(pathname_builtin);
BUILTIN(warning);
BUILTIN(array);
BUILTIN(hash);
Expand Down
10 changes: 0 additions & 10 deletions lib/pathname.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,6 @@ def find(ignore_error: true) # :yield: pathname


class Pathname # * FileUtils *
# Creates a full path, including any intermediate directories that don't yet
# exist.
#
# See FileUtils.mkpath and FileUtils.mkdir_p
def mkpath(mode: nil)
require 'fileutils'
FileUtils.mkpath(@path, mode: mode)
self
end

# Recursively deletes a directory, including all directories beneath it.
#
# See FileUtils.rm_rf
Expand Down
11 changes: 9 additions & 2 deletions pathname.c
Original file line number Diff line number Diff line change
Expand Up @@ -1311,7 +1311,9 @@ path_f_pathname(VALUE self, VALUE str)
return rb_class_new_instance(1, &str, rb_cPathname);
}

#include "pathname.rbinc"
#include "pathname_builtin.rbinc"

static void init_ids(void);

/*
*
Expand Down Expand Up @@ -1503,8 +1505,13 @@ Init_pathname(void)
rb_ext_ractor_safe(true);
#endif

init_ids();
InitVM(pathname);
}

void
InitVM_pathname(void)
{
rb_cPathname = rb_define_class("Pathname", rb_cObject);
rb_define_method(rb_cPathname, "initialize", path_initialize, 1);
rb_define_method(rb_cPathname, "freeze", path_freeze, 0);
Expand Down Expand Up @@ -1596,7 +1603,7 @@ Init_pathname(void)
}

void
InitVM_pathname(void)
init_ids(void)
{
#undef rb_intern
id_at_path = rb_intern("@path");
Expand Down
28 changes: 28 additions & 0 deletions pathname.rb → pathname_builtin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,34 @@ class Pathname

# :startdoc:

# Creates a full path, including any intermediate directories that don't yet
# exist.
#
# See FileUtils.mkpath and FileUtils.mkdir_p
def mkpath(mode: nil)
path = @path == '/' ? @path : @path.chomp('/')

stack = []
until File.directory?(path) || File.dirname(path) == path
stack.push path
path = File.dirname(path)
end

stack.reverse_each do |dir|
dir = dir == '/' ? dir : dir.chomp('/')
if mode
Dir.mkdir dir, mode
File.chmod mode, dir
else
Dir.mkdir dir
end
rescue SystemCallError
raise unless File.directory?(dir)
end

self
end

# chop_basename(path) -> [pre-basename, basename] or nil
def chop_basename(path) # :nodoc:
base = File.basename(path)
Expand Down
1 change: 1 addition & 0 deletions test/.excludes/URI/TestMailTo.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
exclude :test_email_regexp, "still flaky with --repeat-count option"