aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--coreutils/touch.c31
1 files changed, 13 insertions, 18 deletions
diff --git a/coreutils/touch.c b/coreutils/touch.c
index 68fb625fe..92e134168 100644
--- a/coreutils/touch.c
+++ b/coreutils/touch.c
@@ -97,23 +97,18 @@ int touch_main(int argc UNUSED_PARAM, char **argv)
97 OPT_m = (1 << 5) * ENABLE_FEATURE_TOUCH_SUSV3, 97 OPT_m = (1 << 5) * ENABLE_FEATURE_TOUCH_SUSV3,
98 OPT_h = (1 << 6) * ENABLE_FEATURE_TOUCH_NODEREF, 98 OPT_h = (1 << 6) * ENABLE_FEATURE_TOUCH_NODEREF,
99 }; 99 };
100#if ENABLE_FEATURE_TOUCH_SUSV3
101 /* NULL = use current time */ 100 /* NULL = use current time */
102 const struct timeval *newtime = NULL; 101 const struct timeval *newtime = NULL;
103# if ENABLE_LONG_OPTS 102#if ENABLE_LONG_OPTS
104 static const char touch_longopts[] ALIGN1 = 103 static const char touch_longopts[] ALIGN1 =
105 /* name, has_arg, val */ 104 /* name, has_arg, val */
106 "no-create\0" No_argument "c" 105 "no-create\0" No_argument "c"
107 "reference\0" Required_argument "r" 106 IF_FEATURE_TOUCH_SUSV3("reference\0" Required_argument "r")
108 "date\0" Required_argument "d" 107 IF_FEATURE_TOUCH_SUSV3("date\0" Required_argument "d")
109 IF_FEATURE_TOUCH_NODEREF("no-dereference\0" No_argument "h") 108 IF_FEATURE_TOUCH_NODEREF("no-dereference\0" No_argument "h")
110 ; 109 ;
111# define GETOPT32 getopt32long 110#endif
112# define LONGOPTS ,touch_longopts 111#if ENABLE_FEATURE_TOUCH_SUSV3
113# else
114# define GETOPT32 getopt32
115# define LONGOPTS
116# endif
117 char *reference_file = NULL; 112 char *reference_file = NULL;
118 char *date_str = NULL; 113 char *date_str = NULL;
119 /* timebuf[0] is atime, timebuf[1] is mtime */ 114 /* timebuf[0] is atime, timebuf[1] is mtime */
@@ -123,20 +118,20 @@ int touch_main(int argc UNUSED_PARAM, char **argv)
123# define reference_file NULL 118# define reference_file NULL
124# define date_str NULL 119# define date_str NULL
125# define timebuf ((struct timeval*)NULL) 120# define timebuf ((struct timeval*)NULL)
126# define GETOPT32 getopt32
127# define LONGOPTS
128#endif 121#endif
129 122
130 /* -d and -t both set time. In coreutils, 123 /* -d and -t both set time. In coreutils,
131 * accepted data format differs a bit between -d and -t. 124 * accepted data format differs a bit between -d and -t.
132 * We accept the same formats for both */ 125 * We accept the same formats for both */
133 opts = GETOPT32(argv, "c" IF_FEATURE_TOUCH_SUSV3("r:d:t:am") 126 opts = getopt32long(argv, "c" IF_FEATURE_TOUCH_SUSV3("r:d:t:am")
134 IF_FEATURE_TOUCH_NODEREF("h") 127 IF_FEATURE_TOUCH_NODEREF("h")
135 /*ignored:*/ "f" IF_NOT_FEATURE_TOUCH_SUSV3("am") 128 /*ignored:*/ "f" IF_NOT_FEATURE_TOUCH_SUSV3("am"),
136 LONGOPTS 129 touch_longopts
137 IF_FEATURE_TOUCH_SUSV3(, &reference_file) 130#if ENABLE_FEATURE_TOUCH_SUSV3
138 IF_FEATURE_TOUCH_SUSV3(, &date_str) 131 , &reference_file
139 IF_FEATURE_TOUCH_SUSV3(, &date_str) 132 , &date_str
133 , &date_str
134#endif
140 ); 135 );
141 136
142 argv += optind; 137 argv += optind;