aboutsummaryrefslogtreecommitdiff
path: root/coreutils/touch.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2009-03-15 01:28:30 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2009-03-15 01:28:30 +0000
commit7241e6d37781dc7e72e2b8b809f2643b98b66c25 (patch)
tree0edb24823ce755867ce7678021babab3eb8f2b9e /coreutils/touch.c
parent7aaedcf21ee4c9eb49d7f1f74500c1b84cef75e7 (diff)
downloadbusybox-w32-7241e6d37781dc7e72e2b8b809f2643b98b66c25.tar.gz
busybox-w32-7241e6d37781dc7e72e2b8b809f2643b98b66c25.tar.bz2
busybox-w32-7241e6d37781dc7e72e2b8b809f2643b98b66c25.zip
uname: correct cut/paste error
touch: add long options function old new delta static.longopts 137 162 +25 touch_main 221 231 +10 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 35/0) Total: 35 bytes
Diffstat (limited to 'coreutils/touch.c')
-rw-r--r--coreutils/touch.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/coreutils/touch.c b/coreutils/touch.c
index 92f20235c..20191546c 100644
--- a/coreutils/touch.c
+++ b/coreutils/touch.c
@@ -41,6 +41,13 @@ int touch_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
41int touch_main(int argc UNUSED_PARAM, char **argv) 41int touch_main(int argc UNUSED_PARAM, char **argv)
42{ 42{
43#if ENABLE_DESKTOP 43#if ENABLE_DESKTOP
44#if ENABLE_GETOPT_LONG
45 static const char longopts[] ALIGN1 =
46 /* name, has_arg, val */
47 "no-create\0" No_argument "c"
48 "reference\0" Required_argument "r"
49 ;
50#endif
44 struct utimbuf timebuf; 51 struct utimbuf timebuf;
45 char *reference_file = NULL; 52 char *reference_file = NULL;
46#else 53#else
@@ -49,11 +56,18 @@ int touch_main(int argc UNUSED_PARAM, char **argv)
49#endif 56#endif
50 int fd; 57 int fd;
51 int status = EXIT_SUCCESS; 58 int status = EXIT_SUCCESS;
52 int flags = getopt32(argv, "c" USE_DESKTOP("r:") 59 int opts;
60
61#if ENABLE_DESKTOP
62#if ENABLE_GETOPT_LONG
63 applet_long_options = longopts;
64#endif
65#endif
66 opts = getopt32(argv, "c" USE_DESKTOP("r:")
53 /*ignored:*/ "fma" 67 /*ignored:*/ "fma"
54 USE_DESKTOP(, &reference_file)); 68 USE_DESKTOP(, &reference_file));
55 69
56 flags &= 1; /* only -c bit is left */ 70 opts &= 1; /* only -c bit is left */
57 argv += optind; 71 argv += optind;
58 if (!*argv) { 72 if (!*argv) {
59 bb_show_usage(); 73 bb_show_usage();
@@ -69,7 +83,7 @@ int touch_main(int argc UNUSED_PARAM, char **argv)
69 do { 83 do {
70 if (utime(*argv, reference_file ? &timebuf : NULL)) { 84 if (utime(*argv, reference_file ? &timebuf : NULL)) {
71 if (errno == ENOENT) { /* no such file */ 85 if (errno == ENOENT) { /* no such file */
72 if (flags) { /* creation is disabled, so ignore */ 86 if (opts) { /* creation is disabled, so ignore */
73 continue; 87 continue;
74 } 88 }
75 /* Try to create the file. */ 89 /* Try to create the file. */