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

530 Коммитов

Автор SHA1 Сообщение Дата
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
Nobuyoshi Nakada 7dc0511ea4 Remove "." and ".." from Dir.glob with FNM_DOTMATCH [Bug #17280]
Co-authored-by: Jeremy Evans <code@jeremyevans.net>
2021-01-12 20:02:43 +09:00
Yusuke Endoh 8e1c0b2f93 dir.c: chdir conflict should raise only when called in different thread
... and keep it as a warning (like 2.7) when it is called in the same
thread. [Bug #15661]
2020-12-24 14:34:40 +09:00
Nobuyoshi Nakada 4e01ab342a
Revert "Removed deprecated Dir.exists? and File.exists?"
This reverts commit 1a5205536f.
2020-12-02 19:11:01 +09:00
Nobuyoshi Nakada 1a5205536f
Removed deprecated Dir.exists? and File.exists? 2020-12-02 17:24:34 +09:00
Jeremy Evans 5d7953f86b Switch conflicting chdir warning to RuntimeError
The documentation already stated this was an error in one case
(when it was previously a warning).  Describe the other case,
where chdir without block is called inside block passed to chdir.

Fixes [Bug #15661]
2020-09-28 08:34:04 -07:00
卜部昌平 ff30358d13 RARRAY_AREF: convert into an inline function
RARRAY_AREF has been a macro for reasons.  We might not be able to
change that for public APIs, but why not relax the situation internally
to make it an inline function.
2020-08-15 12:09:26 +09:00
卜部昌平 2bd0f37e2b glob_opendir: move cleanup codes at the end
Nobu likes this arrangement.
2020-06-29 11:05:41 +09:00
卜部昌平 99073f49bf glob_opendir: do not goto into a branch
I'm not necessarily against every goto in general, but jumping into a
branch is definitely a bad idea.  Better refactor.
2020-06-29 11:05:41 +09:00
卜部昌平 70857ae1aa glob_make_pattern: do not goto into a branch
I'm not necessarily against every goto in general, but jumping into a
branch is definitely a bad idea.  Better refactor.
2020-06-29 11:05:41 +09:00
卜部昌平 9e41a75255 sed -i 's|ruby/impl|ruby/internal|'
To fix build failures.
2020-05-11 09:24:08 +09:00
卜部昌平 d7f4d732c1 sed -i s|ruby/3|ruby/impl|g
This shall fix compile errors.
2020-05-11 09:24:08 +09:00
Nobuyoshi Nakada 5d430c1b34
Added more NORETURN declarations 2020-05-11 00:40:14 +09:00
卜部昌平 9e6e39c351
Merge pull request #2991 from shyouhei/ruby.h
Split ruby.h
2020-04-08 13:28:13 +09:00
Nobuyoshi Nakada 67f616c523
Show the deprecated name in the warning
Fixed up a58bbd6a51.
2020-04-07 12:49:33 +09:00
Nobuyoshi Nakada d827c718db
[DOC] Removed RDoc of deprecated methods [ci skip] 2020-04-06 23:06:03 +09:00
Nobuyoshi Nakada 827e88119c Moved `Dir.[]` to dir.rb 2020-04-06 22:22:25 +09:00
Nobuyoshi Nakada 60e25e37d4 Moved `Dir.glob` to dir.rb 2020-04-06 22:22:25 +09:00
Nobuyoshi Nakada 310054b240 Moved `Dir.open` and `Dir#initialize` to dir.rb 2020-04-06 22:22:25 +09:00
Nobuyoshi Nakada a58bbd6a51
Use `rb_warn_deprecated` for `File.exists?` and `Dir.exists?` 2020-04-06 21:43:32 +09:00
Nobuyoshi Nakada c7d668801b
Fixed crash when argument array is modified 2020-03-25 01:23:03 +09:00
卜部昌平 115fec062c more on NULL versus functions.
Function pointers are not void*.  See also
ce4ea956d2
8427fca49b
2020-02-07 14:24:19 +09:00
Nobuyoshi Nakada bdef392ec6
Fixed double closedir
In the case that shinking the entries buffer to the exact size
failed, `dirp` is already closed.  Found by mame with Coverity
Scan.
2020-01-20 09:49:27 +09:00
Nobuyoshi Nakada 2f1081a451
Sort globbed results by default [Feature #8709]
Sort the results which matched single wildcard or character set in
binary ascending order, unless `sort: false` is given.  The order
of an Array of pattern strings and braces are not affected.
2020-01-19 14:46:01 +09:00
Nobuyoshi Nakada eb96e4e981
Made glob option keyword IDs static 2020-01-18 18:14:47 +09:00
Seiei Miyagi a0d1fd16d1 Fix documentation of Dir#each_child 2019-12-29 12:59:23 +09:00
卜部昌平 5e22f873ed decouple internal.h headers
Saves comitters' daily life by avoid #include-ing everything from
internal.h to make each file do so instead.  This would significantly
speed up incremental builds.

We take the following inclusion order in this changeset:

1.  "ruby/config.h", where _GNU_SOURCE is defined (must be the very
    first thing among everything).
2.  RUBY_EXTCONF_H if any.
3.  Standard C headers, sorted alphabetically.
4.  Other system headers, maybe guarded by #ifdef
5.  Everything else, sorted alphabetically.

Exceptions are those win32-related headers, which tend not be self-
containing (headers have inclusion order dependencies).
2019-12-26 20:45:12 +09:00
Nobuyoshi Nakada fb11e6089d
[DOC] Added File::FNM_SYSCASE example [Bug #16391] [ci skip] 2019-12-04 21:52:29 +09:00