Module Name: src
Committed By: christos
Date: Fri Apr 2 21:40:00 UTC 2010
Modified Files:
src/games/larn: scores.c
Log Message:
ctime can return NULL.
To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/games/larn/scores.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/games/larn/scores.c
diff -u src/games/larn/scores.c:1.18 src/games/larn/scores.c:1.19
--- src/games/larn/scores.c:1.18 Wed Aug 12 04:04:05 2009
+++ src/games/larn/scores.c Fri Apr 2 17:40:00 2010
@@ -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)