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

812 Коммитов

Автор SHA1 Сообщение Дата
Nobuyoshi Nakada 46e46eafd4
size_t is not for file size 2021-11-10 16:41:26 +09:00
Samuel Williams 4b89034218 IO::Buffer for scheduler interface. 2021-11-10 19:21:05 +13:00
Nobuyoshi Nakada 1ce3706c58
[DOC] Fix indent as single paragraph [ci skip] 2021-11-05 09:58:46 +09:00
U.Nakamura 3099bb6e3c rb_encoding is already const
- this change get rid of a warning of mswin build.
  see include/ruby/internal/encoding/encoding.h(116)
2021-10-14 10:23:33 +09:00
Nobuyoshi Nakada 8f480eafab rb_group_member: Simplify 2021-10-14 00:20:13 +09:00
Jeremy Evans ee89543e09 Fix regression on Solaris after change to use realpath on loaded features
After the change to use realpath on loaded features, Solaris CI
started failing in test_no_curdir (which tests behavior for running
ruby without a working directory).

I was able to trace the problem to the following call chain:

rb_call_inits->Init_Thread->Init_thread_sync->rb_provide->
get_loaded_features_index->rb_check_realpath->rb_dir_getwd_ospath->
ruby_getcwd

This will throw an exception, but because Ruby hasn't been fully
initialized at the point the exception is thrown, it just exits
with a status of 1.

