From f1765cd4025ff5b3048cb9f330f6624d39e5a742 Mon Sep 17 00:00:00 2001 From: Herwin Date: Fri, 14 Nov 2025 18:36:06 +0100 Subject: [PATCH 1/3] [Doc] Remove leftover references to namespace from box.md And fix the indentation a little bit, since `box` is one character longer than `ns`. --- doc/box.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/doc/box.md b/doc/box.md index 96c0db26a9a853..ed62cbd072dcff 100644 --- a/doc/box.md +++ b/doc/box.md @@ -49,14 +49,12 @@ class Something end ``` -Classes/modules, those methods and constants defined in the box can be accessed via `ns` object. +Classes/modules, those methods and constants defined in the box can be accessed via `box` object. ```ruby -p ns::Something.x # 1 - X = 2 -p X # 2 -p ::X # 2 +p X # 2 +p ::X # 2 p box::Something.x # 1 p box::X # 1 ``` From 70b49b657122da7f5cbfa2b93f198dddf2e41c30 Mon Sep 17 00:00:00 2001 From: YO4 Date: Sat, 15 Nov 2025 01:15:41 +0900 Subject: [PATCH 2/3] refactor io_each_codepoint --- io.c | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/io.c b/io.c index c29ab410a9a071..2605207f2bb49a 100644 --- a/io.c +++ b/io.c @@ -3156,8 +3156,6 @@ io_enc_str(VALUE str, rb_io_t *fptr) return str; } -static rb_encoding *io_read_encoding(rb_io_t *fptr); - static void make_readconv(rb_io_t *fptr, int size) { @@ -4900,7 +4898,7 @@ static VALUE rb_io_each_codepoint(VALUE io) { rb_io_t *fptr; - rb_encoding *enc, *read_enc; + rb_encoding *enc; unsigned int c; int r, n; @@ -4909,20 +4907,17 @@ rb_io_each_codepoint(VALUE io) rb_io_check_char_readable(fptr); READ_CHECK(fptr); + enc = io_read_encoding(fptr); if (NEED_READCONV(fptr)) { SET_BINARY_MODE(fptr); r = 1; /* no invalid char yet */ for (;;) { make_readconv(fptr, 0); - read_enc = io_read_encoding(fptr); for (;;) { if (fptr->cbuf.len) { - if (read_enc) - r = rb_enc_precise_mbclen(fptr->cbuf.ptr+fptr->cbuf.off, - fptr->cbuf.ptr+fptr->cbuf.off+fptr->cbuf.len, - read_enc); - else - r = ONIGENC_CONSTRUCT_MBCLEN_CHARFOUND(1); + r = rb_enc_precise_mbclen(fptr->cbuf.ptr+fptr->cbuf.off, + fptr->cbuf.ptr+fptr->cbuf.off+fptr->cbuf.len, + enc); if (!MBCLEN_NEEDMORE_P(r)) break; if (fptr->cbuf.len == fptr->cbuf.capa) { @@ -4932,25 +4927,18 @@ rb_io_each_codepoint(VALUE io) if (more_char(fptr) == MORE_CHAR_FINISHED) { clear_readconv(fptr); if (!MBCLEN_CHARFOUND_P(r)) { - enc = read_enc; goto invalid; } return io; } } if (MBCLEN_INVALID_P(r)) { - enc = read_enc; goto invalid; } n = MBCLEN_CHARFOUND_LEN(r); - if (read_enc) { - c = rb_enc_codepoint(fptr->cbuf.ptr+fptr->cbuf.off, - fptr->cbuf.ptr+fptr->cbuf.off+fptr->cbuf.len, - read_enc); - } - else { - c = (unsigned char)fptr->cbuf.ptr[fptr->cbuf.off]; - } + c = rb_enc_codepoint(fptr->cbuf.ptr+fptr->cbuf.off, + fptr->cbuf.ptr+fptr->cbuf.off+fptr->cbuf.len, + enc); fptr->cbuf.off += n; fptr->cbuf.len -= n; rb_yield(UINT2NUM(c)); @@ -4958,7 +4946,6 @@ rb_io_each_codepoint(VALUE io) } } NEED_NEWLINE_DECORATOR_ON_READ_CHECK(fptr); - enc = io_input_encoding(fptr); while (io_fillbuf(fptr) >= 0) { r = rb_enc_precise_mbclen(fptr->rbuf.ptr+fptr->rbuf.off, fptr->rbuf.ptr+fptr->rbuf.off+fptr->rbuf.len, enc); From 577cf5e3841e0ef142c192f9bd17d64707221402 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sat, 15 Nov 2025 12:07:44 +0900 Subject: [PATCH 3/3] [DOC] Remove an obsolete file It has been merged into `doc/ruby/options.md` with `field_processing.md` at ruby/ruby#10138. --- doc/command_line/environment.md | 174 -------------------------------- 1 file changed, 174 deletions(-) delete mode 100644 doc/command_line/environment.md diff --git a/doc/command_line/environment.md b/doc/command_line/environment.md deleted file mode 100644 index 8f6d595f6c2f25..00000000000000 --- a/doc/command_line/environment.md +++ /dev/null @@ -1,174 +0,0 @@ -## Environment - -Certain command-line options affect the execution environment -of the invoked Ruby program. - -### About the Examples - -The examples here use command-line option `-e`, -which passes the Ruby code to be executed on the command line itself: - -```console -$ ruby -e 'puts "Hello, World."' -``` - -### Option `-C` - -The argument to option `-C` specifies a working directory -for the invoked Ruby program; -does not change the working directory for the current process: - -```console -$ basename `pwd` -ruby -$ ruby -C lib -e 'puts File.basename(Dir.pwd)' -lib -$ basename `pwd` -ruby -``` - -Whitespace between the option and its argument may be omitted. - -### Option `-I` - -The argument to option `-I` specifies a directory -to be added to the array in global variable `$LOAD_PATH`; -the option may be given more than once: - -```console -$ pushd /tmp -$ ruby -e 'p $LOAD_PATH.size' -8 -$ ruby -I my_lib -I some_lib -e 'p $LOAD_PATH.size' -10 -$ ruby -I my_lib -I some_lib -e 'p $LOAD_PATH.take(2)' -["/tmp/my_lib", "/tmp/some_lib"] -$ popd -``` - -Whitespace between the option and its argument may be omitted. - -### Option `-r` - -The argument to option `-r` specifies a library to be required -before executing the Ruby program; -the option may be given more than once: - -```console -$ ruby -e 'p defined?(JSON); p defined?(CSV)' -nil -nil -$ ruby -r CSV -r JSON -e 'p defined?(JSON); p defined?(CSV)' -"constant" -"constant" -``` - -Whitespace between the option and its argument may be omitted. - -### Option `-0` - -Option `-0` defines the input record separator `$/` -for the invoked Ruby program. - -The optional argument to the option must be octal digits, -each in the range `0..7`; -these digits are prefixed with digit `0` to form an octal value: - -- If no argument is given, the input record separator is `0x00`. -- If the argument is `0`, the input record separator is `''`; - see {Special Line Separator Values}[rdoc-ref:IO@Special+Line+Separator+Values]. -- If the argument is in range `(1..0377)`, - it becomes the character value of the input record separator `$/`. -- Otherwise, the input record separator is `nil`. - -Examples: - -```console -$ ruby -0 -e 'p $/' -"\x00" -$ ruby -00 -e 'p $/' -"" -$ ruby -012 -e 'p $/' -"\n" -$ ruby -015 -e 'p $/' -"\r" -$ ruby -0377 -e 'p $/' -"\xFF" -$ ruby -0400 -e 'p $/' -nil -``` - -The option may not be separated from its argument by whitespace. - -### Option `-d` - -Some code in (or called by) the Ruby program may include statements or blocks -conditioned by the global variable `$DEBUG` (e.g., `if $DEBUG`); -these commonly write to `$stdout` or `$stderr`. - -The default value for `$DEBUG` is `false`; -option `-d` (or `--debug`) sets it to `true`: - -```console -$ ruby -e 'p $DEBUG' -false -$ ruby -d -e 'p $DEBUG' -true -``` - -### Option '-w' - -Option `-w` (lowercase letter) is equivalent to option `-W1` (uppercase letter). - -### Option `-W` - -Any Ruby code can create a warning message by calling method Kernel#warn; -methods in the Ruby core and standard libraries can also create warning messages. -Such a message may be printed on `$stderr` -(or not, depending on certain settings). - -Option `-W` helps determine whether a particular warning message -will be written, -by setting the initial value of global variable `$-W`: - -- `-W0`: Sets `$-W` to `0` (silent; no warnings). -- `-W1`: Sets `$-W` to `1` (moderate verbosity). -- `-W2`: Sets `$-W` to `2` (high verbosity). -- `-W`: Same as `-W2` (high verbosity). -- Option not given: Same as `-W1` (moderate verbosity). - -The value of `$-W`, in turn, determines which warning messages (if any) -are to be printed to `$stdout` (see Kernel#warn): - -```console -$ ruby -W1 -e 'p $foo' -nil -$ ruby -W2 -e 'p $foo' --e:1: warning: global variable '$foo' not initialized -nil -``` - -Ruby code may also define warnings for certain categories; -these are the default settings for the defined categories: - -```ruby -Warning[:experimental] # => true -Warning[:deprecated] # => false -Warning[:performance] # => false -``` - -They may also be set: - -```ruby -Warning[:experimental] = false -Warning[:deprecated] = true -Warning[:performance] = true -``` - -You can suppress a category by prefixing `no-` to the category name: - -```console -$ ruby -W:no-experimental -e 'p IO::Buffer.new' -# -``` -