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

32 Коммитов

Автор SHA1 Сообщение Дата
nobu ea9ff28f80 win32: realloc failures
* win32/file.c (code_page_i): handle realloc failure.
  reported by Denis Denisov <denji0k AT gmail.com>.
* win32/stub.c (stub_sysinit): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49023 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-26 05:48:12 +00:00
nobu fa13cb050d win32: suppress warnings
* win32/file.c (home_dir, code_page_i): parenthesize to suppress
  warnings.

* win32/win32.c (is_command_com, join_argv, w32_cmdvector, kill),
  (constat_attr_color_reverse, constat_attr): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48971 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-24 10:18:35 +00:00
nobu edae1c7200 win32/file.c: fix no user exception
* win32/file.c (append_wstr): set expanded length, not length of
  appended string.  fix "probable buffer overflow" bug.
  [ruby-core:65317] [Bug #10304]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47738 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-29 13:54:50 +00:00
nobu 8f0543a364 win32/file.c: direct conversion
* win32/file.c (user_length_in_path): count user name length in
  path.

* win32/file.c (append_wstr): append WCHAR string to Ruby string
  directly without an intermediate buffer, if possible.

* win32/file.c (rb_file_expand_path_internal): use above functions.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47118 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-09 11:50:13 +00:00
nobu b136c5cd48 win32/file.c: share functions with win32.c
* win32/file.c (rb_file_expand_path_internal, rb_file_load_ok):
  use functions defined in win32/win32.c.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-09 10:10:11 +00:00
nobu cb4b55d3d8 win32/file.c: code page table
* win32/file.c (code_page): use simple array instead of st_table.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43363 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-19 10:59:06 +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 36862468a8 file.c: fix memory leak
* win32/file.c (rb_file_expand_path_internal): fix memory leaks at
  a non-absolute home exception.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43328 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-17 05:21:38 +00:00
nobu 6531e12e0b win32/file.c: make mapping at initialization
* win32/file.c (code_page_i, rb_w32_init_file): make encoding to code
  page mapping at initialization directly.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43169 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-07 07:20:59 +00:00
nobu 98e4a412e4 win32/file.c: use encoding index
* win32/file.c (code_page): use encoding index, which is primary
  entity, instead of encoding name.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43168 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-07 06:50:18 +00:00
nobu 6d07beb4c1 win32/file.c: using st_table
* win32/file.c (code_page): cache using st_table, not RHash.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43166 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-07 06:28:11 +00:00
nobu 1c7b42e2bc win32/file.c: check ASCII encodings first
* win32/file.c (code_page): check US-ASCII and ASCII-8bit before
  ordinary mapping.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43165 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-07 06:09:01 +00:00
nobu 48443714b7 win32/file.c: suppress warning
* win32/file.c (convert_mb_to_wchar): omit never-true NULL check to
  suppress maybe-uninitialized warning in rb_file_load_ok().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42191 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-26 08:50:33 +00:00
nobu c4c78f758f win32/file.c: fix target encoding
* win32/file.c (fix_string_encoding): fix target encoding.  the
  parameter `encoding' is not the target encoding but the original
  encoding.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42190 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-26 08:49:31 +00:00
nobu e9b8488fe5 win32/file.c: adjust indent
* win32/file.c (get_user_from_path): adjust indent.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42189 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-26 06:43:33 +00:00
nobu 8948280c67 load.c: search in OS path encoding
* load.c (rb_load_internal): use rb_load_file_str() to keep path
  encoding.
* load.c (rb_require_safe): search in OS path encoding for Windows.
* ruby.c (rb_load_file_str): load file with keeping path encoding.
* win32/file.c (rb_file_load_ok): use WCHAR type API assuming incoming
  path is encoded in UTF-8.  [ruby-core:56136] [Bug #8676]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42183 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-26 04:04:23 +00:00
nobu 320a0dd218 win32/file.c: refine fix_string_encoding
* win32/file.c (fix_string_encoding): simplify with rb_str_conv_enc().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-26 04:01:07 +00:00
nobu 45fbfd0a81 win32/file.c: refine convert_mb_to_wchar
* win32/file.c (convert_mb_to_wchar): use bare pointer instead of
  VALUE, and remove useless argument.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42179 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-26 04:00:28 +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
usa b7d708c3f1 * win32/file.c (code_page): use cp1252 instead of cp20127 as US-ASCII.
fix [ruby-core:53079] [Bug #7996]
  reported and patched by mmeltner (Michael Meltner).


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40003 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-29 19:00:05 +00:00
luislavena 2caf0bc820 Refactor rb_file_expand_path_internal for dir_string corner cases
* win32/file.c (get_user_from_path):  add internal function that retrieves
  username from supplied path (refactored).
* win32/file.c (rb_file_expand_path_internal):  refactor expansion of user
  home to use get_user_from_path and cover dir_string corner cases.
  [ruby-core:53168] [Bug #8034]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39751 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-14 03:56:09 +00:00
luislavena ee90455a44 Expand home directory when used in dir_string
* win32/file.c (rb_file_expand_path_internal):  Expand home directory when
  used as second parameter (dir_string).  [ruby-core:53168] [Bug #8034]
* test/ruby/test_file_exhaustive.rb: add test to verify.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39697 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-10 14:39:09 +00:00
luislavena 55915036a6 Swap logic around wildcard character detection
* win32/file.c (replace_to_long_name): correct logic around wildcard
  characters detection and ensure wide-chars are used as pattern.
  [ruby-core:49451] [Bug #7374]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37706 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-17 17:53:21 +00:00
luislavena 6285597653 Skip path expansion for all wildcard characters
* win32/file.c (replace_to_long_name): skip expansion for all wildcard
  characters.
  [ruby-core:49451] [Bug #7374]

* test/ruby/test_file_exhaustive.rb: add more assertions to test.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-17 12:46:17 +00:00
luislavena 25058a58a2 skip long name conversion if last character is a wildcard one
* win32/file.c (replace_to_long_name): skip automatic path expansion
  when wildcard character is used.  [ruby-core:49451] [Bug #7374]

* test/ruby/test_file_exhaustive.rb: add a test for above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37692 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-16 22:43:22 +00:00
nobu ad2e34c670 win32/file.c: simplify
* win32/file.c (rb_file_expand_path_internal): simplify a condition.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36908 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-09-05 05:29:44 +00:00
nobu f961b80a78 win32/file.c: prototype and cosmetic changes
* win32/file.c (home_dir, system_code_page): use prototype, adjust
  indent, and fix typo.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36907 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-09-05 05:29:41 +00:00
luislavena 86df08dac6 Improve require/File.expand_path performance on Windows
* configure.in (mingw): add shlwapi to the list of dependency
  libs for Windows.
* win32/Makefile.sub (EXTSOLIBS): ditto.

* internal.h: declare internal functions rb_w32_init_file,
  rb_file_expand_path_internal and rb_file_expand_path_fast.

* file.c (Init_File): invoke Windows initialization rb_w32_init_file

* win32/file.c (rb_file_load_path_internal): new function.
  Windows-specific implementation that replaces file_expand_path.
  [Bug #6836][ruby-core:46996]

* win32/file.c (rb_w32_init_file): new function. Initialize codepage
  cache for faster conversion encodings lookup.

* file.c (file_expand_path): rename to rb_file_expand_path_internal.
  Conditionally exclude from Windows.

* file.c (rb_file_expand_path_fast): new function. delegates to
  rb_file_expand_path_internal without performing a hit to the
  filesystem.

* file.c (file_expand_path_1): use rb_file_expand_path_internal without
  path expansion (used by require).
* file.c (rb_find_file_ext_safe): ditto.
* file.c (rb_find_file_safe): ditto.

* load.c (rb_get_expanded_load_path): use rb_file_expand_path_fast.
* load.c (rb_feature_provided): ditto.

* file.c (rb_file_expand_path): use rb_file_expand_path_internal with
  path expansion.
* file.c (rb_file_absolute_path): ditto.

* test/ruby/test_file_exhaustive.rb: new tests to exercise
  rb_file_expand_path_internal implementation and compliance with
  existing behaviors.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36811 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-24 03:44:56 +00:00
usa ab649ef3c4 * win32/file.c (INVALID_FILE_ATTRIBUTES): commit miss of r35384.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35385 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-18 05:50:45 +00:00
nobu fc493491fe fix indent
* win32/file.c (rb_file_load_ok): fix indent.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34855 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-29 04:07:08 +00:00
shirosaki 4b1e9f0c47 * Makefile.in (PLATFORM_DIR): add a variable for `win32` directory.
* Makefile.in (clean-platform): add new target.
  It cleans `win32` directory.

* common.mk (clean): add a dependency for `win32` directory.
* common.mk (distclean): ditto.
* common.mk (distclean-platform): add new target.
  It cleans `win32` directory.
* common.mk ($(PLATFORM_D)): add new target to make `win32` directory.
* common.mk (win32/win32.$(OBJEXT)): move win32.o into `win32`
  directory.
* common.mk (win32/file.$(OBJEXT)): add new target for win32/file.c.

* configure.in: move win32.o into `win32` directory and add
  win32/file.o to MISSING.

* file.c (file_load_ok, rb_file_load_ok): replace static
  file_load_ok() with public rb_file_load_ok().
  It's to link Windows implementation in win32/file.c.
* file.c (rb_find_file_ext_safe): ditto.
* file.c (rb_find_file_safe): ditto.

* win32/file.c (rb_file_load_ok): new file. Add Windows specific
  optimized implementation of rb_file_load_ok(). We created a
  separated file to avoid too many #ifdef macro which is unreadable.

* win32/Makefile.sub (PLATFORM_DIR): add a variable for `win32`
  directory.
* win32/Makefile.sub (MISSING): move win32.obj into `win32`
  directory and add win32/file.obj to MISSING.
* win32/Makefile.sub (MAKEDIRS): replace MINIRUBY with BASERUBY.
  It's because miniruby doesn't exist when making `win32` directory.
* win32/Makefile.sub (clean-platform): add new target to clean `win32`
  directory.
* win32/Makefile.sub ({$(srcdir)}.c{}.obj): make it not match
  win32/file.c to build properly.
* win32/Makefile.sub (win32/win32.$(OBJEXT)): move win32.obj into
 `win32` directory.

  Patch created with Luis Lavena.
  [ruby-core:42480] [Feature #5999]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34849 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-28 15:51:25 +00:00