aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2021-04-13 15:41:57 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2021-04-13 15:41:57 +0200
commit36300545046a4f33dca90cedf14a6025a313aeac (patch)
treefd47d7097f34ce4f130696b3441a135f195f0e6e
parent6f63a2ba0e54f7fc8ec66d470beb0212dd1b4d4f (diff)
downloadbusybox-w32-36300545046a4f33dca90cedf14a6025a313aeac.tar.gz
busybox-w32-36300545046a4f33dca90cedf14a6025a313aeac.tar.bz2
busybox-w32-36300545046a4f33dca90cedf14a6025a313aeac.zip
touch: code shrink
function old new delta touch_main 450 423 -27 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--coreutils/touch.c8
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