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: 2 additions & 3 deletions doc/string/bytesplice.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ And either count may be zero (i.e., specifying an empty string):
'0123456789'.bytesplice(0, 0, 'abc') # => "abc0123456789" # Empty target.

In the second form, just as in the first,
arugments +offset+ and +length+ determine the target bytes;
arguments +offset+ and +length+ determine the target bytes;
argument +str+ _contains_ the source bytes,
and the additional arguments +str_offset+ and +str_length+
determine the actual source bytes:
Expand All @@ -42,7 +42,7 @@ and the source bytes are all of the given +str+:
'0123456789'.bytesplice(0...0, 'abc') # => "abc0123456789" # Empty target.

In the fourth form, just as in the third,
arugment +range+ determines the target bytes;
argument +range+ determines the target bytes;
argument +str+ _contains_ the source bytes,
and the additional argument +str_range+
determines the actual source bytes:
Expand All @@ -63,4 +63,3 @@ and so has character boundaries at offsets 0, 3, 6, 9, 12, and 15.
'こんにちは'.bytesplice(0, 3, 'abc') # => "abcんにちは"
'こんにちは'.bytesplice(1, 3, 'abc') # Raises IndexError.
'こんにちは'.bytesplice(0, 2, 'abc') # Raises IndexError.

2 changes: 1 addition & 1 deletion doc/string/dump.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ In a dump, certain special characters are escaped:

In a dump, unprintable characters are replaced by printable ones;
the unprintable characters are the whitespace characters (other than space itself);
here we see the ordinals for those characers, together with explanatory text:
here we see the ordinals for those characters, together with explanatory text:

h = {
7 => 'Alert (BEL)',
Expand Down
5 changes: 3 additions & 2 deletions gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1637,9 +1637,10 @@ rb_gc_obj_free(void *objspace, VALUE obj)
break;
case T_FILE:
if (RFILE(obj)->fptr) {
make_io_zombie(objspace, obj);
bool closed = rb_io_fptr_finalize_closed(RFILE(obj)->fptr);
if (!closed) make_io_zombie(objspace, obj);
RB_DEBUG_COUNTER_INC(obj_file_ptr);
return FALSE;
return closed;
}
break;
case T_RATIONAL:
Expand Down
1 change: 1 addition & 0 deletions internal/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ VALUE rb_io_prep_stdout(void);
VALUE rb_io_prep_stderr(void);

int rb_io_notify_close(struct rb_io *fptr);
bool rb_io_fptr_finalize_closed(struct rb_io *fptr);

RUBY_SYMBOL_EXPORT_BEGIN
/* io.c (export) */
Expand Down
9 changes: 9 additions & 0 deletions io.c
Original file line number Diff line number Diff line change
Expand Up @@ -5707,6 +5707,15 @@ rb_io_fptr_finalize(struct rb_io *io)
return 1;
}

bool
rb_io_fptr_finalize_closed(struct rb_io *io)
{
if (!io) return true;
if (io->fd >= 0) return false;
rb_io_fptr_finalize(io);
return true;
}

size_t
rb_io_memsize(const rb_io_t *io)
{
Expand Down