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

419 Коммитов

Автор SHA1 Сообщение Дата
nobu ec4af34efb dir.c: fix up r59527
* dir.c (glob_helper): fix up r59527, dot files other than current
  directory should not be included unless FNM_DOTMATCH is given.
  [ruby-core:82266] [Bug #13785]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59529 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-08 10:43:19 +00:00
nobu 50dc093d6b dir.c: fix up r59481 for old kernels
* dir.c (glob_helper): fix up r59481 for old kernels, which
  provide d_type member but just always set DT_UNKNOWN for any
  entries.  [ruby-core:82266] [Bug #13785]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59527 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-08 08:34:10 +00:00
nobu 76857f8ee8 dir.c: reduce syscalls
* dir.c (glob_helper): utilize d_type even if no recursive
  pattern, to reduce stat/lstat syscalls in subsequent
  glob_helper.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59481 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-03 04:13:12 +00:00
nobu 1ef613dd0b dir.c: relative path Dir base
* dir.c (glob_helper): fix globbing based on a relative path Dir.
  [Feature #13056]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59479 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-03 03:39:33 +00:00
nobu 83a31e9e90 dir.c: relax base option
* dir.c (dir_glob_options): relax base option.  ignore when nil
  or an empty string as :base option.  [Feature #13056]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59476 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-03 02:14:51 +00:00
normal 8e2d0deb88 dir.c (ruby_brace_expand): RB_GC_GUARD safety
The lifetime of a String VALUE must match or exceed the lifetime
of its R*_PTR result; otherwise the GC can while reclaim the
VALUE while the R*_PTR result is in use.

* dir.c (ruby_brace_expand): add var parameter for GC guard
  (ruby_brace_glob_with_enc): adjust call
  (file_s_fnmatch): ditto
  (push_glob): remove misplaced GC guard

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59416 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-25 05:55:22 +00:00
nobu ff5e3b98a0 win32.c: rb_dir_getwd_ospath
* win32/win32.c (rb_dir_getwd_ospath): Windows implementation
  moved from dir.c.  get rid of freeing malloced memory by xfree.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59061 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-12 00:18:30 +00:00
nobu aac0b43ed5 file.c: realpath in OS path encoding
* dir.c (rb_dir_getwd_ospath): return cwd path in the OS path
  encoding.

* file.c (rb_realpath_internal): work in the OS path encoding

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59040 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-08 01:58:44 +00:00
ko1 b4621c9aae make Dir object WB protected.
* dir.c (dir_data_type): set RUBY_TYPED_WB_PROTECTED.
  Insert WBs for dir_data::path.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58990 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-01 15:18:51 +00:00
nobu 1dec75c02f dir.c: fix FD leaks
* dir.c (do_opendir): close FD when fdopendir failed, e.g.,
  ENOTDIR.  [Feature#13056]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58912 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-27 01:04:23 +00:00
nobu 5e7ce51911 dir.c: yield without base part
* dir.c (glob_helper): yield globbed part only without the base
  directory path part if the base is given.  [Feature#13056]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58901 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-26 07:04:43 +00:00
stomar 4bc4403b2d dir.c: document base keyword argument of Dir.glob
* dir.c: [DOC] document the new `base` keyword argument of Dir.glob
  [Feature #13056]; also improve docs for Dir.glob and Dir[].

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58885 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-25 08:34:13 +00:00
stomar 135c7a53ec dir.c: docs for Dir.each_child and Dir.children
* dir.c: [DOC] fix examples for Dir.each_child and Dir.children.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58884 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-25 07:50:20 +00:00
nobu 944c455b38 dir.c: Dir.each_child and Dir.children
* dir.c (dir_s_each_child, dir_s_children): Dir.each_child and
  Dir.children which are similar to Dir.foreach and Dir.entries
  respectively, except to exclude "."  and "..".  [Feature #11302]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58879 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-25 02:50:21 +00:00
nobu bf463442ed dir.c: dir_each_entries
* dir.c (dir_each_entries): expand entries without method calls.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58877 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-25 01:46:36 +00:00
nobu de5e3475c0 dir.c: prefer NAMLEN to d_name
* dir.c (glob_helper): prefer NAMLEN, do not assume d_name is NUL
  terminated everywhere.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58873 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-24 14:26:09 +00:00
nobu 6d06aadd8e Dir as base option
* dir.c (glob_helper): support Dir instance as `base` option.
  [Feature#13056]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58860 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-23 14:34:12 +00:00
nobu 52419a6e10 Dir.glob base option
* dir.c (dir_s_aref, dir_s_glob): add new optional keyword
  argument, `base`.  [Feature#13056]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58858 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-23 13:47:36 +00:00
nobu 92690b6235 potential memory leak
* dir.c (rb_dir_getwd): get rid of potential memory leak.

* util.c (ruby_getcwd): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58780 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-18 11:29:42 +00:00
nobu 000482a173 rb_w32_ugetcwd: UTF-8 version getcwd
* dir.c (rb_dir_getwd): convert from UTF-8.

* win32/win32.c (w32_getcwd): codepage aware getcwd using
  GetCurrentDirectoryW.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58745 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-16 10:25:56 +00:00
ktsj 5c8edab967 dir.c: [DOC] Properly refer to keyword argument by its name [Fix GH-1543]
enc is the name of the variable used in the example, not the name of the
keyword argument (encoding).

The documentation used to wrongly suggest that the keyword argument name was
"enc" which could cause people try try to call `Dir.open("thing", enc: "utf-8")`

Author: Olivier Lacan <hi@olivierlacan.com>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58566 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-04 08:58:59 +00:00
nobu 4756365503 dir.c: err at glob failure
* dir.c (glob_helper): raise a SystemCallError exception when
  opendir() failed, except for ENOENT, ENOTDIR, and EACCES.  this
  behavior predates 1.0; the comments in glob.c claimed that
  glob() returned -1 on error but actualy the pointer to a global
  variable, then dir_glob() did check only -1 as the comments, and
  ignored actual errors.  [ruby-core:80226] [Bug #13276]

dir.c: ruby_glob_funcs_t

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-27 14:57:08 +00:00
normal cad4591086 remove branches in dmark and dfree GC callbacks
dmark and dfree callbacks are never called in gc.c for NULL
DATA_PTR values, not even for zombie objects.

* compile.c (ibf_loader_mark): remove branch for pointer validity
* compile.c (ibf_loader_free): ditto
* cont.c (cont_free): ditto
* cont.c (fiber_free): ditto
* dir.c (dir_free): ditto
* ext/stringio/stringio.c (strio_mark): ditto
* proc.c (binding_free): ditto
* thread_sync.c (mutex_free): ditto
* vm.c (thread_free): ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58006 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-17 19:59:56 +00:00
nobu 1c80c388d5 dir.c: getattrlist on OSX 10.5
* dir.c (is_case_sensitive): use getattrlist() if fgetattrlist()
  is unavailable, on OSX 10.5.  [ruby-core:68829] [Bug #11054]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57248 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-01 22:20:38 +00:00
nobu a44c3bb26f dir.c: merge rb_glob2 into rb_glob
* dir.c (rb_glob): merge rb_glob2 which is used only here.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56608 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-05 15:49:29 +00:00
nobu c72fc9f323 dir.c: suppress a warning
* dir.c (to_be_ignored): remove duplicate inline modifier, and
  suppress a warning by VC.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56533 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-31 16:01:30 +00:00
nobu 5d20d347c7 dir.c: retry glob with GC
* dir.c (do_opendir): retry after GC when the limit for open file
  descriptors reached.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56467 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-21 07:44:46 +00:00
nobu 9590e99031 dir.c: use rb_gc_for_fd
* dir.c (rb_dir_s_empty_p): use rb_gc_for_fd for the condition to
  invoke GC by errno.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56466 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-21 07:40:50 +00:00
nobu 1e09d98b23 dir.c: inline to_be_ignored
* dir.c (to_be_ignored): make an inline function to get rid of
  multiple errno function calls.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56465 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-21 07:40:48 +00:00
nobu ccc9841a82 prefer rb_syserr_fail
* dir.c (dir_initialize, dir_read): prefer rb_syserr_fail over
  rb_sys_fail.

* io.c (ruby_dup, rb_sysopen): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56464 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-21 07:40:47 +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 65ca6391ed Name USE_NAME_ON_FS constants
* dir.c (USE_NAME_ON_FS): name constants.
  * USE_NAME_ON_FS_REAL_BASENAME: platform dependent APIs to get
    real basenames.
  * USE_NAME_ON_FS_BY_FNMATCH: select the matching basename by
    fnmatch.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55470 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-06-20 11:00:17 +00:00
normal bee0756ea9 dir.c (dir_close): update RDoc for 2.3 #close change
[ruby-core:75679] [Bug #12413]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55120 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-22 23:09:38 +00:00
nobu 4f969f6eee dir.c: paths as UTF-8
* dir.c (push_pattern, push_glob): deal with read paths as UTF-8
  to stat later, on Windows as well as OS X.
  [ruby-core:73868] [Bug #12081]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53877 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-02-20 04:04:59 +00:00
nobu 135a171ce1 dir.c: Dir.empty?
* dir.c (rb_dir_s_empty_p): add Dir.empty? method, which tells the
  argument is the name of an empty directory.  [Feature #10121]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53841 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-02-16 08:34:47 +00:00
hsbt 6851be0f0c * compile.c: fix typos.
[ci skip][fix GH-1140] Patch by @jutaz
* dir.c: ditto.
* gc.c: ditto.
* io.c: ditto.
* node.h: ditto.
* thread_pthread.c: ditto.
* vm_insnhelper.c: ditto.
* vsnprintf.c: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53103 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-14 02:51:13 +00:00
nobu dec78a7a73 dir.c, io.c: use rb_id_encoding
* dir.c (dir_initialize): rb_id_encoding() returns same ID with
  caching.

* io.c (Init_IO): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53012 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-09 18:15:04 +00:00
ko1 2f5b8f0529 * *.c (*_memsize): do not check ptr.
NULL checking is finished Before call of memsize functions.
  See r52979.




git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52986 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-09 00:38:32 +00:00
normal 61e5fe0674 use rb_gc_for_fd for more callers
* dir.c (dir_initialize): use rb_gc_for_fd for ENOMEM
* ext/socket/init.c (rsock_socket): ditto
* ext/socket/socket.c (rsock_socketpair): ditto
* internal.h (rb_gc_for_fd): prototype
* io.c (rb_gc_for_fd): remove static
  [ruby-core:71623] [Feature #11727]

Manpages for opendir(2), socket(2), and socketpair(3posix)
describe ENOMEM as a possible error for each of these;
handle it consistently with our existing wrappers for
open(2)/pipe(2) etc...

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52726 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-23 22:50:53 +00:00
ngoto 7ceb0f9eb4 * dir.c (dir_fileno, dirfd): support of Dir#fileno on Solaris 10.
Solaris 10 does not have dirfd, but the file descriptor of a
  directory is stored in the d_fd or dd_fd member in the DIR struct.
  Note that Solaris 11 has dirfd(3C).

* configure.in: checks for DIR.d_fd and DIR.dd_fd on Solaris 10.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52472 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-06 17:07:08 +00:00
ko1 56eee285be revert r52336 (commit miss)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52337 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-29 05:30:50 +00:00
ko1 106f033b89 * gc.c (gc_mark_ptr): remove debug code for #11244.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52336 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-29 05:10:06 +00:00
nobu ff3288fe5a dir.c: glob brace expansion [Fix GH-1061]
* dir.c (ruby_brace_expand): glob brace expansion edge case fix.
  When there are closing braces '}' before a open brace '{' it
  must be ignored and considered as literal.
  [ruby-core:71138] [Bug #11609]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52212 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-22 04:16:21 +00:00
nobu 4d753671b2 dir.c: make ASCII-8BIT
* dir.c (rb_dir_getwd): make ASCII-8BIT if filesystem encoding is
  US-ASCII, like as Dir.glob.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52031 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-04 15:53:53 +00:00
nobu c604000a31 dir.c: normalize cwd
* dir.c (rb_dir_getwd): normalize OS path to UTF-8 on OS X.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52012 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-04 01:10:00 +00:00
nobu 563127d710 dir.c: give pathlen from callers
* dir.c (glob_helper): move pathlen to argument which is known in
  the callers almost.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51990 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-30 08:12:14 +00:00
kosaki 06ca0b67f4 * dir.c (glob_helper): check pathtype once again by lstat(2) if
dp->d_type is DT_UNKNOWN. XFS may return DT_UNKNOWN.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51870 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-16 03:19:53 +00:00
nobu 2046f38aa6 dir.c: fundamental_encoding_p
* dir.c (fundamental_encoding_p, push_glob): compare by encoding
  index immediately.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51865 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-15 06:06:19 +00:00
nobu 82da3da5ac win32.c: support known reparse points only
* dir.c (replace_real_basename), win32/win32.c (opendir_internal):
  check reparse point tags and treat supported tags only as
  symbolic links.  [ruby-core:70454] [Bug #11462]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51644 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-19 23:31:19 +00:00
nobu d8f628e582 dir.c: get attributes by fd
* dir.c (is_case_sensitive): get attributes by the file descriptor
  of open directory, instead of using mount point name.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51208 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-10 08:41:57 +00:00