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

529 Коммитов

Автор SHA1 Сообщение Дата
naruse a6488f04de Revert "Dir.glob with FNM_EXTGLOB is optimized [Feature #13873]"
This reverts commit r60341,r60342,r60344,r60345.
Breaking compabitility of the order of result breaks many tests.
To avoid such effort to fix tests, the order should be kept.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60478 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-27 08:40:40 +00:00
hsbt 0e2d2e6a79 Drop to support NaCl platform.
Because NaCl and PNaCl are already sunset status.
  see https://bugs.chromium.org/p/chromium/issues/detail?id=239656#c160

  configure.ac: Patch for this file was provided by @nobu.

  [Feature #14041][ruby-core:83497][fix GH-1726]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60374 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-23 05:56:25 +00:00
nobu 7fa932ece6 dir.c: adjust indent [ci skip]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60345 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-22 04:06:23 +00:00
naruse 3866715356 Dir.glob with FNM_EXTGLOB is optimized [Feature #13873]
The order of resulted array is changed in some cases.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60341 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-22 02:03:49 +00:00
naruse b39132e993 Revert "ignore server side error"
This reverts commit r60314.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60315 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21 16:44:56 +00:00
naruse facccd3129 ignore server side error
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60314 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21 16:43:54 +00:00
naruse c1db20c3b5 Revert "Dir.glob with FNM_EXTGLOB is optimized [Feature #13873]"
This reverts commit r60253 because it causes on error on Linux.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60255 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21 10:44:13 +00:00
naruse e2a92c54e6 Dir.glob with FNM_EXTGLOB is optimized [Feature #13873]
The order of resulted array is changed in some cases.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60253 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21 10:28:34 +00:00
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
nobu aa3b506270 add some documents [ci skip]
* bignum.c (Init_Bignum): [DOC] Bignum::GMP_VERSION.

* complex.c (Init_Complex): [DOC] ignore an internal class.

* dir.c (Init_Dir): [DOC] File::FNM_SYSCASE.

* file.c (rb_file_exists_p): [DOC] File.exists? is deprecated.

* object.c (rb_mod_initialize_clone): [DOC] ignore implementation
  detail.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46990 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-28 11:28:55 +00:00
nobu f2980e3e20 encoding.h: constify rb_encoding
* include/ruby/encoding.h: constify `rb_encoding` itself, not only
  arguments.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46322 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-02 20:23:47 +00:00
nobu c466dcc05b dir.c: try match PLAIN
* dir.c (glob_helper): try match PLAIN as well as ALPHA, which are
  separated by previous commits.  [ruby-core:61552] [Bug #9648]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45969 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-17 02:02:51 +00:00
nobu f88481740a dir.c: set PLAIN for non-magical
* dir.c (glob_make_pattern): set PLAIN for non-magical path to
  skip parts which not need to glob.
  [ruby-core:61552] [Bug #9648]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45968 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-17 01:40:34 +00:00
nobu 47f4eee420 dir.c: fix conditions for ALPHA
* dir.c (has_magic): return ALPHA at alphabetical name regardless
  FNM_CASEFOLD flag.
* dir.c (glob_helper): fix conditions for ALPHA.
  [ruby-core:61552] [Bug #9648]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45967 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-17 01:05:06 +00:00
nobu 8cb6f21e1a dir.c: reduce matching
* dir.c (glob_helper): reduce matching at non-mgaical path on
  Windows.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45966 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-16 16:49:38 +00:00
nobu 17d31216ea dir.c: match plain names as-is
* dir.c (glob_pattern_type): separate names with alphabet but no
  magical from plain.
* dir.c (glob_helper): match plain names as-is to treat super-root
  same as the root.  [ruby-core:61552] [Bug #9648]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45965 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-16 16:49:25 +00:00
nobu 29b5de1de2 dir.c: check boundary
* dir.c (glob_make_pattern): check boundary before accessing.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45957 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-16 08:22:41 +00:00
nobu 1f30b7437e dir.c: match in UTF-8
* dir.c (push_glob): match in UTF-8 on Mac OS X.
  [ruby-dev:48213] [Bug #9825]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45904 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-10 13:37:58 +00:00
normal 87661039e7 dir.c (dir_s_glob): RB_GC_GUARD instead of volatile
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44997 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-16 05:53:14 +00:00
nobu c512cfdb1f dir.c: fallback to ASCII-8BIT
* dir.c (push_glob): fallback to ASCII-8BIT for the case non-ascii
  path name exists.  failed with LANG=C, on MacOS X which has a
  localized symlink on the root directory.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44834 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-05 06:23:37 +00:00
nobu 8d9b300a72 dir.c: glob cases on case-insensitive system
* dir.c (glob_helper): return the filename with actual cases on
  the filesystem if it is case-insensitive.  [ruby-core:42469]
  [Feature #5994]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44807 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-04 08:20:05 +00:00
nobu 5b92c0bea3 dir.c: glob cases on case-insensitive system
* dir.c (glob_make_pattern): all alphabets are magic characters on
  case-insensitive filesystems.  [ruby-core:42469] [Feature #5994]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44802 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-04 03:45:17 +00:00
naruse 859ae7764c Revert "dir.c: glob cases on case-insensitive system"
This reverts commit r44796.

    * dir.c (glob_helper): return the filename with actual cases on
      the filesystem if it is case-insensitive.  [ruby-core:42469]
      [Feature #5994]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44801 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-04 03:19:57 +00:00
nobu 0f9da4228d dir.c: glob cases on case-insensitive system
* dir.c (glob_helper): return the filename with actual cases on
  the filesystem if it is case-insensitive.  [ruby-core:42469]
  [Feature #5994]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44796 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-03 01:49:50 +00:00
hsbt 6f53ea480a * dir.c: Add example for Dir.pwd in Dir.getwd doc by @jasonrclark [fix GH-504]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44677 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-21 12:10:17 +00:00
nobu b9cafaf524 vm_insnhelper.c: rb_get_kwargs
* vm_insnhelper.c (rb_get_kwargs): get keyword argument values from an
  option hash, not only checking keys.
* dir.c (dir_initialize): use rb_get_kwargs.
* gc.c (gc_start_internal): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44035 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-06 08:10:47 +00:00
nobu bf9c1d9818 dir.c: check unknown keywords
* dir.c (dir_initialize): check unknown keywords.  [ruby-dev:47152]
  [Bug #8060]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43935 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-30 12:22:20 +00:00
glass 5c54eb4045 * dir.c, pack.c, ruby.c, struct.c, vm_eval.c: use RARRAY_CONST_PTR().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43580 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-08 02:37:47 +00:00
ko1 c5e08b764e * add RUBY_TYPED_FREE_IMMEDIATELY to data types which only use
safe functions during garbage collection such as xfree().
  On default, T_DATA objects are freed at same points as fianlizers.
  This approach protects issues such as reported by [ruby-dev:35578].
  However, freeing T_DATA objects immediately helps heap usage.
  Most of T_DATA (in other words, most of dfree functions) are safe.
  However, we turned off RUBY_TYPED_FREE_IMMEDIATELY by default
  for safety.
* cont.c: ditto.
* dir.c: ditto.
* encoding.c: ditto.
* enumerator.c: ditto.
* error.c: ditto.
* file.c: ditto.
* gc.c: ditto.
* io.c: ditto.
* iseq.c: ditto.
* marshal.c: ditto.
* parse.y: ditto.
* proc.c: ditto.
* process.c: ditto.
* random.c: ditto.
* thread.c: ditto.
* time.c: ditto.
* transcode.c: ditto.
* variable.c: ditto.
* vm.c: ditto.
* vm_backtrace.c: ditto.
* vm_trace.c: ditto.
* ext/bigdecimal/bigdecimal.c: ditto.
* ext/objspace/objspace.c: ditto.
* ext/stringio/stringio.c: ditto.
* ext/strscan/strscan.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43466 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-29 11:16:54 +00:00
nobu f57c988e34 dir.c: DOTMATCH to current directory
* dir.c (glob_helper): don't skip current directories if FNM_DOTMATCH
  is given.  [ruby-core:53108] [Bug #8006]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43385 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-22 06:59:54 +00:00
nobu 22a961383a dir.c: warn Dir.exists?
* dir.c (rb_dir_exists_p): warn deprecated name.  [Bug #9041]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43380 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-21 17:06:31 +00:00
drbrain 2614d9ba2f * dir.c (dir_s_glob): [DOC] Improve wording and layout.
* dir.c (file_s_fnmatch):  ditto.

* dir.c (Init_Dir):  [DOC] Document File::Constants::FNM_XXX
  constants.  (These won't show up in RDoc until a new RDoc is
  imported.)



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42940 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-13 21:08:36 +00:00
nobu 378161fe68 dir.c: reduce string object
* dir.c (dir_each): get rid of allocate new string from UTF-8 string.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42737 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-31 04:30:25 +00:00
nobu 51705124e8 dir.c: normalization
* dir.c (glob_helper): re-enalbe normalization.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42501 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-10 23:55:05 +00:00
naruse 9962aad7b0 * file.c (rb_str_normalize_ospath):
HFS Plus (Mac OS Extended) uses a variant of Normal Form D in which
  U+2000 through U+2FFF, U+F900 through U+FAFF, and U+2F800 through
  U+2FAFF are not decomposed (this avoids problems with round trip
  conversions from old Mac text encodings).
  http://developer.apple.com/library/mac/qa/qa1173/_index.html
  Therefore fix r42457 to exclude the range.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42498 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-10 20:44:10 +00:00
nobu 354028abe1 file.c: rb_str_normalize_ospath
* file.c (rb_str_normalize_ospath): extract and move from dir.c.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42430 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-08 01:26:27 +00:00
naruse 276457dfac fix typo
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42161 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-25 04:16:08 +00:00
nobu 7ec4a44762 file.c: split rb_home_dir
* dir.c (dir_s_home): use rb_home_dir_of and rb_default_home_dir.
* file.c (rb_home_dir_of): split from rb_home_dir() for the home
  directry of the given user, and the user name is a VALUE, not a bare
  pointer.  should raise if the user does not exist.
* file.c (rb_default_home_dir): split from rb_home_dir() for the home
  directry of the current user.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42160 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-25 04:06:50 +00:00
ktsj 8dd4a3c604 * dir.c: [DOC] add docs for :encoding option.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42058 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-19 04:40:07 +00:00
nobu 48b19a3a75 dir.c: get rid of FindFirstFile bug
* dir.c (do_stat): use rb_w32_ustati64() in win32.c to get rid of
  mysterious behavior of FindFirstFile() Windows API which treat "<"
  and ">" like as wildcard characters.  [ruby-core:55764] [Bug #8597]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41755 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-03 05:15:28 +00:00
nobu 89e38a2b7c dir.c: do_lstat alias
* dir.c (do_lstat): make an alias of do_stat instead of two same
  functions, when no lstat is available.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41754 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-03 05:12:03 +00:00
nobu 14dfdb5eaf dir.c: use built-in encoding indexes
* internal.h: add UTF8-MAC.
* dir.c (rb_utf8mac_encoding): use built-in encoding indexes in
  internal.h.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41744 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-02 08:22:43 +00:00
shugo 1f828497d1 * safe.c (rb_set_safe_level, safe_setter): raise an ArgumentError
when $SAFE is set to 4.  $SAFE=4 is now obsolete.
  [ruby-core:55222] [Feature #8468]

* object.c (rb_obj_untrusted, rb_obj_untrust, rb_obj_trust):
  Kernel#untrusted?, untrust, and trust are now deprecated.
  Their behavior is same as tainted?, taint, and untaint,
  respectively.

* include/ruby/ruby.h (OBJ_UNTRUSTED, OBJ_UNTRUST): OBJ_UNTRUSTED()
  and OBJ_UNTRUST() are aliases of OBJ_TAINTED() and OBJ_TAINT(),
  respectively.

* array.c, class.c, debug.c, dir.c, encoding.c, error.c, eval.c,
  ext/curses/curses.c, ext/dbm/dbm.c, ext/dl/cfunc.c,
  ext/dl/cptr.c, ext/dl/dl.c, ext/etc/etc.c, ext/fiddle/fiddle.c,
  ext/fiddle/pointer.c, ext/gdbm/gdbm.c, ext/readline/readline.c,
  ext/sdbm/init.c, ext/socket/ancdata.c, ext/socket/basicsocket.c,
  ext/socket/socket.c, ext/socket/udpsocket.c,
  ext/stringio/stringio.c, ext/syslog/syslog.c, ext/tk/tcltklib.c,
  ext/win32ole/win32ole.c, file.c, gc.c, hash.c, io.c, iseq.c,
  load.c, marshal.c, object.c, proc.c, process.c, random.c, re.c,
  safe.c, string.c, thread.c, transcode.c, variable.c,
  vm_insnhelper.c, vm_method.c, vm_trace.c: remove code for
  $SAFE=4.

* test/dl/test_dl2.rb, test/erb/test_erb.rb,
  test/readline/test_readline.rb,
  test/readline/test_readline_history.rb, test/ruby/test_alias.rb,
  test/ruby/test_array.rb, test/ruby/test_dir.rb,
  test/ruby/test_encoding.rb, test/ruby/test_env.rb,
  test/ruby/test_eval.rb, test/ruby/test_exception.rb,
  test/ruby/test_file_exhaustive.rb, test/ruby/test_hash.rb,
  test/ruby/test_io.rb, test/ruby/test_method.rb,
  test/ruby/test_module.rb, test/ruby/test_object.rb,
  test/ruby/test_pack.rb, test/ruby/test_rand.rb,
  test/ruby/test_regexp.rb, test/ruby/test_settracefunc.rb,
  test/ruby/test_struct.rb, test/ruby/test_thread.rb,
  test/ruby/test_time.rb: remove tests for $SAFE=4.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41259 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-12 14:20:51 +00:00
nobu 482f0e6b97 dir.c: use fd to fstatfs
* dir.c (is_hfs): use the file descriptor instead of a path.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41046 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-03 10:02:39 +00:00
kosaki 523bd6737e * configure.in: removes AC_CHECK_FUNCS(readdir_r). readdir_r()
is only used from dir.c and it doesn't need readdir_r().
* configure.in (SIZEOF_STRUCT_DIRENT_TOO_SMALL): remvoed. It is
  only used for readdir_r.
* dir.c: removes NAME_MAX_FOR_STRUCT_DIRENT. It is not right way
  to detect maximum length of path len. POSIX require to use
  fpathconf(). IOW, it might have lead to make a vulnerability
  using stack smashing. Moreover, readdir() works enough for our
  usage.
* dir.c (READDIR): removes an implementation which uses
  readdir_r() and parenthesize in a macro body correctly.
* dir.c (dir_read): removes IF_HAVE_READDIR_R(DEFINE_STRUCT_DIRENT
  entry), it is used only for readdir_r().
* dir.c (dir_each): ditto.
* dir.c (glob_helper): ditto.

* dir.c (READDIR): removes entry and dp argument.
* dir.c (dir_read): adjust for the above change.
* dir.c (dir_each): ditto.
* dir.c (glob_helper): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41042 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-02 22:38:11 +00:00
mame a0b3e03202 * dir.c (bracket): fix copy-paste error. When the first and last
characters of fnmatch range have different length, fnmatch may
  have wrongly matched a path that does not really match.
  Coverity Scan found this bug.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40925 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-25 09:32:47 +00:00
nobu 1891b60f26 dir.c: compose HFS file names
* dir.c (dir_each): compose HFS file names from
  UTF8-MAC. [ruby-core:48745] [Bug #7267]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40868 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-20 18:11:23 +00:00
akr 847fe27e31 * dir.c (dir_set_pos): Fix a compilation error when seekdir() is not
exist.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40478 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-26 09:16:14 +00:00
nobu a4188556d3 dir.c: not skip dot directories if matching
* dir.c (glob_helper): should skip dot directories only for recursion,
  but should not if matching to the given pattern.  [ruby-core:54387]
  [Bug #8283]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40345 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-18 07:20:53 +00:00
eregon 37a350dbb6 * dir.c (File.fnmatch): fix typo in documentation
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40301 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-14 22:38:26 +00:00
zzak 9ef4e13459 * array.c: Document synonymous methods, by windwiny [GH-277]
* bignum.c: ditto
* complex.c: ditto
* dir.c: ditto
* encoding.c: ditto
* enumerator.c: ditto
* numeric.c: ditto
* proc.c: ditto
* re.c: ditto
* string.c: ditto


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40259 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-12 02:59:07 +00:00