Module Name:    src
Committed By:   christos
Date:           Mon Oct 22 21:51:58 UTC 2012

Modified Files:
        src/usr.bin/touch: touch.1 touch.c

Log Message:
Recognize --date and --reference like gnu.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/usr.bin/touch/touch.1
cvs rdiff -u -r1.31 -r1.32 src/usr.bin/touch/touch.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/touch/touch.1
diff -u src/usr.bin/touch/touch.1:1.21 src/usr.bin/touch/touch.1:1.22
--- src/usr.bin/touch/touch.1:1.21	Fri Jul 27 14:34:35 2012
+++ src/usr.bin/touch/touch.1	Mon Oct 22 17:51:58 2012
@@ -1,4 +1,4 @@
-.\"	$NetBSD: touch.1,v 1.21 2012/07/27 18:34:35 wiz Exp $
+.\"	$NetBSD: touch.1,v 1.22 2012/10/22 21:51:58 christos Exp $
 .\"
 .\" Copyright (c) 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -32,7 +32,7 @@
 .\"
 .\"     @(#)touch.1	8.3 (Berkeley) 4/28/95
 .\"
-.Dd July 24, 2012
+.Dd October 22, 2012
 .Dt TOUCH 1
 .Os
 .Sh NAME
@@ -66,6 +66,7 @@ The
 utility does not treat this as an error.
 No error messages are displayed and the exit value is not affected.
 .It Fl d Ar human-datetime
+.It Fl Fl date Ar human-datetime
 Parse
 .Ar human-datetime
 using the human datetime parser
@@ -84,6 +85,7 @@ The access time of the file is not chang
 .Fl a
 flag is also specified.
 .It Fl r Ar file
+.It Fl Fl reference Ar file
 Use the access and modifications times from
 .Ar file
 instead of the current time of day.

Index: src/usr.bin/touch/touch.c
diff -u src/usr.bin/touch/touch.c:1.31 src/usr.bin/touch/touch.c:1.32
--- src/usr.bin/touch/touch.c:1.31	Tue Jul 24 21:23:46 2012
+++ src/usr.bin/touch/touch.c	Mon Oct 22 17:51:58 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: touch.c,v 1.31 2012/07/25 01:23:46 christos Exp $	*/
+/*	$NetBSD: touch.c,v 1.32 2012/10/22 21:51:58 christos Exp $	*/
 
 /*
  * Copyright (c) 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1993\
 #if 0
 static char sccsid[] = "@(#)touch.c	8.2 (Berkeley) 4/28/95";
 #endif
-__RCSID("$NetBSD: touch.c,v 1.31 2012/07/25 01:23:46 christos Exp $");
+__RCSID("$NetBSD: touch.c,v 1.32 2012/10/22 21:51:58 christos Exp $");
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -57,6 +57,7 @@ __RCSID("$NetBSD: touch.c,v 1.31 2012/07
 #include <tzfile.h>
 #include <unistd.h>
 #include <util.h>
+#include <getopt.h>
 
 static void	stime_arg0(char *, struct timeval *);
 static void	stime_arg1(char *, struct timeval *);
@@ -64,6 +65,15 @@ static void	stime_arg2(char *, int, stru
 static void	stime_file(char *, struct timeval *);
 __dead static void	usage(void);
 
+struct option touch_longopts[] = {
+	{ "date",		required_argument,	0,
+						'd' },
+	{ "reference",		required_argument,	0,
+						'r' },
+	{ NULL,			0,			0,
+						0 },
+};
+
 int
 main(int argc, char *argv[])
 {
@@ -80,7 +90,8 @@ main(int argc, char *argv[])
 	if (gettimeofday(&tv[0], NULL))
 		err(1, "gettimeofday");
 
-	while ((ch = getopt(argc, argv, "acd:fhmr:t:")) != -1)
+	while ((ch = getopt_long(argc, argv, "acd:fhmr:t:", touch_longopts,
+	    NULL)) != -1)
 		switch(ch) {
 		case 'a':
 			aflag = 1;
@@ -320,7 +331,7 @@ static void
 usage(void)
 {
 	(void)fprintf(stderr,
-	    "Usage: %s [-acfhm] [-d datetime] [-r file] [-t time] file ...\n",
+	    "Usage: %s [-acfhm] [-d|--date datetime] [-r|--reference file] [-t time] file ...\n",
 	    getprogname());
 	exit(EXIT_FAILURE);
 }

Reply via email to