diff options
-rw-r--r-- | coreutils/touch.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/coreutils/touch.c b/coreutils/touch.c index 43312d22a..52605fb7c 100644 --- a/coreutils/touch.c +++ b/coreutils/touch.c | |||
@@ -88,8 +88,8 @@ int touch_main(int argc UNUSED_PARAM, char **argv) | |||
88 | int opts; | 88 | int opts; |
89 | smalluint status = EXIT_SUCCESS; | 89 | smalluint status = EXIT_SUCCESS; |
90 | #if ENABLE_FEATURE_TOUCH_SUSV3 | 90 | #if ENABLE_FEATURE_TOUCH_SUSV3 |
91 | char *reference_file = NULL; | 91 | char *reference_file; |
92 | char *date_str = NULL; | 92 | char *date_str; |
93 | /* timebuf[0] is atime, timebuf[1] is mtime */ | 93 | /* timebuf[0] is atime, timebuf[1] is mtime */ |
94 | struct timespec timebuf[2]; | 94 | struct timespec timebuf[2]; |
95 | #else | 95 | #else |
@@ -137,7 +137,7 @@ int touch_main(int argc UNUSED_PARAM, char **argv) | |||
137 | ); | 137 | ); |
138 | 138 | ||
139 | timebuf[0].tv_nsec = timebuf[1].tv_nsec = UTIME_NOW; | 139 | timebuf[0].tv_nsec = timebuf[1].tv_nsec = UTIME_NOW; |
140 | if (reference_file) { | 140 | if (opts & OPT_r) { |
141 | struct stat stbuf; | 141 | struct stat stbuf; |
142 | xstat(reference_file, &stbuf); | 142 | xstat(reference_file, &stbuf); |
143 | timebuf[0].tv_sec = stbuf.st_atime; | 143 | timebuf[0].tv_sec = stbuf.st_atime; |
@@ -145,7 +145,7 @@ int touch_main(int argc UNUSED_PARAM, char **argv) | |||
145 | timebuf[0].tv_nsec = stbuf.st_atim.tv_nsec; | 145 | timebuf[0].tv_nsec = stbuf.st_atim.tv_nsec; |
146 | timebuf[1].tv_nsec = stbuf.st_mtim.tv_nsec; | 146 | timebuf[1].tv_nsec = stbuf.st_mtim.tv_nsec; |
147 | } | 147 | } |
148 | if (date_str) { | 148 | if (opts & (OPT_d|OPT_t)) { |
149 | struct tm tm_time; | 149 | struct tm tm_time; |
150 | time_t t; | 150 | time_t t; |
151 | 151 | ||