Module Name:    src
Committed By:   riz
Date:           Sun Nov 21 17:26:36 UTC 2010

Modified Files:
        src/bin/date [netbsd-5]: date.c

Log Message:
Pull up following revision(s) (requested by dholland in ticket #1411):
        bin/date/date.c: revision 1.53
Don't blow up on date +''. Patch from Robert Elz in followup to PR 39392.


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.52.4.1 src/bin/date/date.c

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

Modified files:

Index: src/bin/date/date.c
diff -u src/bin/date/date.c:1.52 src/bin/date/date.c:1.52.4.1
--- src/bin/date/date.c:1.52	Sun Jul 20 00:52:39 2008
+++ src/bin/date/date.c	Sun Nov 21 17:26:36 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: date.c,v 1.52 2008/07/20 00:52:39 lukem Exp $ */
+/* $NetBSD: date.c,v 1.52.4.1 2010/11/21 17:26:36 riz Exp $ */
 
 /*
  * Copyright (c) 1985, 1987, 1988, 1993
@@ -40,7 +40,7 @@
 #if 0
 static char sccsid[] = "@(#)date.c	8.2 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: date.c,v 1.52 2008/07/20 00:52:39 lukem Exp $");
+__RCSID("$NetBSD: date.c,v 1.52.4.1 2010/11/21 17:26:36 riz Exp $");
 #endif
 #endif /* not lint */
 
@@ -118,11 +118,11 @@
 	if (!rflag && time(&tval) == -1)
 		err(EXIT_FAILURE, "time");
 
-	format = "%a %b %e %H:%M:%S %Z %Y";
+	format = "+%a %b %e %H:%M:%S %Z %Y";
 
 	/* allow the operands in any order */
 	if (*argv && **argv == '+') {
-		format = *argv + 1;
+		format = *argv;
 		++argv;
 	}
 
@@ -132,14 +132,14 @@
 	}
 
 	if (*argv && **argv == '+')
-		format = *argv + 1;
+		format = *argv;
 
 	if ((buf = malloc(bufsiz = 1024)) == NULL)
 		goto bad;
 	while (strftime(buf, bufsiz, format, localtime(&tval)) == 0)
 		if ((buf = realloc(buf, bufsiz <<= 1)) == NULL)
 			goto bad;
-	(void)printf("%s\n", buf);
+	(void)printf("%s\n", buf+1);
 	free(buf);
 	return 0;
 bad:

Reply via email to