Source-Changes-HG archive

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

[src/trunk]: src handle ctime returning NULL.



details:   https://anonhg.NetBSD.org/src/rev/c0f079da586f
branches:  trunk
changeset: 753577:c0f079da586f
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Apr 02 15:34:16 2010 +0000

description:
handle ctime returning NULL.

diffstat:

 distrib/utils/tls/tls.c     |  13 ++++++++-----
 games/battlestar/command6.c |   9 +++------
 2 files changed, 11 insertions(+), 11 deletions(-)

diffs (64 lines):

diff -r 4835e943c636 -r c0f079da586f distrib/utils/tls/tls.c
--- a/distrib/utils/tls/tls.c   Fri Apr 02 15:28:16 2010 +0000
+++ b/distrib/utils/tls/tls.c   Fri Apr 02 15:34:16 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tls.c,v 1.3 2009/10/21 23:12:09 snj Exp $      */
+/*     $NetBSD: tls.c,v 1.4 2010/04/02 15:34:16 christos Exp $ */
 
 /*
  * Copyright (c) 1995 Gordon W. Ross
@@ -126,10 +126,13 @@
        }
 
        /* date */
-       date = ctime(&st.st_mtime);
-       date += 4;      /* skip day-of-week */
-       date[12] = '\0';        /* to the minute */
-       printf("%s ", date);
+       if ((date = ctime(&st.st_mtime)) == NULL)
+               printf("? ");
+       else {
+               date += 4;      /* skip day-of-week */
+               date[12] = '\0';        /* to the minute */
+               printf("%s ", date);
+       }
 
        /* name */
        printf("%s", fname);
diff -r 4835e943c636 -r c0f079da586f games/battlestar/command6.c
--- a/games/battlestar/command6.c       Fri Apr 02 15:28:16 2010 +0000
+++ b/games/battlestar/command6.c       Fri Apr 02 15:34:16 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: command6.c,v 1.5 2009/08/12 05:20:38 dholland Exp $    */
+/*     $NetBSD: command6.c,v 1.6 2010/04/02 15:35:32 christos Exp $    */
 
 /*
  * Copyright (c) 1983, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)com6.c     8.2 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: command6.c,v 1.5 2009/08/12 05:20:38 dholland Exp $");
+__RCSID("$NetBSD: command6.c,v 1.6 2010/04/02 15:35:32 christos Exp $");
 #endif
 #endif                         /* not lint */
 
@@ -120,17 +120,14 @@
 post(int ch)
 {
        time_t tv;
-       char   *date;
        sigset_t isigset, osigset;
 
        sigemptyset(&isigset);
        sigaddset(&isigset, SIGINT);
        sigprocmask(SIG_BLOCK, &isigset, &osigset);
        tv = time(NULL);
-       date = ctime(&tv);
-       date[24] = '\0';
        if (score_fp != NULL) {
-               fprintf(score_fp, "%s  %8s  %c%20s", date, username, 
+               fprintf(score_fp, "%24.24s  %8s  %c%20s", ctime(&t), username, 
                    ch, rate());
                if (wiz)
                        fprintf(score_fp, "   wizard\n");



Home | Main Index | Thread Index | Old Index