Source-Changes-HG archive

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

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



details:   https://anonhg.NetBSD.org/src/rev/86121a01b236
branches:  trunk
changeset: 753621:86121a01b236
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Apr 04 00:08:49 2010 +0000

description:
handle ctime returning NULL.

diffstat:

 games/mille/save.c |  17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)

diffs (52 lines):

diff -r 8682cdcd5ce4 -r 86121a01b236 games/mille/save.c
--- a/games/mille/save.c        Sat Apr 03 23:17:05 2010 +0000
+++ b/games/mille/save.c        Sun Apr 04 00:08:49 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: save.c,v 1.14 2009/05/25 23:24:54 dholland Exp $       */
+/*     $NetBSD: save.c,v 1.15 2010/04/04 00:08:49 christos Exp $       */
 
 /*
  * Copyright (c) 1983, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)save.c     8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: save.c,v 1.14 2009/05/25 23:24:54 dholland Exp $");
+__RCSID("$NetBSD: save.c,v 1.15 2010/04/04 00:08:49 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -124,7 +124,11 @@
        if (rv == FALSE) {
                unlink(buf);
        } else {
-               strcpy(buf, ctime(tp));
+               char *p;
+               if ((p = ctime(tp)) == NULL)
+                       strcpy(buf, "?");
+               else
+                       strcpy(buf, p);
                for (sp = buf; *sp != '\n'; sp++)
                        continue;
                *sp = '\0';
@@ -144,7 +148,7 @@
 rest_f(const char *file)
 {
 
-       char    *sp;
+       char    *sp, *p;
        int     inf;
        char    buf[80];
        STAT    sbuf;
@@ -159,7 +163,10 @@
        }
        varpush(inf, readv);
        close(inf);
-       strcpy(buf, ctime(&sbuf.st_mtime));
+       if ((p = ctime(&sbuf.st_mtime)) == NULL)
+               strcpy(buf, "?");
+       else
+               strcpy(buf, p);
        for (sp = buf; *sp != '\n'; sp++)
                continue;
        *sp = '\0';



Home | Main Index | Thread Index | Old Index