* file.c (rb_file_s_stat): need type check for non string values.
[ruby-dev:37673] fix: #964 * file.c (rb_file_s_size, rb_file_s_atime, rb_file_s_mtime, rb_file_s_ctime, rb_f_test): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21331 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
f3844ccf44
commit
8b7b9e33a5
@ -1,3 +1,11 @@
|
|||||||
|
Mon Jan 5 08:41:13 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* file.c (rb_file_s_stat): need type check for non string values.
|
||||||
|
[ruby-dev:37673] fix: #964
|
||||||
|
|
||||||
|
* file.c (rb_file_s_size, rb_file_s_atime, rb_file_s_mtime,
|
||||||
|
rb_file_s_ctime, rb_f_test): ditto.
|
||||||
|
|
||||||
Mon Jan 5 08:17:56 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
|
Mon Jan 5 08:17:56 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
* range.c (range_step): should not add up errors on loops.
|
* range.c (range_step): should not add up errors on loops.
|
||||||
|
29
file.c
29
file.c
@ -773,7 +773,8 @@ rb_file_s_stat(VALUE klass, VALUE fname)
|
|||||||
rb_secure(4);
|
rb_secure(4);
|
||||||
FilePathValue(fname);
|
FilePathValue(fname);
|
||||||
if (rb_stat(fname, &st) < 0) {
|
if (rb_stat(fname, &st) < 0) {
|
||||||
rb_sys_fail(StringValueCStr(fname));
|
FilePathValue(fname);
|
||||||
|
rb_sys_fail(RSTRING_PTR(fname));
|
||||||
}
|
}
|
||||||
return stat_new(&st);
|
return stat_new(&st);
|
||||||
}
|
}
|
||||||
@ -1590,8 +1591,10 @@ rb_file_s_size(VALUE klass, VALUE fname)
|
|||||||
{
|
{
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
if (rb_stat(fname, &st) < 0)
|
if (rb_stat(fname, &st) < 0) {
|
||||||
rb_sys_fail(StringValueCStr(fname));
|
FilePathValue(fname);
|
||||||
|
rb_sys_fail(RSTRING_PTR(fname));
|
||||||
|
}
|
||||||
return OFFT2NUM(st.st_size);
|
return OFFT2NUM(st.st_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1680,8 +1683,10 @@ rb_file_s_atime(VALUE klass, VALUE fname)
|
|||||||
{
|
{
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
if (rb_stat(fname, &st) < 0)
|
if (rb_stat(fname, &st) < 0) {
|
||||||
rb_sys_fail(StringValueCStr(fname));
|
FilePathValue(fname);
|
||||||
|
rb_sys_fail(RSTRING_PTR(fname));
|
||||||
|
}
|
||||||
return stat_atime(&st);
|
return stat_atime(&st);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1724,8 +1729,10 @@ rb_file_s_mtime(VALUE klass, VALUE fname)
|
|||||||
{
|
{
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
if (rb_stat(fname, &st) < 0)
|
if (rb_stat(fname, &st) < 0) {
|
||||||
|
FilePathValue(fname);
|
||||||
rb_sys_fail(RSTRING_PTR(fname));
|
rb_sys_fail(RSTRING_PTR(fname));
|
||||||
|
}
|
||||||
return stat_mtime(&st);
|
return stat_mtime(&st);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1769,8 +1776,10 @@ rb_file_s_ctime(VALUE klass, VALUE fname)
|
|||||||
{
|
{
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
if (rb_stat(fname, &st) < 0)
|
if (rb_stat(fname, &st) < 0) {
|
||||||
|
FilePathValue(fname);
|
||||||
rb_sys_fail(RSTRING_PTR(fname));
|
rb_sys_fail(RSTRING_PTR(fname));
|
||||||
|
}
|
||||||
return stat_ctime(&st);
|
return stat_ctime(&st);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3660,10 +3669,12 @@ rb_f_test(int argc, VALUE *argv)
|
|||||||
|
|
||||||
if (strchr("MAC", cmd)) {
|
if (strchr("MAC", cmd)) {
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
VALUE fname = argv[1];
|
||||||
|
|
||||||
CHECK(1);
|
CHECK(1);
|
||||||
if (rb_stat(argv[1], &st) == -1) {
|
if (rb_stat(fname, &st) == -1) {
|
||||||
rb_sys_fail(RSTRING_PTR(argv[1]));
|
FilePathValue(fname);
|
||||||
|
rb_sys_fail(RSTRING_PTR(fname));
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user