Commit graph

834 commits

Author SHA1 Message Date
Nobuyoshi Nakada
35c794b26d Fixed by [Bug #18964] 2022-08-19 03:05:53 +09:00
Jean Boussier
b0b9f7201a rb_str_resize: Only clear coderange on truncation
If we are expanding the string or only stripping extra capacity
then coderange won't change, so clearing it is wasteful.
2022-08-18 10:09:08 +02: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
5e1c182900
Remove no longer used label [ci skip] 2022-06-29 12:38:12 +09:00
Nobuyoshi Nakada
b6b9a6190d
Check availability of utimensat on macOS 2022-06-27 17:52:13 +09:00
S-H-GAMELINKS
420f3ced4d Using is_ascii_string to check encoding 2022-06-17 12:02:50 +09:00
Kazuhiro NISHIYAMA
67950a4c0a
Fix missing paren [ci skip] 2022-05-06 18:13:22 +09:00
Burdette Lamar
ae96ef9cfb
File rdoc (#5888)
Treats:
    ::pipe?
    ::symlink?
    ::socket?
    ::blockdev?
    ::chardev?
2022-05-05 15:02:54 -05:00
Burdette Lamar
72628c1ccc
Enhanced RDoc for File (#5849)
Treats:

    #path
    ::stat
    ::lstat
    #lstat
    ::directory?

Also adds section "Example Files" that explains assumptions about example files. I'm using t.txt already, and I'm pretty sure I'll need t.dat (binary data). I don't know whether I'll need t.rus (Russian text).
2022-04-26 16:49:28 -05:00
Nobuyoshi Nakada
b0666d6417
[DOC] Use consistent terms [Bug #18680] 2022-04-18 17:53:05 +09:00
Nobuyoshi Nakada
7f81f33547 Return false where sticky-bit is not provided [Bug #18734] 2022-04-15 17:52:10 +09:00
Peter Zhu
381475f02e Use an empty string when building File.expand_path
Allocating a string of length MAXPATHLEN and then shrinking the string
is inefficient when the resulting path is short. Preallocating a large
string is also a problem for Variable Width Allocation since we can't
easily downsize the capacity.

I ran the following benchmark:

```ruby
Benchmark.ips do |x|
  {
    "empty" => "",
    "short" => "a/" * 10,
    "medium" => "a/" * 100,
    "long" => "a/" * 500
  }.each do |name, path|
    x.report(name) do |times|
      i = 0
      while i < times
        File.expand_path(path)
        i += 1
      end
    end
  end
end
```

On this commit:

```
 empty     97.486k (± 0.7%) i/s -    492.915k in   5.056507s
 short     96.026k (± 2.4%) i/s -    486.489k in   5.068966s
medium     86.304k (± 1.3%) i/s -    435.336k in   5.045112s
  long     59.395k (± 1.7%) i/s -    302.175k in   5.089026s
```

On master:

```
 empty     94.138k (± 1.4%) i/s -    472.158k in   5.016590s
 short     92.043k (± 1.4%) i/s -    468.180k in   5.087496s
medium     84.910k (± 2.3%) i/s -    425.750k in   5.017007s
  long     61.503k (± 2.7%) i/s -    309.723k in   5.039429s
```
2022-04-12 09:54:57 -04:00
Burdette Lamar
d0b7df8153
Fix formatting of What's Here for File (#5717) 2022-03-25 12:16:37 -05:00
Peter Zhu
f53f49197f [DOC] Replace with IO@Modes 2022-02-07 09:52:06 -05:00
Peter Zhu
a32e5e1b97 [DOC] Use RDoc link style for links in the same class/module
I used this regex:

(?<=\[)#(?:class|module)-([A-Za-z]+)-label-([A-Za-z0-9\-\+]+)

And performed a global find & replace for this:

rdoc-ref:$1@$2
2022-02-07 09:52:06 -05:00
Peter Zhu
f9a2802bc5 [DOC] Use RDoc link style for links to other classes/modules
I used this regex:

([A-Za-z]+)\.html#(?:class|module)-[A-Za-z]+-label-([A-Za-z0-9\-\+]+)

And performed a global find & replace for this:

rdoc-ref:$1@$2
2022-02-07 09:52:06 -05:00
Peter Zhu
ecd469fad0 [DOC] Fix links in documentation for File and IO
Fixes some typos and dead links.
2022-02-07 09:52:06 -05:00
Burdette Lamar
6dc4c942a3
File rdoc (#5438)
Treats:

    File introduction
    File.open
    File.new
2022-01-13 18:00:24 -06:00
Nobuyoshi Nakada
bf97415c02 Removed deprecated Dir.exists? and File.exists? 2021-12-28 18:36:30 +09:00
Nobuyoshi Nakada
4f74153846
Adjust styles [ci skip] 2021-12-24 21:17:27 +09:00
Samuel Williams
49166fc74a Improved exception usage/classes. 2021-12-21 12:25:42 +13:00
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