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

471 Коммитов

Автор SHA1 Сообщение Дата
nobu 20685cdc85 Get rid of shadowing local variables
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60204 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-18 04:35:25 +00:00
normal 1e14126b4f Dir.empty? releases GVL
This converts all slow syscalls in the Dir.empty? implementation
to release GVL.  We avoid unnecessarily GVL release and
reacquire for each slow call (opendir, readdir, closedir) and
instead only release and acquire the GVL once in the common
case.

Benchmark results show a small degradation in single-threaded
performance:
Execution time (sec)
name	trunk	built
dir_empty_p	0.689	0.758

Speedup ratio: compare with the result of `trunk' (greater is better)
name	built
dir_empty_p	0.909

* dir.c (rb_gc_for_fd_with_gvl): new function
  (nogvl_dir_empty_p): ditto
  (dir_s_empty_p): use new functions to release GVL
* benchmark/bm_dir_empty_p.rb: new benchmark
  [ruby-core:83071] [Feature #13958]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60111 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-04 00:04:51 +00:00
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
nobu 911cf9e83c dir.c: set errno
* dir.c (replace_real_basename): Win32 API does not set errno, get
  the last error by GetLastError() and map to errno.  [Bug #10015]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51111 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-02 22:13:17 +00:00
nobu d7dc0c5f03 dir.c: show warnings
* dir.c (replace_real_basename): show warnings at errors.
  [Bug #10015]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51109 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-02 12:32:09 +00:00
nobu 5a2b77ff4a dir.c: update path type
* dir.c (replace_real_basename): update path type by the target
  attributes if possible, to improve the performance.  [Bug #10015]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51106 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-02 07:15:09 +00:00
nobu 347da440cf ensure paths NUL-terminated
* dir.c (check_dirname): ensure path name NUL-terminated for
  SHARABLE_MIDDLE_SUBSTRING.
* io.c (rb_sysopen): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51073 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-30 14:11:56 +00:00
normal 3fe2773c73 dir.c (check_dirname): avoid volatile, use return value
volatile is unnecessary since we use rb_sys_fail_path nowadays
and that prevents the path argument from being GC-ed.
Using a return value instead of modifying the argument directly
simplifies the generated code (on 32-bit x86):

 text    data     bss     dec     hex filename
20744      40      20   20804    5144 dir.o-orig
20720      40      20   20780    512c dir.o

* dir.c (check_dirname): avoid volatile, use return value
  (dir_s_chroot, dir_s_mkdir, dir_s_rmdir): adjust callers

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51000 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-23 00:49:26 +00:00
hsbt 5d6ca9e950 * include/ruby/ruby.h: $SAFE=2 is now obsolete.
* dir.c, ext/fiddle/handle.c, ext/socket/basicsocket.c, file.c
  gc.c, io.c, process.c, safe.c, signal.c, win32/file.c:
  removed code for $SAFE=2
* test/erb/test_erb.rb, test/fiddle/test_handle.rb
  test/ruby/test_env.rb: removed tests for $SAFE=2.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50958 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-18 14:21:03 +00:00
nobu 9375ff5b06 dir.c: FNM_SHORTNAME
* dir.c (dirent_match): match short names only when FNM_SHORTNAME
  flag is given, for the backward compatibility, and the new
  behavior is often dangerous.  [ruby-core:69435] [Bug #11206]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50760 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-03 22:12:24 +00:00
nobu 9e459f7aa9 dir.c: getattrlist on OSX 10.5
* dir.c (need_normalization): 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@50218 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-10 14:57:47 +00:00
nobu ec85609f23 dir.c: expand ruby_brace_glob0
* dir.c (ruby_brace_glob_with_enc): call ruby_brace_glob_with_enc
  in ruby_brace_glob, and expanded ruby_brace_glob0 which is no
  longer used anywhere else.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50144 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-01 02:42:19 +00:00
nobu 93f6b2a36e dir.c: reduce indirect arguments
* dir.c (push_glob): remove indirect links of arguments for
  trampoline.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50143 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-01 02:09:18 +00:00
nobu 78a73a538d dir.c: don't raise after close
* dir.c (dir_close): don't raise on dobule close for consistent to
  IO#close.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50064 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-23 14:18:30 +00:00
nobu f5b96e594c win32.c: w32_lstati64
* win32/win32.c (winnt_stat): stat with following symbolic links.
* win32/win32.c (winnt_lstat): rename old winnt_stat, which does
  not follow symbolic links.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50060 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-23 05:40:48 +00:00
nobu 41872a8df6 dir.c: fix DT_UNKNOWN recursion
* dir.c (glob_helper): distinguish not-yet-stated and DT_UNKNOWN
  by readdir, and traverse recursively for the former.  Linux
  readdir returns DT_UNKNOWN on some filesystems, e.g., smbfs,
  iso9660.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49983 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-17 08:23:14 +00:00
nobu 8e1f6b0750 dir.c: DT_UNKNOWN
* dir.c (glob_helper): deal with DT_UNKNOWN.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49982 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-16 10:20:25 +00:00
nobu 00f7db376c dir.h: direct::d_type
* dir.c (glob_helper): use d_type to reduce lstat system calls.
* win32/dir.h (struct direct): add d_type instead of d_isdir and
  d_isrep.  SYMLINKD is unreliable, since the target can be
  replaced after a link was created.
* win32/win32.c (readdir_internal): set d_type.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49966 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-14 03:23:56 +00:00
nobu 5b06e83345 dir.c: glob short names
* dir.c (glob_helper): match patterns against legacy short names
  too, not only ordinary names.  [ruby-core:67954] [Bug #10819]
* win32/dir.h (struct direct): add short name members.
* win32/win32.c (opendir_internal, readdir_internal): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49892 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-08 07:57:38 +00:00
usa 908c25341e * dir.c (replace_real_basename): need to check the return value of
GLOB_REALLOC().
  [ruby-core:68430] [Bug #10941]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49861 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-05 17:51:02 +00:00
usa c529554548 * dir.c (replace_real_basename): shouldn't create Ruby object before
the object system is loaded.
  [ruby-core:68430] [Bug #10941]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49859 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-05 17:28:07 +00:00
nobu f4726dcdaa dir.c: same encoding to the pattern
* dir.c (push_pattern, push_glob): make globbed file names same
  encoding to the given pattern.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49744 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-25 06:59:39 +00:00
nobu 7294d08d48 dir.c: use packed structs
* dir.c (is_case_sensitive, replace_real_basename): [OSX] use
  packed structs instead of arrays to suppress warning by older
  versions of gcc.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49712 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-24 03:34:10 +00:00
nobu 16294913f7 use rb_funcallv
* use rb_funcallv() for no arguments call instead of variadic
  rb_funcall().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49612 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-16 04:08:52 +00:00
nobu 034e38d8a2 dir.c: long path name on Windows
* dir.c (has_magic): always get long path name on Windows even if
  no tilde is there.  [ruby-core:68011] [Bug #10819]
* dir.c (replace_real_basename): FindFirstFile ignore redirection
  character, check if exists before call it.  cf. [Bug #8597]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49537 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-07 10:25:27 +00:00
nobu 7645c974de dir.c: fix a typo
* dir.c (has_magic): fix a typo, check code not c.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49536 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-07 05:08:37 +00:00
nobu b53f9528f3 dir.c: use USE_NAME_ON_FS
* dir.c (glob_helper): use USE_NAME_ON_FS instead of configure and
  platform macro list.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49533 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-07 00:11:02 +00:00
nobu 461c38a973 dir.c: fix escaping multibyte char
* dir.c (has_magic): fix escaping multibyte char, with glob
  meta-char in trailing bytes, e.g., Shift-JIS

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49532 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-07 00:11:00 +00:00
nobu ef5b8fe12f dir.c: preserve encoding
* dir.c (sys_enc_warning_in): preserve encoding of path name in
  warning messages.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49528 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-06 08:37:27 +00:00
nobu 338bd4cc65 remove duplication in warning
* dir.c (sys_warning_1): remove duplication in the message.
* error.c (rb_mod_sys_fail_str): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49479 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-03 06:15:51 +00:00
nobu 45df1c24d2 dir.c: glob legacy short name
* dir.c (glob_helper): obtain real name with FindFirstFile API
  instead of matchin all entries, on Windows.
  [ruby-core:67954] [Bug #10819]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49478 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-03 05:04:49 +00:00
nobu 3e2942423e dir.c: GC guard
* dir.c (do_opendir): prevent intermediate string for transcoding
  from GC.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49477 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-03 04:43:52 +00:00
nobu d6aa766ad5 dir.c: OSX case-folding
* dir.c (glob_helper): match in case-folding only if the directory
  resides on a case-insensitve file system, on OSX.
  [ruby-core:67364] [Bug #10700]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49178 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-08 03:53:45 +00:00
nobu 48ad25568f dir.c: use macros
* dir.c (replace_real_basename): use macros for getattrlist
  buffer.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49171 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-07 10:29:49 +00:00
nobu 10e74f035f dir.c: cifs symlinkd on OSX
* dir.c (dir_initialize): workaround of opendir failure at symlink
  directories on Windows via CIFS.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49170 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-07 10:19:29 +00:00
nobu 79219d9656 dir.c: GC guard
* dir.c (dir_initialize): add GC guard for retrying.  the argument
  of RSTRING_PTR() may be eliminated by optimization.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49169 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-07 10:18:45 +00:00
nobu 376c4e8100 dir.c: normalize CIFS too
* dir.c (need_normalization): not only HFS+, CIFS (SMB) is also
  decomposed.  [Bug #10704]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49168 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-07 09:52:53 +00:00
nobu b04c628792 Revert "dir.c: NORMALIZE_UTF8PATH"
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49167 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-07 09:52:03 +00:00
nobu a921841b48 dir.c: NORMALIZE_UTF8PATH
* dir.c (NORMALIZE_UTF8PATH): Unicode decomposition seems to
  perform in an upper layer than file systems on OSX, as all path
  names are always decomposed regardless of file system types.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49166 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-07 07:51:18 +00:00
nobu 859f3d14ed never-NULL pointer check
* dir.c (ruby_glob0): no need to check never-NULL pointer.
  reported by Denis Denisov <denji0k AT gmail.com>.
* win32/file.c (rb_file_expand_path_internal): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49024 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-26 05:51:36 +00:00
nobu 0ebfc6f216 dir.c: replace_real_basename
* dir.c (replace_real_basename): get the real name and replace the
  base name with it by getattrlist(2) if available.
  suggested by Matthew Draper at [ruby-core:67116].  [Bug #10015]
* dir.c (glob_helper): get the real name of the whole path, not
  only the last name.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48990 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-25 06:36:18 +00:00
nobu fbbf715d27 revert r48975
caused CI fauilures

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48976 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-24 14:59:20 +00:00
nobu ae6fb2c8f7 dir.c: shortcut for case-insensitive name
* dir.c (glob_helper): shortcut for case-insensitive name by
  stopping reading after a matching name found.
  [ruby-core:63591] [Bug #10015]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48975 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-24 14:39:49 +00:00
nobu 8b764b1daf dir.c: glob performance
* dir.c (glob_make_pattern): restrict searching case-insensitive
  name from the filesystem to only last part, for the performance.
  [ruby-core:63591] [ruby-core:63591]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48972 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-24 11:38:21 +00:00
nobu e580a631be use 0 for reserved
use 0 for rb_data_type_t::reserved instead of NULL, since its type
may be changed in the future and possibly not a pointer type.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48662 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-01 06:38:04 +00:00
akr 7cd76ab0c5 * internal.h: Include ruby.h and ruby/encoding.h to be
includable without prior inclusion.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-15 11:49:06 +00:00
nobu abafe3354f dir.c: fix rdoc [ci skip]
* dir.c (dir_s_aref): fix rdoc.  `Dir.glob` allows an array but
  `Dir[]` not.  the former accepts an optional parameter `flags`,
  while the latter accepts arbitrary number of arguments but no
  `flags`.  [ruby-core:65265] [Bug #10294]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47850 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-08 15:53:11 +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
akr d03315d84a * configure.in (dirfd): Check function.
* dir.c (dir_fileno): New method.
  [ruby-dev:48265] [Feature #9880]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47387 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-04 15:54:04 +00:00
ko1 68f55c4b35 * dir.c (glob_helper): use #ifdef instead of #if.
gcc's -Wundef option shows warning for undefined macro.
* numeric.c (flo_is_finite_p): ditto.
* vm_dump.c (rb_vmdebug_thread_dump_state): ditto.
* vm_core.h: define VM_DEBUG_VERIFY_METHOD_CACHE to 0.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47382 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-04 08:50:31 +00:00
nobu 4ce3e118e7 dir.c: Dir.exists? is deprecated
* dir.c (rb_dir_exists_p): [DOC] Document that Dir.exists? is
  deprecated.  [ruby-core:64135] [Bug #10102]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47134 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-11 07:17:22 +00:00