Nobuyoshi Nakada
715955ff27
Include ruby/assert.h in ruby/ruby.h so that assertions can be there
2019-07-14 17:58:03 +09:00
Tanaka Akira
4d9504fe13
Delegates 3 arguments for Pathname.glob.
...
Thanks for the patch by pocke (Masataka Kuwabara) [Feature #14405 ].
2019-07-14 17:42:58 +09:00
nobu
15a98ab428
Try statx syscall
...
* file.c (rb_file_s_birthtime): export for pathname to check if
birthtime is supported.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67097 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-02-20 06:54:23 +00:00
nobu
3d1c86a26f
Removed moving toplevel header since r12501
...
Moving public headers was 12-years ago, no depend files would
expect ruby.h in the top source directory now.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67033 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-02-08 02:46:22 +00:00
akr
78dc3da299
Pathname#relative_path_from uses is_a?
...
I reconsidered because simpler code would have better maintainablity.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-18 03:09:54 +00:00
akr
4cf828632f
Pathname#relative_path_from compatible with mock.
...
[Fix GH-2049]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66416 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-16 12:26:52 +00:00
akr
53a5b276b8
Use File class methods to avoid pipe execution
...
Following methods use corresponding File class methods
instead of IO class methods.
- Pathname#each_line
- Pathname#read
- Pathname#binread
- Pathname#write
- Pathname#binwrite
- Pathname#readlines
Reported by ooooooo_q.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66346 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-12 05:07:49 +00:00
marcandre
dde0e30c2d
Pathname: Have #relative_path_from accept String argument.
...
[Fix GH-1975]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65706 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-13 06:20:06 +00:00
nobu
74325360d3
Pathname: Simplified Pathname#mountpoint?
...
Removed unnecessary comparison in mountpoint?
[Fix GH-1927]
From: John Whitson <john.whitson@gmail.com>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64273 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-10 12:04:24 +00:00
watson1978
ccc2576514
Improve Pathname performance
...
If it will not use special variables (like $1, $&, $`...),
it can improve the performance by using Regexp#match? instead of Regexp#=~.
Because Regexp#=~ will generate the objects to special variables by pattern matching.
This patch will replace Regexp#=~ without special variables to Regexp#match?.
(Excludes https://github.com/ruby/ruby/blob/trunk/ext/pathname/lib/pathname.rb#L144-L153 )
[Fix GH-1836] [ruby-core:86093] [Bug #14599 ]
## Environment
* OS : Ubuntu 17.10
* Compiler : gcc version 7.2.0
* CPU : Intel(R) Core(TM) i5-3210M CPU @ 2.50GHz
* Memory : 16 GB
## TL;DR
| Before | After | Speed up
--------------------------- | ------ | ------ | --------
Pathname#absolute? | 142836 | 198487 | 39.0%
Pathname#cleanpath | 60706 | 79415 | 30.8%
Pathname#root? | 603806 | 759157 | 25.7%
Pathname#absolute? | 142592 | 197859 | 38.8%
Pathname#each_filename | 115600 | 152982 | 32.3%
Pathname#ascend | 50494 | 63606 | 26.0%
Pathname#+ | 100550 | 130372 | 29.7%
Pathname#join | 46673 | 60994 | 30.7%
Pathname#relative_path_from | 28362 | 37494 | 32.2%
## Before
```
Calculating -------------------------------------
Pathname#absolute? 142.836k (± 0.1%) i/s - 722.304k in 5.056884s
Pathname#cleanpath 60.706k (± 0.1%) i/s - 306.764k in 5.053305s
Pathname#root? 603.806k (± 0.3%) i/s - 3.062M in 5.071696s
Pathname#absolute? 142.592k (± 0.1%) i/s - 720.846k in 5.055301s
Pathname#each_filename
115.600k (± 0.1%) i/s - 586.818k in 5.076292s
Pathname#ascend 50.494k (± 0.1%) i/s - 255.301k in 5.056049s
Pathname#+ 100.550k (± 0.1%) i/s - 509.630k in 5.068433s
Pathname#join 46.673k (± 0.1%) i/s - 236.433k in 5.065696s
Pathname#relative_path_from
28.362k (± 0.0%) i/s - 143.728k in 5.067640s
```
## After
```
Calculating -------------------------------------
Pathname#absolute? 198.487k (± 0.1%) i/s - 995.665k in 5.016272s
Pathname#cleanpath 79.415k (± 0.1%) i/s - 404.406k in 5.092344s
Pathname#root? 759.157k (± 0.0%) i/s - 3.800M in 5.005072s
Pathname#absolute? 197.859k (± 0.1%) i/s - 995.720k in 5.032494s
Pathname#each_filename
152.982k (± 0.1%) i/s - 775.555k in 5.069607s
Pathname#ascend 63.606k (± 0.0%) i/s - 320.862k in 5.044560s
Pathname#+ 130.372k (± 0.1%) i/s - 660.856k in 5.068991s
Pathname#join 60.994k (± 0.1%) i/s - 305.068k in 5.001626s
Pathname#relative_path_from
37.494k (± 0.4%) i/s - 189.124k in 5.044146s
```
## Benchmark code
```ruby
require 'pathname'
require 'benchmark/ips'
Benchmark.ips do |x|
root = Pathname.new('/')
path1 = Pathname.new('/path/to/some/file1.rb')
path2 = Pathname.new('/path/to/some/file2.rb')
x.report("Pathname#absolute?") do
path1.absolute?
end
x.report("Pathname#cleanpath") do
Pathname.new('/path/to/some/file.rb').cleanpath
end
x.report("Pathname#root?") do
path1.root?
end
x.report("Pathname#absolute?") do
path1.absolute?
end
x.report("Pathname#each_filename") do
path1.each_filename { |file| }
end
x.report("Pathname#ascend") do
path1.ascend { |path| }
end
x.report("Pathname#+") do
path1 + path2
end
x.report("Pathname#join") do
path1.join("../file3.rb")
end
x.report("Pathname#relative_path_from") do
path1.relative_path_from(root)
end
end
```
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62740 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-13 09:15:10 +00:00
stomar
c1e1e2b6d9
pathname.c: improve docs for Pathname
...
* ext/pathname/pathname.c: [DOC] improve example for Pathname.glob,
by using a more common glob pattern, and improve the reference
to the `base' keyword argument for Pathname#glob.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60711 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-07 20:14:46 +00:00
nobu
dfbeb7188d
Pathname: get rid of a -Wcomment warning [DOC]
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60600 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-01 03:26:27 +00:00
marcandre
e63dd598a7
Pathname: Simplify example [DOC] [ci-skip]
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60594 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-31 22:24:03 +00:00
akr
4ad1ac75e4
declare variables once for each line in pathname.c.
...
This ease adding/deleting variables.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60241 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21 08:41:59 +00:00
akr
cea5f5aaee
Pathname#glob method implemented.
...
[ruby-core:49373] [Feature #7360 ] proposed by Alexander E. Fischer.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60238 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21 08:34:49 +00:00
nobu
4f8107a4ba
disable rdoc for internal constants [ci skip]
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59484 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-03 08:11:57 +00:00
nobu
2d3c331510
extract IDs
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59482 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-03 07:08:00 +00:00
nobu
2875337533
pathname.rb: UNC root pathname needs a separator
...
* ext/pathname/lib/pathname.rb (Pathname#plus): UNC root pathname
needs a separator. File.basename returns "/" on UNC root, as
well as sole drive letter, even if it does not end with a
separator. [ruby-core:80900] [Bug #13515 ]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59102 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-16 14:44:01 +00:00
shyouhei
20c72dc89d
ruby tool/update-deps --fix
...
Onigumo 6 (r57045) introduced new onigumo.h header file, which is
required from quite much everywhere. This commit adds necessary
dependencies.
Note: ruby/oniguruma.h now includes onigumo.h,
ruby/io.h includes oniguruma.h,
ruby/encoding.h also includes oniguruma.h,
and internal.h includes encoding.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58054 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-22 06:00:18 +00:00
akr
9373c5efb9
Pathname#empty? implemented.
...
* ext/pathname/pathname.c (Pathname#empty?): New method.
[ruby-core:76404] [Feature#12596] Proposed by John Backus.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56571 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-05 03:29:08 +00:00
nobu
e4257036ec
pathname.c: unnormalized Fixnum value
...
* ext/pathname/pathname.c (path_hash): fix unnormalized Fixnum
value bug on mingw/mswin.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56553 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-04 01:51:18 +00:00
nobu
c463366dfd
rb_funcallv
...
* *.c: rename rb_funcall2 to rb_funcallv, except for extensions
which are/will be/may be gems. [Fix GH-1406]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55773 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-07-29 11:57:14 +00:00
nobu
64fea27496
Update dependencies
...
* common.mk (compile.o, loadpath.o): update dependencies.
* common.mk (vm_call.o): remove stale object dependencies.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55589 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-07-06 05:48:13 +00:00
naruse
c4fdfabcc8
handle ext/ as r53141
...
g -L frozen_string_literal ext/**/*.rb|xargs ruby -Ka -e'ARGV.each{|fn|puts
fn;open(fn,"r+"){|f|s=f.read.sub(/\A(#!.*\n)?(#.*coding.*\n)?/,"\\&#
frozen_string_literal: false\n");f.rewind;f.write s}}'
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53143 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-16 05:31:54 +00:00
akr
68ebbbfebe
* lib/open-uri.rb: Remove indicator for "frozen_string_literal: true".
...
* lib/pp.rb: Ditto.
* lib/prettyprint.rb: Ditto.
* lib/resolv.rb: Ditto.
* lib/securerandom.rb: Ditto.
* lib/tmpdir.rb: Ditto.
* lib/unicode_normalize/tables.rb: Ditto.
* test/net/ftp/test_buffered_socket.rb: Ditto.
* test/net/ftp/test_mlsx_entry.rb: Ditto.
* test/open-uri/test_open-uri.rb: Ditto.
* test/open-uri/test_ssl.rb: Ditto.
* test/pathname/test_pathname.rb: Ditto.
* test/test_pp.rb: Ditto.
* test/test_prettyprint.rb: Ditto.
* tool/transcode-tblgen.rb: Ditto.
* ext/pathname/lib/pathname.rb: Ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52526 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-10 11:48:14 +00:00
akr
36ca18b847
Put an line before "frozen_string_literal: true" for emacs.
...
https://bugs.ruby-lang.org/issues/8976#note-49
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52052 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-05 22:22:56 +00:00
akr
7ab70c3548
* ext/pathname/lib/pathname.rb: freeze string literals for
...
reduced object allocation.
patch by schneems.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52023 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-04 13:05:32 +00:00
akr
8bb581f8dd
* ext/pathname/lib/pathname.rb (descend): Blockless form supported.
...
(ascend): Ditto.
[ruby-core:68820] [Feature #11052 ] Patch by Piotr Szotkowski.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50897 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-14 15:14:46 +00:00
hsbt
180293ac89
* ext/pathname/lib/pathname.rb: Remove condition of RUBY_VERSION <= 1.9.
...
[Feature #11082 ]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50490 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-14 06:54:22 +00:00
zzak
857756ac6e
* file.c: NotImplementedError is raised if birthtime is unavailable.
...
Patch by @y-yagi san and [Fixes GH-817] [ci skip] [DOC]
* ext/pathname/pathname.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49336 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-19 17:57:03 +00:00
nobu
28b9f11d5a
protoize no-arguments functions
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47744 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-30 05:25:32 +00:00
nobu
8ae989f6b6
pathname.rb: fix a Pathname#relative_path_from crash on
...
* ext/pathname/lib/pathname.rb (SAME_PATHS):
Pathname#relative_path_from uses String#casecmp to compare strings
on case-insensitive filesystem platforms (e.g., Windows). This can
return nil for strings with different encodings, and the code
previously assumed that it always returned a Fixnum. [Fix GH-713]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47591 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-15 01:29:21 +00:00
ktsj
9f051c80dc
* file.c, ext/pathname/pathname.c: [DOC] correct position of method rdoc.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46718 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-06 12:45:27 +00:00
usa
d0465cc9e0
* ext/pathname/pathname.c (path_birthtime): Windows support.
...
see [Feature #9857 ] [ruby-dev:48339]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46604 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-28 13:58:01 +00:00
akr
b9faaf6a55
* ext/pathname/pathname.c (path_birthtime): New method,
...
Pathname#birthtime.
Proposed by Kazuhiro NISHIYAMA. [ruby-dev:48232] [Feature #9857 ]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46602 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-28 13:46:02 +00:00
akr
edacb3a94a
* ext/pathname/lib/pathname.rb (cleanpath_aggressive): make all
...
separators File::SEPARATOR from File::ALT_SEPARATOR.
Reported by Daniel Rikowski.
Fixed by Nobuyoshi Nakada. [Bug #9618 ]
* ext/pathname/lib/pathname.rb (cleanpath_conservative): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45827 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-05 13:09:58 +00:00
akr
391fc2eeec
* ext/pathname/lib/pathname.rb (Pathname#/): Aliased to Pathname#+.
...
Suggested by Alexey Muranov. [ruby-core:61432] [Feature #9625 ]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45826 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-05 12:49:27 +00:00
kazu
60d4fc9f68
Fix error with empty args.
...
* ext/pathname/lib/pathname.rb (Pathname#join): Fix error with
empty args. Reported by ko1 via IRC.
* test/pathname/test_pathname.rb (TestPathname#test_join): Add the
test for above case.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45499 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-02 02:51:20 +00:00
kazu
6df5f314ac
remove unnecessary unshift
...
* ext/pathname/lib/pathname.rb (Pathname#join): remove unnecessary unshift.
* test/pathname/test_pathname.rb (TestPathname#test_join): add tests.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45407 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-25 14:42:36 +00:00
ktsj
df0991f34b
* ext/pathname/lib/pathname.rb (Pathname#find): add "ignore_error"
...
keyword argument defaulted to true as well as Find#find.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45269 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-04 15:44:53 +00:00
nobu
7566c49068
ruby/ruby.h: RB_BLOCK_CALL_FUNC_ARGLIST
...
* include/ruby/ruby.h (RB_BLOCK_CALL_FUNC_ARGLIST): for declaration
argument list of rb_block_call_func.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43910 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-29 07:59:14 +00:00
ko1
ad0ef29da7
* array.c (rb_ary_splice): use RARRAY_PTR_USE() without WB because
...
there are not new relations.
* enum.c (enum_sort_by): ditto.
* struct.c (setup_struct): use RARRAY_RAWPTR().
* vm_eval.c (yield_under): ditto.
* ext/pathname/pathname.c (path_entries): use RARRAY_AREF().
* ext/pathname/pathname.c (path_s_glob): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42688 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-26 05:47:27 +00:00
ktsj
854520fc1e
* ext/pathname/pathname.c (path_inspect): use PRIsVALUE to preserve
...
the result encoding.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42060 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-19 05:21:38 +00:00
ktsj
edb98f8b91
fix typos. Patch by k_takata.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40825 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-19 03:10:21 +00:00
akr
788b45da3e
* ext/-test-/debug/depend: New file.
...
* ext/-test-/exception/depend: Ditto.
* ext/-test-/printf/depend: Ditto.
* ext/-test-/string/depend: Ditto.
* ext/coverage/depend: Ditto.
* ext/io/console/depend: Ditto.
* ext/io/nonblock/depend: Ditto.
* ext/io/wait/depend: Ditto.
* ext/openssl/depend: Ditto.
* ext/pathname/depend: Ditto.
* ext/psych/depend: Ditto.
* ext/zlib/depend: Ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40287 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-14 10:48:08 +00:00
akr
c3d1fde2b5
* ext/pathname/pathname.c (path_write): New method.
...
(path_binwrite): Ditto.
[ruby-core:49468] [Feature #7378 ]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40107 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-04 11:12:12 +00:00
zzak
7d183dab15
* ext/pathname/pathname.c (path_f_pathname): rdoc for Pathname()
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39634 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-08 04:21:43 +00:00
drbrain
d5ba73e0d9
* ext/pathname/lib/pathname.rb: Hide private methods from RDoc.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38310 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-11 06:25:56 +00:00
nobu
857ec7118f
pathname.c: suppress -Wcomment warning
...
* ext/pathname/pathname.c (path_s_glob): get rid of "/*" within block
comment.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36953 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-09-12 14:16:16 +00:00
zzak
b5c38622b1
* ext/pathname/lib/pathname.rb: Documentation for Pathname.
...
* ext/pathname/pathname.c: ditto.
[Bug #6947 ] [ruby-core:47354]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36950 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-09-12 13:54:08 +00:00