mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
cd06ce2e5a
commit
28ca0b0f20
2 changed files with 14 additions and 3 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Sat Apr 11 23:33:22 2015 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* file.c (rb_f_test): Consider nsec for "=", "<" and ">" for "test"
|
||||||
|
method.
|
||||||
|
|
||||||
Sat Apr 11 23:26:05 2015 SHIBATA Hiroshi <shibata.hiroshi@gmail.com>
|
Sat Apr 11 23:26:05 2015 SHIBATA Hiroshi <shibata.hiroshi@gmail.com>
|
||||||
|
|
||||||
* tool/rbinstall.rb: support destdir for native extention gem.
|
* tool/rbinstall.rb: support destdir for native extention gem.
|
||||||
|
|
12
file.c
12
file.c
|
@ -4829,22 +4829,28 @@ rb_f_test(int argc, VALUE *argv)
|
||||||
|
|
||||||
if (strchr("=<>", cmd)) {
|
if (strchr("=<>", cmd)) {
|
||||||
struct stat st1, st2;
|
struct stat st1, st2;
|
||||||
|
struct timespec t1, t2;
|
||||||
|
|
||||||
CHECK(2);
|
CHECK(2);
|
||||||
if (rb_stat(argv[1], &st1) < 0) return Qfalse;
|
if (rb_stat(argv[1], &st1) < 0) return Qfalse;
|
||||||
if (rb_stat(argv[2], &st2) < 0) return Qfalse;
|
if (rb_stat(argv[2], &st2) < 0) return Qfalse;
|
||||||
|
|
||||||
|
t1 = stat_mtimespec(&st1);
|
||||||
|
t2 = stat_mtimespec(&st2);
|
||||||
|
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case '=':
|
case '=':
|
||||||
if (st1.st_mtime == st2.st_mtime) return Qtrue;
|
if (t1.tv_sec == t2.tv_sec && t1.tv_nsec == t2.tv_nsec) return Qtrue;
|
||||||
return Qfalse;
|
return Qfalse;
|
||||||
|
|
||||||
case '>':
|
case '>':
|
||||||
if (st1.st_mtime > st2.st_mtime) return Qtrue;
|
if (t1.tv_sec > t2.tv_sec) return Qtrue;
|
||||||
|
if (t1.tv_sec == t2.tv_sec && t1.tv_nsec > t2.tv_nsec) return Qtrue;
|
||||||
return Qfalse;
|
return Qfalse;
|
||||||
|
|
||||||
case '<':
|
case '<':
|
||||||
if (st1.st_mtime < st2.st_mtime) return Qtrue;
|
if (t1.tv_sec < t2.tv_sec) return Qtrue;
|
||||||
|
if (t1.tv_sec == t2.tv_sec && t1.tv_nsec < t2.tv_nsec) return Qtrue;
|
||||||
return Qfalse;
|
return Qfalse;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue