From b7a44a904f68d5a88886d63c2abc4cb42f2ac56c Mon Sep 17 00:00:00 2001 From: jsm Date: Thu, 1 Jan 2004 16:03:46 +0000 Subject: When cleaning up, only close files that have been opened successfully. When reporting errors for failing to open files, give error text rather than errno number. Patch from Joey Hess for Debian bug 187251 from Mikael Hedin . --- phantasia/main.c | 14 +++++++++----- phantasia/misc.c | 4 ++-- 2 files changed, 11 insertions(+), 7 deletions(-) (limited to 'phantasia') diff --git a/phantasia/main.c b/phantasia/main.c index 871ff678..f9beea8a 100644 --- a/phantasia/main.c +++ b/phantasia/main.c @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.11 2003/05/08 13:03:49 wiz Exp $ */ +/* $NetBSD: main.c,v 1.12 2004/01/01 16:03:46 jsm Exp $ */ /* * Phantasia 3.3.2 -- Interterminal fantasy game @@ -997,10 +997,14 @@ cleanup(doexit) nocbreak(); endwin(); } - fclose(Playersfp); - fclose(Monstfp); - fclose(Messagefp); - fclose(Energyvoidfp); + if (Playersfp) + fclose(Playersfp); + if (Monstfp) + fclose(Monstfp); + if (Messagefp) + fclose(Messagefp); + if (Energyvoidfp) + fclose(Energyvoidfp); if (doexit) exit(0); diff --git a/phantasia/misc.c b/phantasia/misc.c index e195e4d3..4dc71b37 100644 --- a/phantasia/misc.c +++ b/phantasia/misc.c @@ -1,4 +1,4 @@ -/* $NetBSD: misc.c,v 1.9 2003/05/08 13:03:49 wiz Exp $ */ +/* $NetBSD: misc.c,v 1.10 2004/01/01 16:03:46 jsm Exp $ */ /* * misc.c Phantasia miscellaneous support routines @@ -945,7 +945,7 @@ error(whichfile) } else funcp = printf; - (*funcp) ("An unrecoverable error has occurred reading %s. (errno = %d)\n", whichfile, errno); + (*funcp) ("An unrecoverable error has occurred reading %s. (%s)\n", whichfile, strerror(errno)); (*funcp) ("Please run 'setup' to determine the problem.\n"); cleanup(TRUE); /* NOTREACHED */ -- cgit v1.2.3-56-ge451