Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/bin/date Don't blow up on date +''. Patch from Robert Elz in...



details:   https://anonhg.NetBSD.org/src/rev/9a08cd04bb38
branches:  trunk
changeset: 755242:9a08cd04bb38
user:      dholland <dholland%NetBSD.org@localhost>
date:      Sat May 29 20:41:58 2010 +0000

description:
Don't blow up on date +''. Patch from Robert Elz in followup to PR 39392.

diffstat:

 bin/date/date.c |  12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diffs (49 lines):

diff -r 1cc5d31cd92c -r 9a08cd04bb38 bin/date/date.c
--- a/bin/date/date.c   Sat May 29 20:32:18 2010 +0000
+++ b/bin/date/date.c   Sat May 29 20:41:58 2010 +0000
@@ -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:



Home | Main Index | Thread Index | Old Index