Граф коммитов

557 Коммитов

Автор SHA1 Сообщение Дата
Nobuyoshi Nakada 5326337d4f [Feature #20244] Issue a single `Warning.warn` call
Make the entire series of message lines a multiline string so that the
`Warning.warn` hook can receive them in a single call.
2024-03-14 18:33:28 +09:00
Nobuyoshi Nakada 67fe047821 [Feature #20244] Register global variable for another thread
Co-authored-by: Alan Wu <XrXr@users.noreply.github.com>
2024-03-14 18:33:28 +09:00
Nobuyoshi Nakada 4bb8f8582f [Feature #20244] Show the conflicting another chdir block 2024-03-14 18:33:28 +09:00
Nobuyoshi Nakada 8fe86feecd [Feature #20244] Extract `chdir_lock` and its stuffs 2024-03-14 18:33:28 +09:00
Nobuyoshi Nakada d86c4e553e
Define `IO_WITHOUT_GVL` macro 2024-01-24 20:51:50 +09:00
Xavier Noria aad246feba s/SafeStringValue/StringValue/
The macro SafeStringValue() became just StringValue() in c5c05460ac,
and it is deprecated nowadays.

This patch replaces remaining macro usage. Some occurrences are left in
ext/stringio and ext/win32ole, they should be fixed upstream.

The macro itself is not deleted, because it may be used in extensions.
2024-01-12 12:24:48 -08:00
Nobuyoshi Nakada 494e6b54ab
[DOC] Add links from `File::Constants` in dir.c to `File` constants
Due to the bug ruby/rdoc#1067, `rb_file_const` needs `Document-const`
directives.
2023-12-18 20:17:44 +09:00
Victor Shepelev 570d7b2c3e
[DOC] Adjust some new features wording/examples. (#9183)
* Reword Range#overlap? docs last paragraph.

* Docs: add explanation about Queue#freeze

* Docs: Add :rescue event docs for TracePoint

* Docs: Enhance Module#set_temporary_name documentation

* Docs: Slightly expand Process::Status deprecations

* Fix MatchData#named_captures rendering glitch

* Improve Dir.fchdir examples

* Adjust Refinement#target docs
2023-12-14 23:01:48 +02:00
Jeremy Evans f49af3c969 Make Dir#chdir never yield args, and return block return value
If no block is given, return 0 instead of nil for consistency
with Dir.chdir and Dir.fchdir.
2023-12-11 22:31:16 -08:00
Victor Shepelev 07734b51c6
[DOC] Small fixes for documentation rendering
Mostly just fixing RDoc's incorrect treatment of `+`
2023-12-09 13:54:33 +09:00
Nobuyoshi Nakada 0cdad3b92a Add `RUBY_REFERENCES`
Instead of `RUBY_REFERENCES_START` and `RUBY_REFERENCES_END`, so that
auto-indent works well.
2023-11-30 21:39:28 +09:00
Nobuyoshi Nakada 30f7b7a053 Prefix `REF_EDGE` and `REFS_LIST_PTR` with `RUBY_`
Also move `struct` so that `typedef`-ed names can be used.
2023-11-30 21:39:28 +09:00
Peter Zhu b040c529a0 Implement dir on VWA 2023-11-22 09:36:54 -05:00
Nobuyoshi Nakada 63fdfa1312
[DOC] Link Dir.exist? to File.directory? 2023-11-14 17:29:15 +09:00
Nobuyoshi Nakada b01118f29c
[DOC] Describe Dir.home 2023-11-14 17:20:57 +09:00
Koichi Sasada be1bbd5b7d M:N thread scheduler for Ractors
This patch introduce M:N thread scheduler for Ractor system.

In general, M:N thread scheduler employs N native threads (OS threads)
to manage M user-level threads (Ruby threads in this case).
On the Ruby interpreter, 1 native thread is provided for 1 Ractor
and all Ruby threads are managed by the native thread.

From Ruby 1.9, the interpreter uses 1:1 thread scheduler which means
1 Ruby thread has 1 native thread. M:N scheduler change this strategy.

Because of compatibility issue (and stableness issue of the implementation)
main Ractor doesn't use M:N scheduler on default. On the other words,
threads on the main Ractor will be managed with 1:1 thread scheduler.

There are additional settings by environment variables:

`RUBY_MN_THREADS=1` enables M:N thread scheduler on the main ractor.
Note that non-main ractors use the M:N scheduler without this
configuration. With this configuration, single ractor applications
run threads on M:1 thread scheduler (green threads, user-level threads).

`RUBY_MAX_CPU=n` specifies maximum number of native threads for
M:N scheduler (default: 8).

This patch will be reverted soon if non-easy issues are found.

[Bug #19842]
2023-10-12 14:47:01 +09:00
Nobuyoshi Nakada 50520cc193
[DOC] Missing comment markers 2023-09-27 16:18:05 +09:00
Burdette Lamar bcc160b449
[DOC] RDoc for File::Constants (#8103) 2023-07-23 10:24:19 -04:00
Stan Lo 0db58dd0db [ruby/irb] Declare rdoc as dependency
(https://github.com/ruby/irb/pull/648)

IRB already has several features that rely on rdoc, such as:

- Autocompletion's document dialog
- Autocompletion's `PerfectMatchedProc`
- The `show_doc` command
- Easter egg

And we could use its pager more in the future too. So it makes sense to
declare rdoc as a dependency instead of relying on the one bundled with
Ruby.

https://github.com/ruby/irb/commit/4dffbb1dd3
2023-07-18 13:53:31 +00:00
Burdette Lamar 7f2bd17fad
[DOC] RDoc for dir.c (#8037) 2023-07-07 16:37:36 -04:00
Burdette Lamar 00f9231534
[DOC] RDoc for some of dir.c (#8026) 2023-07-05 09:45:54 -04:00
Nobuyoshi Nakada c803e92d66
Return `errno` as the result instead of the global variable 2023-05-12 18:36:02 +09:00
Nobuyoshi Nakada 05b7bbecc6
Suppress `-Wdiscarded-qualifiers` warning where `fchdir` is unusable 2023-04-04 11:27:43 +09:00
Jeremy Evans c08fe40872 Fix Dir.for_fd call-seq 2023-03-24 16:16:32 -07:00
Jeremy Evans 836e9a192b Add Dir.for_fd
This returns a Dir instance for the given directory file descriptor.
If fdopendir is not supported, this raises NotImplementedError.

Implements [Feature #19347]
2023-03-24 11:18:57 -07:00
Jeremy Evans 3be65f63c7 Add Dir#chdir
This uses Dir.fchdir if supported, or Dir.chdir otherwise.

Implements [Feature #19347]
2023-03-24 11:18:57 -07:00
Jeremy Evans 466ca7ae20 Add Dir.fchdir
This is useful for passing directory file descriptors over UNIX
sockets or to child processes to avoid TOCTOU vulnerabilities.

The implementation follows the Dir.chdir code.

This will raise NotImplementedError on platforms not supporting
both fchdir and dirfd.

Implements [Feature #19347]
2023-03-24 11:18:57 -07:00
Matt Valentine-House 405966e239 Implement declarative references for dir_data_type 2023-03-17 19:20:40 +00:00
S-H-GAMELINKS 040e0c8d67 Reuse NIL_OR_UNDEF_P macro 2022-12-02 01:19:55 +09:00
S-H-GAMELINKS 1f4f6c9832 Using UNDEF_P macro 2022-11-16 18:58:33 +09:00
Hiroshi Shirosaki 329d5424a4 [Bug #19042] Fix Dir.glob brace with '/'
Dir.glob brace pattern with '/' after '**' does not match
paths in recursive expansion process.
We expand braces with '/' before expanding a recursive.

Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
2022-10-18 09:18:03 +09:00
Takashi Kokubun 5b21e94beb Expand tabs [ci skip]
[Misc #18891]
2022-07-21 09:42:04 -07:00
Jean Boussier d084585f01 Rename ENCINDEX_ASCII to ENCINDEX_ASCII_8BIT
Otherwise it's way too easy to confuse it with US_ASCII.
2022-07-19 08:48:56 +02:00
Nobuyoshi Nakada a58611dfb1 Allow to just warn as bool expected, without an exception 2022-06-20 19:35:12 +09:00
Yuta Saito 44d0caa1ca dir.c: refresh pathtype when emulating `IFTODT` in `glob_helper`
When using `IFTODT` defined in libc, `dirent.d_type` oriented pathtype
is compatible with `IFTODT(stat.st_mode)`. However they are not
compatible when emulating `IFTODT`, so `glob_helper` has to stat instead
of reusing dirent result by passing unknown pathtype to `glob_helper`.

This is a follow-up fix of 0c90ca4dd0
2022-04-03 01:13:16 +09:00
Yuta Saito 0c90ca4dd0 dir.c: use self-made IFTODT in rb_pathtype_t if available
dir.c defines IFTODT if the system doesn't have it. The macro is used
when comparing with rb_pathtype_t's cases. rb_pathtype_t's cases are
defined by DT_XXX macro if they are available, or defined using IFTODT.
Most POSIX-compatible platforms have both IFTODT and DT_XXX and most of
other platforms like MinGW have neither of them. On those platforms,
DT_XXX-oriented rb_pathtype_t is always compared with values converted
by system's IFTODT, and emulated-IFTODT-oriented rb_pathtype_t is always
compared with values converted by emulated-IFTODT.

However, when IFTODT is *not defined* and DT_XXX is *defined*, like
on wasi-libc, DT_XXX-oriented rb_pathtype_t was compared with values
converted by emulated-IFTODT, and they are not guaranteed to be
compatible.

This patch fixes such a situation by using emulated-IFTODT to define
rb_pathtype_t when either IFTODT or DT_XXX is not available.
2022-03-02 12:50:53 +09:00
Yuta Saito 9033ac3e2c dir.c: ignore ENOTCAPABLE while glob similar to EACCES 2022-01-19 11:19:06 +09:00
Nobuyoshi Nakada 069cca6f74
Negative RBOOL usage 2022-01-01 17:02:04 +09:00
Nobuyoshi Nakada bf97415c02 Removed deprecated Dir.exists? and File.exists? 2021-12-28 18:36:30 +09:00
Nobuyoshi Nakada 89b440bf72
Expect bool as `sort:` option at glob [Feature #18287] 2021-11-18 21:47:18 +09:00
S.H dc9112cf10
Using NIL_P macro instead of `== Qnil` 2021-10-03 22:34:45 +09:00
S-H-GAMELINKS bdd6d8746f Replace RBOOL macro 2021-09-05 23:01:27 +09:00
Jeremy Evans a2592702ae Actually ignore FNM_CASEFOLD flag in Dir.glob
This was already documented as being ignored, but it wasn't being
ignored, causing an issue in a particular case where a UTF-8
pattern was provided and a filename was tested that wasn't valid
UTF-8.

Fixes [Bug #14456]
2021-06-24 12:22:09 -07:00
Nobuyoshi Nakada 4bd538e847
dir.rb: moved class rdoc from dir.c 2021-06-07 20:44:05 +09:00
Nobuyoshi Nakada a35d137a37 [DOC] Moved `File.fnmatch?` to dir.rb
So that no longer disturbed by C comment delimiters.
2021-05-21 09:01:01 +09:00
Burdette Lamar 86b4c2fc3f
What's Here for class Dir (#4472)
What's Here for class Dir
2021-05-07 15:14:08 -05:00
Benoit Daloze 0764d323d8 Fix -Wundef warnings for patterns `#if HAVE`
* See [Feature #17752]
* Using this to detect them:
  git grep -P 'if\s+HAVE' | grep -Pv 'HAVE_LONG_LONG|/ChangeLog|HAVE_TYPEOF'
2021-05-04 14:56:55 +02:00
Benoit Daloze 68d6bd0873 Fix trivial -Wundef warnings
* See [Feature #17752]

Co-authored-by: xtkoba (Tee KOBAYASHI) <xtkoba+ruby@gmail.com>
2021-05-04 14:56:55 +02:00
Nobuyoshi Nakada 60bdf03b6d
[DOC] Adjusted spacing [ci skip] 2021-04-11 13:21:33 +09:00
Nobuyoshi Nakada 083c5f08ec Check stack overflow in recursive glob_helper [Bug #17162] 2021-01-13 12:16:00 +09:00