Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/games/larn ctime can return NULL.
details: https://anonhg.NetBSD.org/src/rev/cb7f37129f5f
branches: trunk
changeset: 753593:cb7f37129f5f
user: christos <christos%NetBSD.org@localhost>
date: Fri Apr 02 21:40:00 2010 +0000
description:
ctime can return NULL.
diffstat:
games/larn/scores.c | 14 +++++++++-----
1 files changed, 9 insertions(+), 5 deletions(-)
diffs (42 lines):
diff -r 4dc020158e00 -r cb7f37129f5f games/larn/scores.c
--- a/games/larn/scores.c Fri Apr 02 21:37:22 2010 +0000
+++ b/games/larn/scores.c Fri Apr 02 21:40:00 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: scores.c,v 1.18 2009/08/12 08:04:05 dholland Exp $ */
+/* $NetBSD: scores.c,v 1.19 2010/04/02 21:40:00 christos Exp $ */
/*
* scores.c Larn is copyrighted 1986 by Noah Morgan.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: scores.c,v 1.18 2009/08/12 08:04:05 dholland Exp $");
+__RCSID("$NetBSD: scores.c,v 1.19 2010/04/02 21:40:00 christos Exp $");
#endif /* not lint */
#include <sys/types.h>
#include <sys/times.h>
@@ -772,6 +772,7 @@
{
int n;
char *p;
+ static char q[] = "?";
struct stat stbuf;
lcreat((char *) 0);
if (lopen(logfile) < 0) {
@@ -784,9 +785,12 @@
}
for (n = stbuf.st_size / sizeof(struct log_fmt); n > 0; --n) {
lrfill((char *) &logg, sizeof(struct log_fmt));
- p = ctime(&logg.diedtime);
- p[16] = '\n';
- p[17] = 0;
+ if ((p = ctime(&logg.diedtime)) == NULL)
+ p = q;
+ else {
+ p[16] = '\n';
+ p[17] = 0;
+ }
lprintf("Score: %ld, Diff: %ld, %s %s on %ld at %s", (long) (logg.score), (long) (logg.diff), logg.who, logg.what, (long) (logg.cavelev), p + 4);
#ifdef EXTRA
if (logg.moves <= 0)
Home |
Main Index |
Thread Index |
Old Index