The bug here is that rb_check_realpath should not raise an
exception, it should return nil.  This bug is hit on Solaris
because Solaris uses the realpath emulation instead of native
realpath, and the realpath emualation raised instead of
returning nil if the mode was RB_REALPATH_CHECK. Use rb_rescue
in the realpath emulation if the mode is RB_REALPATH_CHECK, and
swallow any exceptions raised and return nil.
2021-10-04 19:30:01 -09:00
xtkoba c5ff954410 Get rid of unused function warning for `_WIN32` 2021-10-03 11:06:24 +09:00
Nobuyoshi Nakada 3e46117d3f Associate the encoding to the found path 2021-10-01 20:28:44 +09:00
S.H b8c3a84bdd
Refactor and Using RBOOL macro 2021-09-15 08:11:05 +09:00
S-H-GAMELINKS bdd6d8746f Replace RBOOL macro 2021-09-05 23:01:27 +09:00
S-H-GAMELINKS 4794a8a7cf Add stat_time function 2021-08-24 09:23:07 +09:00
Akinori MUSHA 4814528296 [DOC] Fix the rdoc for File::Stat#size? [ci skip] 2021-08-17 21:44:41 +09:00
S.H 378e8cdad6
Using RBOOL macro 2021-08-02 12:06:44 +09:00
S.H 64adeeadaa
Add RBOOL macro and use it 2021-07-29 12:51:10 +09:00
Burdette Lamar c1741df1a1 What's Here for Numeric and Comparable 2021-06-21 10:38:16 -07:00
Burdette Lamar 4337da377e
What's Here for class File (#4460)
What's Here for class File
2021-05-07 11:22:32 -05:00
Nobuyoshi Nakada a5688b5ce6
Support non-standard `struct stat` [Bug #17793]
On 32-bit Android:
* `st_dev`/`st_rdev` are not `dev_t`
* `st_mode` is not `mode_t`
2021-04-12 15:32:49 +09:00
Nobuyoshi Nakada 43e0677c6d Fill the ring-buffer with the fallback value
Fill with the pointer to the root position, instead of zero and
comparing later.  Also suppress a false warning by Visual C++.

```
file.c(4759): warning C4090: 'function': different 'const' qualifiers
```
2021-04-02 14:17:33 +09:00
Nobuyoshi Nakada 82b6f89283 File.dirname optional level
* file.c (rb_file_dirname_n): chomp N level of base names.
  [Feature #12194]
2021-03-15 15:09:05 +09:00
xtkoba (Tee KOBAYASHI) 3ac28de541
Explicitly cast __s64 to time_t [Bug #17645]
A workaround of shorten-64-to-32 error where 32-bit linux.
2021-03-14 20:10:01 +09:00
Nobuyoshi Nakada 0d57d59933 Keep encoding in the result of File.expand_path [Bug #17517] 2021-01-15 17:46:48 +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
Hiroshi SHIBATA e380f78851 Removed rb_find_file_ext_safe and rb_find_file_safe 2020-09-23 09:09:36 +09:00
Jean Boussier 2c6512fe67 Get rid of the redundant stat() in rb_check_realpath_internal 2020-07-07 00:26:37 +09:00
卜部昌平 de3e931df7 add UNREACHABLE_RETURN
Not every compilers understand that rb_raise does not return.  When a
function does not end with a return statement, such compilers can issue
warnings.  We would better tell them about reachabilities.
2020-06-29 11:05:41 +09:00
卜部昌平 e9cb092b2d rb_f_stat: 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
Nobuyoshi Nakada c3ba2db48b
Removed execpath argument of path_check_0 as always TRUE now 2020-06-23 10:01:23 +09:00
Nobuyoshi Nakada 61374839e4
Removed fpath_check, no longer used since taint flag was removed 2020-06-23 10:01:23 +09:00
Alan D. Salewski c15cddd1d5 Allow Dir.home to work for non-login procs when $HOME not set
Allow the 'Dir.home' method to reliably locate the user's home directory when
all three of the following are true at the same time:

    1. Ruby is running on a Unix-like OS
    2. The $HOME environment variable is not set
    3. The process is not a descendant of login(1) (or a work-alike)

The prior behavior was that the lookup could only work for login-descended
processes.

This is accomplished by looking up the user's record in the password database
by uid (getpwuid_r(3)) as a fallback to the lookup by name (getpwname_r(3))
which is still attempted first (based on the name, if any, returned by
getlogin_r(3)).

If getlogin_r(3), getpwnam_r(3), and/or getpwuid_r(3) is not available at
compile time, will fallback on using their respective non-*_r() variants:
getlogin(3), getpwnam(3), and/or getpwuid(3).

The rationale for attempting to do the lookup by name prior to doing it by uid
is to accommodate the possibility of multiple login names (each with its own
record in the password database, so each with a potentially different home
directory) being mapped to the same uid (as is explicitly allowed for by
POSIX; see getlogin(3posix)).

Preserves the existing behavior for login-descended processes, and adds the
new capability of having Dir.home being able to find the user's home directory
for non-login-descended processes.

Fixes [Bug #16787]

Related discussion:
    https://bugs.ruby-lang.org/issues/16787
    https://github.com/ruby/ruby/pull/3034
2020-05-23 23:16:28 +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
卜部昌平 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 a58bbd6a51
Use `rb_warn_deprecated` for `File.exists?` and `Dir.exists?` 2020-04-06 21:43:32 +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
NAKAMURA Usaku 204dc3f39f Revert "Should return "." for File.extname("file.") also on Windows"
We want to introduce consistency and better compatibility with unixen,
but the Windows APIs doues not have consistency fundamentally and
we can not found any logical way...

This reverts commit 61aff0cd18.
2019-12-23 11:54:25 +09:00
NAKAMURA Usaku 61aff0cd18 Should return "." for File.extname("file.") also on Windows
But not changes another cases, such as "file.rb."
[Bug #15267]
2019-12-22 02:42:09 +09:00
Nobuyoshi Nakada 04e95f8985 Get rid of infinite recursion at loading transcoder
Disable encoding US-ASCII path to filesystem on Windows too.
[Bug #16392]
2019-12-16 16:16:54 +09:00
Nobuyoshi Nakada 14a17063a1
Fixed stack overflow [Bug #16382]
Get rid of infinite recursion in expanding a load path to the real
path while loading a transcoder.
2019-12-03 08:51:50 +09:00
Jeremy Evans ffd0820ab3 Deprecate taint/trust and related methods, and make the methods no-ops
This removes the related tests, and puts the related specs behind
version guards.  This affects all code in lib, including some
libraries that may want to support older versions of Ruby.
2019-11-18 01:00:25 +02:00
Jeremy Evans c5c05460ac Warn on access/modify of $SAFE, and remove effects of modifying $SAFE
This removes the security features added by $SAFE = 1, and warns for access
or modification of $SAFE from Ruby-level, as well as warning when calling
all public C functions related to $SAFE.

This modifies some internal functions that took a safe level argument
to no longer take the argument.

rb_require_safe now warns, rb_require_string has been added as a
version that takes a VALUE and does not warn.

One public C function that still takes a safe level argument and that
this doesn't warn for is rb_eval_cmd.  We may want to consider
adding an alternative method that does not take a safe level argument,
and warn for rb_eval_cmd.
2019-11-18 01:00:25 +02:00
Nobuyoshi Nakada 4f13927f1f
[DOC] no change on Windows [Bug #15267] [ci skip] 2019-10-17 19:43:10 +09:00
Nobuyoshi Nakada e169ad93f4 Fixed File.extname at a name ending with a dot
File.extname now returns a dot string at a name ending with a dot.
[Bug #15267]
2019-10-17 18:51:51 +09:00
Jeremy Evans 978276a7d9 Update documentation for File#{readable,writable,executable}{,_real}? [ci skip]
Some OS-level security features cause these methods to not return
expected results.  For example fs.protected_regular sysctl on Linux,
or pledge(2)/unveil(2) on OpenBSD.

Fixes [Bug #16002]
2019-10-14 17:43:11 -07:00
Nobuyoshi Nakada 0c6f36668a
Adjusted spaces [ci skip] 2019-09-27 10:20:56 +09:00
David Rodríguez 2a166cfea2 Add `File.absolute_path?` (#2198)
In order to check whether a path is absolute or not in a portable way.

[Feature #15868]
2019-09-05 20:00:50 +09:00
卜部昌平 3df37259d8 drop-in type check for rb_define_singleton_method
We can check the function pointer passed to
rb_define_singleton_method like how we do so in rb_define_method.
Doing so revealed many arity mismatches.
2019-08-29 18:34:09 +09:00
卜部昌平 7bcfd9189a drop-in type check for rb_define_global_function
We can check the function pointer passed to rb_define_global_function
like we do so in rb_define_method.  It turns out that almost anybody
is misunderstanding the API.
2019-08-29 18:34:09 +09:00