[BusyBox] And, thanks to glen, here's the date -r patch.

Rob Landley rob at landley.net
Tue Feb 17 10:42:59 UTC 2004


Based on glenn's patch.  It worked for me, your mileage may vary.

Rob

--- busybox.sed/coreutils/date.c	2004-02-17 04:42:25.630699704 -0600
+++ busybox/coreutils/date.c	2004-02-17 01:58:04.000000000 -0600
@@ -118,9 +118,8 @@
 #define DATE_OPT_SET    	0x02
 #define DATE_OPT_UTC    	0x04
 #define DATE_OPT_DATE   	0x08
-#define DATE_OPT_REFERENCE	0x10
 #ifdef CONFIG_FEATURE_DATE_ISOFMT
-# define DATE_OPT_TIMESPEC	0x20
+# define DATE_OPT_TIMESPEC	0x10
 #endif
 
 int date_main(int argc, char **argv)
@@ -134,7 +133,6 @@
 	time_t tm;
 	unsigned long opt;
 	struct tm tm_time;
-	char *filename = NULL;
 
 #ifdef CONFIG_FEATURE_DATE_ISOFMT
 	int ifmt = 0;
@@ -145,8 +143,8 @@
 # define GETOPT_ISOFMT
 #endif
 	bb_opt_complementaly = "d~ds:s~ds";
-	opt = bb_getopt_ulflags(argc, argv, "Rs:ud:r:" GETOPT_ISOFMT,
-					&date_str, &date_str, &filename
+	opt = bb_getopt_ulflags(argc, argv, "Rs:ud:" GETOPT_ISOFMT,
+					&date_str, &date_str
 #ifdef CONFIG_FEATURE_DATE_ISOFMT
 					, &isofmt_arg
 #endif
@@ -196,12 +194,7 @@
 	/* Now we have parsed all the information except the date format
 	   which depends on whether the clock is being set or read */
 
-	if(filename) {
-		struct stat statbuf;
-		if(stat(filename,&statbuf))
-			bb_perror_msg_and_die("File '%s' not found.\n",filename);
-		tm=statbuf.st_mtime;
-	} else time(&tm);
+	time(&tm);
 	memcpy(&tm_time, localtime(&tm), sizeof(tm_time));
 	/* Zero out fields - take her back to midnight! */
 	if (date_str != NULL) {




More information about the busybox mailing list