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

776 Коммитов

Автор SHA1 Сообщение Дата
normal 05404cba6e deduplicate "/", ":" and "\n" strings
"/" and ":" are always statically registered in symbol.c (Init_op_tbl),
and "\n" is a commonly seen in source code.

* file.c (Init_File): fstring on File::SEPARATOR and File::PATH_SEPARATOR
* io.c (Init_IO): fstring on rb_default_rs ("\n")

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57995 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-17 00:55:45 +00:00
nobu b75f68ab8d file.c: join with /
* file.c (rb_file_join): join using "/" always, not a constant.
  and fix the document.  [ruby-core:79579] [Bug #13223]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57960 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-13 09:29:19 +00:00
nobu 803621f6d7 file.c: refine message
* file.c (rb_get_path_check_convert): refine the error message
  when the path name contains null byte.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57336 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-16 02:43:55 +00:00
nobu 7eb8d74f34 file.c: cygwin behavior
* file.c: recent cygwin hides NTFS specific features.
  [ruby-core:78497] [Bug #13008]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57009 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-07 02:19:29 +00:00
nobu 1f97dd562c file.c: isADS
* file.c (isADS): add macro to tell if Alternate Data Stream
  separator, to distinguish from drive letter.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56996 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-06 07:21:55 +00:00
nobu 6b88dd2698 file.c: home directory from system
* file.c (rb_default_home_dir): resolve home directory from the
  system database when HOME is not set.  [Feature #12695]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56902 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-26 11:37:01 +00:00
naruse 54a6cd84df * file.c (rb_home_dir_of): convert given username into filesystem
encoding. [ruby-core:76682] [Bug #12652]
  patched by Dāvis Mosāns

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56600 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-05 15:00:37 +00:00
nobu 6c7024f6f4 file.c: include sys/sysmacros.h
* file.c: include sys/sysmacros.h for ArchLinux which deprecated
  use of major() and minor() in sys/types.h.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56549 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-03 06:02:16 +00:00
nobu 91fbf2b24b file.c: use DEVT2NUM
* file.c (rb_stat_dev_major, rb_stat_dev_minor): use DEVT2NUM as
  well as rdev_major and rdev_minor.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56547 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-03 05:46:55 +00:00
nobu 9e75488ac8 internal.h: RB_OBJ_BUILTIN_TYPE
* internal.h (RB_OBJ_BUILTIN_TYPE): special-const safe
  BUILTIN_TYPE.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56510 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-28 06:58:19 +00:00
akr 577de1e93d replace fixnum by integer in documents.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56102 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-08 04:57:49 +00:00
nobu 797f2eda58 file.c: normalize cwd
* file.c (append_fspath): normalize directory name to be appended
  on OS X.  [ruby-core:75957] [Ruby trunk Bug#12483]
  https://github.com/rails/rails/issues/25303#issuecomment-224834804

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55385 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-06-12 00:24:36 +00:00
nobu f0355ae707 file.c: home dir fall back
* file.c (rb_home_dir_of): return the default home path if the
  user name is the current user name, on platforms where struct
  pwd is not supported.  a temporary measure against
  [Bug #12226].

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54947 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-08 09:51:34 +00:00
usa 3e5dc499a8 * win32/win32.c, include/ruby/win32.h (rb_w32_utruncate): implements new
truncate alternative which accepts UTF-8 path.

* file.c (truncate): use above function.
  [Bug #12340]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54889 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-02 14:05:19 +00:00
hsbt 48d22f8360 * file.c, win32/file.c: Removed obsoleted safe level checks.
[fix GH-1327] Patch by @cremno

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54668 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-22 01:43:31 +00:00
nobu 096137e84f file.c: File.empty?
* file.c (Init_File): add alias File.empty? to File.zero?.
  [Feature #9969]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54559 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-13 05:47:49 +00:00
nobu e9bb167bfb file.c: prefer rb_check_arity
* file.c (rb_file_s_expand_path, rb_file_s_absolute_path): use
  rb_check_arity instead of rb_scan_args for a simple optional
  argument.

* file.c (rb_file_s_realpath, rb_file_s_realdirpath): ditto.

* file.c (rb_file_s_basename): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54533 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-10 21:59:02 +00:00
nobu e19df562a8 file.c: apply2files returns Fixnum
* file.c (apply2files): return Fixnum so that callers can just
  return it.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54532 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-10 21:59:01 +00:00
nobu 03bf343a9f file.c: apply to argv
* file.c (apply2files): apply to a VALUE vector instead of a
  temporary array.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54530 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-10 21:54:41 +00:00
nobu 3cd3c9d74c no argument conversions in rb_realpath_internal
* file.c (rb_realpath_internal): no argument conversions since
  this internal function does not need to_path and encoding
  conversions, not to be affected by the default internal
  encoding.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54528 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-10 08:47:44 +00:00
nobu b14ed1bb5d file.c: simplify rb_file_s_split
* file.c (rb_file_s_split): use rb_file_dirname instead of
  rb_file_s_dirname with unused Qnil.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54171 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-18 06:59:10 +00:00
nobu a4e6f7d707 ruby.c: reduce fstat
* file.c (ruby_is_fd_loadable): now return -1 if loadable but
  may block.
* ruby.c (open_load_file): wait to read by the result of
  ruby_is_fd_loadable, without fstat.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54099 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-14 07:03:01 +00:00
headius 4bb6f3fd3b file.c: fix documentation
* file.c: mode is optional, defaults to 0666.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53595 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-01-19 18:42:36 +00:00
nobu f4166e2dd7 prefer rb_syserr_fail
* file.c, io.c, util.c: prefer rb_syserr_fail with saved errno
  over setting errno then call rb_sys_fail, not to be clobbered
  potentially and to reduce thread local errno accesses.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53264 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-23 08:57:48 +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
nobu 46df9c425e file.c: call get_stat only once
* file.c (rb_stat_wr, rb_stat_ww): call get_stat only once and
  reduce checking struct.  patch by Yuki Kurihara in
  [ruby-core:71949].  [Misc #11789]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52970 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-08 15:52:40 +00:00
nobu 13a935b0ba Drop support for BeOS
* beos: Drop support for BeOS now that Haiku is stable.
  [Fix GH-1112]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52731 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-24 00:17:11 +00:00
nobu e99cc601e0 Add missing punctuation to File docs [ci skip]
* file.c: [DOC] add a missing period to File docs, to terminate
  the sentence and separate from the next sentence.  [Fix GH-1111]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52729 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-24 00:04:36 +00:00
nobu e29c109d2a Haiku now best effort support
* configure.in: remove obsolete workarounds for Haiku.
* dln.c, file.c, io.c: remove obsolete Haiku workarounds.
* thread_pthread.c: add stack bounds detection for Haiku.
* signal.c: get stack pointer from signal context on Haiku.
  [ruby-core:67923] [Bug #10811] [Fix GH-1109]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52721 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-23 03:54:42 +00:00
glass 1a98b567af * file.c: Add O_TMPFILE.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-08 06:26:44 +00:00
hsbt 5fdee2f829 * file.c: fix indent style. [fix GH-977]
* test/ruby/test_string.rb: indent. [fix GH-975]
[ci skip] These patches are contributed from @yui-knk

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52242 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-23 07:03:34 +00:00
nobu a3ac9d0bb6 file.c: fix typos
* file.c (rb_file_expand_path_internal): fix typos.
  [ruby-core:71111] [Bug #11601]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52192 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-19 12:10:14 +00:00
usa a01dfd479f * file.c (rb_file_identical_p): not necessary to compare the paths after
comparing the file indexes on Windows.  designate by kosaki.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52188 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-18 16:29:07 +00:00
nobu 3d7a535440 file.c: fix compile error
* file.c (rb_file_s_rename): remove unmatched endif not removed at
  r52161.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52164 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-18 01:30:47 +00:00
kosaki a857b11ded * file.c (rb_file_identical_p): simplify ifdefs
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52163 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-18 01:19:13 +00:00
kosaki 4ad2057f27 * ChangeLog: Good-bye OS/2.
* common.mk: ditto.
* configure.in: ditto.
* dln_find.c: ditto.
* ext/Setup.emx: ditto.
* ext/extmk.rb: ditto.
* ext/socket/extconf.rb: ditto.
* ext/zlib/extconf.rb: ditto.
* file.c: ditto.
* include/ruby/defines.h: ditto.
* io.c: ditto.
* lib/mkmf.rb: ditto.
* missing/os2.c: ditto.
* process.c: ditto.
* ruby.c: ditto.
* NEWS: announce OS/2 is no longer supported.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52161 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-18 01:18:34 +00:00
kosaki 21704f2269 * file.c (ruby_is_fd_loadable): this should be fail if st_mode is
not regular file nor FIFO.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52158 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-18 00:33:44 +00:00
nobu d6379666ca file.c: set errno
* file.c (ruby_is_fd_loadable): set proper errno.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52154 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-17 23:41:14 +00:00
kosaki bc8687acd6 * ruby.c (open_load_file): reset O_NONBLOCK after open.
Even if S_ISREG() is true, the file may be file on FUSE filesystem
  or something. We can't assume O_NONBLOCK is safe.
  Moreover, we should wait if the path is point to FIFO. That's
  FIFO semantics. GVL should be transparent from ruby script.
  Thus, just reopen without O_NONBLOCK for filling the requirements.
  [Bug #11060][Bug #11559]
* ruby.c (loadopen_func): new for the above.
* file.c (ruby_is_fd_loadable): new. for checks loadable file type
  of not.
* file.c (rb_file_load_ok): use ruby_is_fd_loadble()
* internal.h: add ruby_is_fd_loadble()
* common.mk: now, ruby.o depend on thread.h.
* test/ruby/test_require.rb
(TestRequire#test_loading_fifo_threading_success): new test.
  This test successful case that loading from FIFO.
* test/ruby/test_require.rb
(TestRequire#test_loading_fifo_threading_raise): rename from
  test_loading_fifo_threading. You souldn't rescue an exception
  if you test raise or not.
  Moreover, this case should be caught IOError because load(FIFO)
  should be blocked until given any input.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52151 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-17 21:09:10 +00:00
nobu 78baa98e69 string.c: rb_str_cat_conv_enc_opts
* file.c (rb_file_expand_path_internal): concatenate converted
  string to the result instead of making converted string and
  append it.
* string.c (rb_str_cat_conv_enc_opts): from rb_str_conv_enc_opts,
  separate function to concatenate with transcoding.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52147 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-17 04:55:47 +00:00
nobu c72ddc4467 file.c: prefer encoding index as possible
* file.c (rb_str_encode_ospath): prefer encoding index as possible
  until rb_encoding is needed.

* file.c (rb_file_expand_path_internal): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52146 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-17 04:31:43 +00:00
nobu abf832f435 file.c: non-blocking open
* file.c (rb_file_load_ok): open in non-blocking mode withoout
  releasing GVL.  don't care about others than regular files and
  directories.  [ruby-dev:49272] [Bug #11559]
* ruby.c (load_file_internal): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52139 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-16 06:54:38 +00:00
nobu 5f0bb43434 file.c: get rid of intermediate objects
* file.c (rb_str_normalize_ospath): place normalized strings to
  the result string directly, to get rid of intermediate objects
  and copying.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52015 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-04 02:32:08 +00:00
nobu 79255ac86c file.c: same timespec
* file.c (rb_file_s_utime): same timespec for same time object.
  assume time objects are static.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51926 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-24 05:20:32 +00:00
nobu 9289515562 file.c: File.mkfifo
* file.c (rb_file_s_mkfifo): implement File.mkfifo.
  [Feature #11536]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51897 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-18 11:11:14 +00:00
nobu 078b6c9838 encindex.h: ENCINDEX
* encindex.h: separate encoding index constants from internal.h.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51861 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-15 05:49:20 +00:00
hsbt d84597355e * file.c: access()/eaccess() wrapping methods check more than just uid.
[fix GH-1007][ci skip] Patch by @eam

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51834 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-12 07:14:38 +00:00
nobu 9af0cf1cfb internal.h: move rb_readlink declaration
* internal.h (rb_readlink): move the declaration.

* ruby.c (dladdr_path): rb_readlink now requires the result
  encoding.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51769 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-05 14:00:15 +00:00
nobu f9ac2106bf file.c: use filesystem encoding
* file.c (rb_realpath_internal): use filesystem encoding if the
  argument is in ASCII encodings.
* win32/file.c (rb_readlink): needs the result encoding.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51738 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-02 07:58:24 +00:00
nobu 754b3342fe file.c: syserr_fail2_in
* file.c (syserr_fail2_in): pass errno from callers.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51718 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-28 11:48:45 +00:00
nobu 262b10210f win32.c: fchmod
* win32/win32.c (fchmod): implement by using
  SetFileInformationByHandle.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51704 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-27 04:01:37 +00:00
nobu dc05dfd496 file.c: fix messages
* file.c (sys_fail2): show method function names but not
  "sys_fail2".

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51701 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-27 01:03:55 +00:00
nobu 597da7b2d0 win32.c: fake lchown
* win32/win32.c (lchown, rb_w32_ulchown): fake lchown.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51687 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-26 05:21:41 +00:00
nobu 2e5c105ff2 win32.c: symlink
* win32/win32.c (w32_symlink): implement symlink().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51674 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-24 21:34:45 +00:00
nobu 4e58f21f79 Add tests for `File.extname`
* file.c (rb_file_s_extname): [DOC] add an example.
* test/ruby/test_path.rb (test_extname): add tests.  [Fix GH-978]
  * path starts with dot ('.a.rb')
  * path includes dir name ('a/b/d/test.rb')
  * path includes dir name and dir name starts with dot
    ('.a/b/d/test.rb')

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51359 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-24 07:35:38 +00:00
nobu 8a0ab36db1 file.c: skip invalid byte
* file.c (rb_str_normalize_ospath): skip invalid byte sequence not
  to loop infinitely.  this case usually does not happen as the
  input name should come from real file systems.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-07 06:02:21 +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 0b3ef899f2 file.c: open without gvl
* file.c (rb_file_load_ok): try opening file without gvl not to
  lock entire process.  [Bug #11060]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50887 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-14 08:20:43 +00:00
naruse 4ff07119e9 * file.c (rb_stat_ino): get inode from the interval of struct st.
* win32/win32.c (stati64_set_inode): get nFilIndexHigh/Low, and set it
  to the interval of struct st as inode.

* win32/win32.c (stati64_set_inode_handle): call stati64_set_inode.

* win32/win32.c (rb_w32_fstati64): call stati64_set_inode_handle.

* win32/win32.c (stati64_handle): call stati64_set_inode.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50870 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-13 11:46:38 +00:00
usa 2bc2802096 * file.c (File::SHARE_DELETE): new flag to be able to delete opened file
on Windows.

* include/win32/win32.c (O_SHARE_DELETE): new pseudo file mode flag.

* win32/win32.c (rb_w32_{w,}open): support above flag.  [EXPERIMENTAL]

* NEWS: mention about this feature.
  [Feature #11218] [ruby-dev:49022]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50848 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-12 12:14:06 +00:00
nobu cb54008be6 wrapper object before alloc
* error.c (rb_name_err_mesg_new): new wrapper object before
  allocate data area and get rid of potential memory leak.
  GC guards are no longer needed.

* file.c (stat_new_0): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50510 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-16 12:56:29 +00:00
akr 28ca0b0f20 * file.c (rb_f_test): Consider nsec for "=", "<" and ">" for "test"
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50236 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-11 14:34:26 +00:00
nobu 2ffb87995a file.c: move rb_readlink on Windows
* win32/file.c (rb_readlink): move from file.c for better buffer
  allocation and the result encoding.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50063 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-23 12:22:10 +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 471457733e file.c: fix handle leak
* file.c (rb_file_identical_p): fix handle leak, ensure to close
  the handle of the first argument.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49664 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-20 08:27:14 +00:00
nobu c3ad34c7fa ruby.c: replace with real path
* ruby.c (dladdr_path): replace the executable path with symlinked
  real path.  dladdr(3) on Linux returns the argv[0] as dli_fname
  instead of the real path, for a symbol defined in the executable
  file itself.  [Bug #10776]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49394 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-24 12:24:27 +00:00
zzak 4908827022 * file.c: Document other cases of missing birthtime on OS with patch
provided by @sho-h similar to GH-817. [ci skip] [DOC]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49362 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-21 00:44:06 +00:00
zzak 857756ac6e * file.c: NotImplementedError is raised if birthtime is unavailable.
Patch by @y-yagi san and [Fixes GH-817] [ci skip] [DOC]

* ext/pathname/pathname.c: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49336 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-19 17:57:03 +00:00
nobu f0806c4863 file.c: drop ignored chars
* file.c (rb_file_expand_path_internal): drop characters ignored
  by filesystem on Mac OS X.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48991 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-25 07:01:22 +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
nobu 2b92335efd file.c: unnecessary #undef
* file.c (flock): remove unnecessary #undef flock, trace of green
  thread polling.  patched by Rohan Garg.  [Bug #10551]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48629 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-28 03:39:18 +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
yugui 165221441c Enable nacl_io in pepper-ruby.
* configure.in (XCFLAGS): Add include path for NaCl libraries.
  (XLDFLAGS): ditto.
  (NACL_LIB_PATH): new stubstitution

* nacl/nacl-config.rb: support NACL_LIB_PATH

* nacl/package.rb: ditto.

* nacl/pepper_main.c: replace old implementations with nacl_io.

* nacl/GNUmakefile.in: link nacl_io to pepper_ruby

* ruby.c (rb_load_file): remove __attribute__((weak)) because the old
  override hack was replaced with nacl_io.

* file.c (rb_file_load_ok): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48078 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-21 15:23:21 +00:00
yugui 8980a9b47b * file.c: include sys/time.h only if HAVE_SYS_TIME_H
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47888 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-11 16:39:15 +00:00
nobu 0d43e14841 file.c: fix compile error on Linux
* file.c (sys/time.h): include after unistd.h to get rid of
  mismatch on struct stat and some system call functions on Linux.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47886 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-11 15:13:24 +00:00
svn 0d1b2755f5 * remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47885 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-11 13:33:36 +00:00
yugui 916fff3b61 * file.c (HAVE_UTIMENSAT): disabled for NativeClient.
Fixes build error.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47884 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-11 13:33:27 +00:00
yugui 57bc5eaf2f Fixes build failures on Portable Native Client.
Note: Some of the fixes are for newlib in general but not NaCl-specific.

* include/ruby/intern.h (rb_fd_select): declare struct timeval, or the
  struct gets local to the function in C99.

* file.c (#include): add nacl/stat.h for PNaCl.
  (utimes): added a declaration for PNaCl.
  (stat_atimespec): stat::st_atimensec is long long but
  timespec::tv_nsec is long in PNaCl.
  (stat_mtimespec, stat_ctimespec): ditto.
  (rb_group_member): disable getgroups unless HAVE_GETGROUPS.
  (eaccess): unify the fallback to generic defined(USE_GETEUID).

* io.c: include sys/time.h for struct timeval.
  (rb_close_before_exec): nothing we can do if F_GETFD is not
  available.
  (ioctl): pnacl newlib actually doesn't have ioctl.

* process.c (maxgroups): it is used iff
   defined(_SC_NGROUPS_MAX) || defined(NGROUPS_MAX) but not
   defined(HAVE_GETGROUPS) || defined(HAVE_SETGROUPS).
  (obj2gid): fail unless the object is a Fixnum if getgrnam is not
  available.
  (disable_child_handler_fork_child): sigaction is not available in
  PNaCl newlib.

* configure.in (warnflags, strict_warnflags): avoid -ansi for strlcpy.
  (rb_cv_gcc_atomic_builtins): also check
  __atomic_or_etch because it is used in ruby_atomic.h.
  (rb_cv_gcc_sync_builtins): ditto.
  (HAVE_GETGRNAM): added.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47882 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-11 13:33:14 +00:00
yugui 69ac654c90 Merges a patch form naclports.
* configure.in (RUBY_NACL and others): Supports PNaCl.
* dln.c: replace the old hacky dynamic loading over HTTP with nacl_io.
* file.c: tenatively use access(2) instead of eaccess.
  (rb_file_load_ok): weaken with attribute but not by postprocess.
* io.c (socket.h): now NaCl has socket.h
  (flock): disable here instead of nacl/ioctl.h
* nacl/GNUmakefile.in (CC, LD, NM, AR, AS, RANLIB, OBJDUMP, OBJCOPY):
  respect path to them if they are absolute.
  This helps naclports to build ruby in their source tree.
  (PROGRAM_NMF, .SUFFIXES): support .pnexe for PNaCl.
  (ruby.o, file.o): move the hack to attributes in ruby.c and file.c
* nacl/ioctl.h: removed. move the hack to io.c.
* nacl/nacl-config.rb: support arm, pnacl and others.
* nacl/pepper_main.c: support build in a naclports tree.
* ruby.c (rb_load_file): weaken with attribute but not by postprocess.

The patch is by sbc@google.com and the Native Client Authors.
It is available at:
* 873ca4910a/ports/ruby/nacl.patch

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47872 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-11 02:11:53 +00:00
normal dfa336cd7d file.c: clear tmp buffer on failures
Reduces GC malloc pressure (MAXPATHLEN is 4096 on my system),
rb_find_file_safe hits this path at least twice every time
ruby starts.

* file.c (rb_find_file_ext_safe): clear tmp buffer on failure
  (rb_find_file_safe): ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47664 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-21 03:26:47 +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
zzak 1fd840a063 * file.c: [DOC] Clarify how File.file? handles symbolic links. Also
cleaned up the rdoc style for this method, more to follow.
  Originally reported by Michael Renner [Bug #10067]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46978 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-27 20:23:45 +00:00
ktsj 9f051c80dc * file.c, ext/pathname/pathname.c: [DOC] correct position of method rdoc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46718 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-06 12:45:27 +00:00
hsbt b5a000bf4c * file.c: [DOC] document File.join returns a string.
Contributed by @dapplebeforedawn. [fix GH-646]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-30 02:37:31 +00:00
nobu e99ee55abc constify parameters
* include/ruby/intern.h: constify `argv` parameters.

* include/ruby/ruby.h: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46459 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-18 06:16:39 +00:00
nobu e2890123ac file.c: shrink expanded path
* file.c (expand_path): shrink expanded path which no longer needs
  rooms to append.  [ruby-core:63114] [Bug #9934]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46410 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-12 04:09:41 +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 046831094b constify rb_encoding and OnigEncoding
* include/ruby/encoding.h: constify `rb_encoding` arguments.
* include/ruby/oniguruma.h: constify `OnigEncoding` arguments.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46309 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-01 22:06:11 +00:00
nobu bfa4f32069 file.c: birthtime on Windows
* file.c (stat_birthtime): `ctime` is actually `created time` on Windows.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46049 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-22 14:34:54 +00:00
naruse 6b4f9210b0 * file.c (stat_birthtime): add birthtime support [Feature #9647]
* file.c (rb_stat_birthtime): add File::Stat.birthtime

* file.c (rb_file_s_birthtime): add File.birthtime

* file.c (rb_file_birthtime): add File#birthtime

* configure.in: check struct stat.st_birthtimespec.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46047 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-22 11:49:22 +00:00
naruse 210f863906 revert File::Statfs [Feature #9772]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46042 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-22 10:39:48 +00:00
tadf 08e0c31d14 * file.c (rb_f_test): removed meaningless "case 'a'".
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45836 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-05 19:38:11 +00:00
ngoto 09f51c56d8 * file.c (HAVE_STRUCT_STATVFS_F_BASETYPE): File::Statfs#fstypename
is supported on AIX, HP-UX, and Solaris, by using the value of
  struct statvfs.f_basetype.
* configure.in (HAVE_STRUCT_STATVFS_F_BASETYPE): check struct
  statvfs.f_basetype which is available on AIX, HP-UX, and Solaris.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45790 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-02 15:24:04 +00:00
kazu a0a5836487 add indent
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45775 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-01 13:25:43 +00:00
kazu 2957f88f8f * file.c: Change AND condition to nested condition.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45774 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-01 13:25:40 +00:00
ngoto 793d9c14df * file.c (FSTATFS): check availability of struct statfs and
struct statvfs in addition to fstatfs(2) and fstatvfs(2).
  This fixes error in Solaris. [Bug #9788] [ruby-dev:48145]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45768 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-30 15:38:31 +00:00
kazu 7973883c3a new macros for statfs_t
* file.c (HAVE_STRUCT_STATFS_T_F_FSTYPENAME): Add new macro for
  statfs_t.
* file.c (HAVE_STRUCT_STATFS_T_F_TYPE): ditto.

* file.c (rb_io_statfs): check FSTATFS macro only instead of
  HAVE_FSTATFS and HAVE_FSTATVFS.

* file.c (statfs_type): use new macro.
* file.c (statfs_fstypename): ditto.
* file.c (statfs_inspect): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45740 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-28 19:35:42 +00:00
kazu c521d87f68 fix preprocessor condition
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45739 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-28 19:35:39 +00:00
nobu 1cabc3cab1 file.c: fix typo
* file.c (FSTATFS): fix typo and commit miss.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45736 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-28 14:13:31 +00:00
nobu a76b0ed54d file.c: fix errors on Windows
* file.c (rb_io_statfs, rb_statfs_init, statfs_inspect): fix
  compilation errors on Windows.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45735 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-28 14:10:28 +00:00
naruse 19fac4432f * configure.in (HAVE_STRUCT_STATFS_F_TYPE): check struct statfs.f_type
to support OpenBSD.

* file.c (statfs_type): use above macro to switch.

* file.c (statfs_inspect): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45734 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-28 12:46:23 +00:00
naruse 559d689ca6 * configure.in: check struct statvfs and struct statvfs.f_fstypename.
* configure.in: on NetBSD fstatfs is obsoleted.

* file.c: support NetBSD for File::Statfs.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45733 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-28 09:08:15 +00:00
naruse f83d51d814 * file.c (statfs_inspect): suppress warnings.
assume those values won't be larger than LONG_LONG_MAX.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45704 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-24 08:46:56 +00:00
nobu ca258c86cf file.c: statfs_inspect
* file.c (statfs_inspect): add File::Statfs#inspect method.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45695 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-24 00:35:34 +00:00
naruse 297fe29fa9 * file.c (statfs_fsid): remove statfs.f_fsid because it doesn't return
meaningful value portably. http://togetter.com/li/658517

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45689 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-23 05:25:12 +00:00
nobu c5fef27312 file.c: unpack in binary
* file.c (statfs_fsid): convert with rb_integer_unpack.

* configure.in: fsid_t is no longer used.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45685 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-23 04:31:09 +00:00
nobu 0f69c1845a file.c: fsid_t may not be defined
* configure.in: check if fsid_t is defined.

* file.c (statfs_fsid): fsid_t may not be defined, assume long in
  that case.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45678 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-23 02:32:17 +00:00
usa 86dc863bd8 * win32/win32.c, include/ruby/win32.h (ustatfs): implementation of
statfs(2) clone. [EXPERIMENTAL]

* file.c (rb_io_statfs): use above function.

* configure.in, win32/Makefile.sub (struct statfs): available.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45672 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-22 15:45:00 +00:00
usa 900ede4053 * file.c (rb_io_stafs): use statfs(2) if fstatfs(2) is unavailable.
* configure.in (fstatfs): check it.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45671 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-22 14:57:18 +00:00
nobu c143b9a0ab file.c: suppress a warning
* file.c (statfs_fsid): use union to suppress strict-aliasing
  warning.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45669 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-22 14:01:51 +00:00
usa 026b0b9469 * file.c (rb_io_statfs): need to define even if the system doesn't have
fstatfs(2).

* test/ruby/test_file.rb (TestFile#test_statfs): skip if IO#stafs is not
  implemented.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45668 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-22 13:19:15 +00:00
naruse 3b1862e62f define File::Statfs only if HAVE_STRUCT_STATFS
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45667 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-22 12:57:38 +00:00
naruse e3a57e06de fix typo
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45663 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-22 10:59:38 +00:00
naruse 035a4e7d72 * file.c: newly added a class File::Statfs. (experimental)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45661 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-22 10:35:57 +00:00
hsbt d89b64ddd7 * file.c: [DOC] Add more documentation for File.basename by @avdi [fix GH-550][ci skip]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45200 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-28 00:37:16 +00:00
charliesome e789250325 * file.c (rb_f_test): [DOC] refer to 'character' instead of 'integer'
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44789 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-01 11:08:15 +00:00
marcandre e030b4ee79 * array.c: rdoc clarification for <=>
* file.c: ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44543 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-09 17:33:47 +00:00
nobu 64211a0f98 file.c: to_uid and to_gid
* file.c (to_uid, to_gid): extract from rb_file_s_chown,
  rb_file_chown, and rb_file_s_lchown.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44401 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-25 01:40:53 +00:00
nobu 4db0887d67 file.c: proper types
* file.c (rb_file_chown): use proper configured types, not plain
  int.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44400 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-25 00:47:26 +00:00
nobu 9f368b5ac9 file.c: destination path only
* file.c: remove unnecessary the source path from EEXIST error
  messages and show the destination path only.  [ruby-core:59202]
  [Feature #9263]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44313 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-21 04:00:31 +00:00
nobu 079009fb93 file.c: fix buffer overflow
* file.c (rb_readlink): fix buffer overflow on a long symlink. since
  rb_str_modify_expand() expands from its length but not its capacity,
  need to set the length properly for each expansion.
  [ruby-core:58592] [Bug #9157]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43853 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-26 07:30:37 +00:00
nobu 7ddf295a4b file.c: remove unnecessary declaration
* file.c (GetLastError): already defined in windows.h on nowadays
  cygwin, and caused the confliction with the system provided
  definition on cygwin64.  by @kou1okada [Fixes GH-433].

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43583 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-08 15:26:55 +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
zzak 2bd5ab359d * file.c: [DOC] fix rdoc format of File#expand_path from r43386
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43393 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-23 02:44:06 +00:00
eregon 5b91ab1f2e * file.c (File#expand_path): [DOC] improve documentation of File#expand_path.
Based on patch by Prathamesh Sonpatki. [ruby-core:57734] [Bug #9002]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43386 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-22 07:59:23 +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
nobu 1ca90beaac * file.c (rb_file_exists_p): maybe FileTest.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43379 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-21 15:34:55 +00:00
nobu 058d55ad2c file.c: warn File.exists?
* file.c (rb_file_exists_p): warn deprecated name.  [Bug #9041]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43377 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-21 15:06:59 +00:00
nobu eeb3156eca encoding.c: defer code page table
* encoding.c (rb_locale_encindex): defer initialization of win32 code
  page table until encoding db loaded.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43362 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-19 10:55:39 +00:00
nobu c07c33b28a file.c: export rb_stat_new
* file.c (stat_new_0): constify.
* file.c (rb_stat_new): constify and export.  based on a patch by
  Hanmac (Hans Mackowiak) at [ruby-core:53225].  [Feature #8050]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43107 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-01 11:54:53 +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
ktsj 04f0de74dd * error.c, file.c, gc.c, hash.c, thread.c, variable.c, vm_eval.c, bin/erb:
$SAFE=4 is obsolete.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42608 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-18 10:36:51 +00:00
usa f2e870c9a7 * file.c (rb_file_size, rb_file_flock): improve parformance of Winodws.
* file.c (rb_file_truncate): removed unnecessary #ifdef.

* test/test_file.rb (TestFile#test_truncate_size): added an assertion
  for File#size.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42577 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-16 02:26:28 +00:00
usa d6af2a2b21 * io.c, internal.h (rb_io_flush_raw): new function to select calling
fsync() (on Windows).

* io.c (rb_io_flush_raw): use above function.

* file.c (rb_file_truncate): use above function.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42564 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-15 11:53:41 +00:00
nobu 863989993a file.c: OSX path encoding
* file.c (rb_str_encode_ospath): OS path encoding on Mac OS X is also
  fixed.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42524 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-11 14:27:04 +00:00
nobu 49826b4b72 file.c: internal function
* file.c (rb_str_normalize_ospath0): make the internal function
  static.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42510 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-11 07:31:25 +00:00
charliesome bf2ed96339 * file.c (rb_str_normalize_ospath): fix mixed code and declaration warning
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42507 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-11 04:04:12 +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 c04f402f0f file.c: normalize Form C
* file.c (rb_str_normalize_ospath): normalize to Normalization Form C
  using CFString.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42457 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-09 03:06:53 +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
nobu f375a8b40e file.c: use rb_str_conv_enc
* file.c (rb_str_encode_ospath): simplify using rb_str_conv_enc().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42181 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-26 04:02:01 +00:00
naruse f86be91b56 * file.c (rb_file_expand_path_internal): fix r42160; skip '~'.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42171 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-25 16:33:57 +00:00
nobu 84d473b750 file.c: clear coderange for user name
* file.c (rb_file_expand_path_internal): should clear coderange after
  copying user name as binary data.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42165 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-25 08:17:55 +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
nobu 1758ff0381 file.c: exception message encoding
* file.c (rb_file_expand_path_internal): preserve the file name
  encoding in an exception message.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42150 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-24 08:38:01 +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 6db56c86c9 fill rdocs
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41027 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-02 03:12:04 +00:00
ktsj edb98f8b91 fix typos. Patch by k_takata.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40825 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-19 03:10:21 +00:00
ko1 83aba04862 * include/ruby/ruby.h: constify RBasic::klass and add
RBASIC_CLASS(obj) macro which returns a class of `obj'.
  This change is a part of RGENGC branch [ruby-trunk - Feature #8339].
* object.c: add new function rb_obj_reveal().
  This function reveal interal (hidden) object by rb_obj_hide().
  Note that do not change class before and after hiding.
  Only permitted example is:
  klass = RBASIC_CLASS(obj);
  rb_obj_hide(obj);
  ....
  rb_obj_reveal(obj, klass);
  TODO: API design. rb_obj_reveal() should be replaced with others.
  TODO: modify constified variables using cast may be harmful for
  compiler's analysis and optimizaton.
  Any idea to prohibt inserting RBasic::klass directly?
  If rename RBasic::klass and force to use RBASIC_CLASS(obj),
  then all codes such as `RBASIC(obj)->klass' will be
  compilation error. Is it acceptable? (We have similar
  experience at Ruby 1.9,
  for example "RARRAY(ary)->ptr" to "RARRAY_PTR(ary)".
* internal.h: add some macros.
* RBASIC_CLEAR_CLASS(obj) clear RBasic::klass to make it internal
  object.
* RBASIC_SET_CLASS(obj, cls) set RBasic::klass.
* RBASIC_SET_CLASS_RAW(obj, cls) same as RBASIC_SET_CLASS
  without write barrier (planned).
* RCLASS_SET_SUPER(a, b) set super class of a.
* array.c, class.c, compile.c, encoding.c, enum.c, error.c, eval.c,
  file.c, gc.c, hash.c, io.c, iseq.c, marshal.c, object.c,
  parse.y, proc.c, process.c, random.c, ruby.c, sprintf.c,
  string.c, thread.c, transcode.c, vm.c, vm_eval.c, win32/file.c:
  Use above macros and functions to access RBasic::klass.
* ext/coverage/coverage.c, ext/readline/readline.c,
  ext/socket/ancdata.c, ext/socket/init.c,
* ext/zlib/zlib.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 10:49:11 +00:00
ko1 aacd771046 * *.c, parse.y, insns.def: use RARRAY_AREF/ASET macro
instead of using RARRAY_PTR().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40690 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 09:56:22 +00:00