Module Name: src Committed By: dholland Date: Sat May 29 20:41:58 UTC 2010
Modified Files: src/bin/date: date.c Log Message: 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.53 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.53 --- src/bin/date/date.c:1.52 Sun Jul 20 00:52:39 2008 +++ src/bin/date/date.c Sat May 29 20:41:58 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: date.c,v 1.52 2008/07/20 00:52:39 lukem Exp $ */ +/* $NetBSD: date.c,v 1.53 2010/05/29 20:41:58 dholland 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.53 2010/05/29 20:41:58 dholland 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: