empdump: Don't abort() on unresolvable symbols
empdump flags them since commit 2a5d12b
(v4.3.28), but still aborts.
Avoid the abort.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
parent
9ca3fa95b8
commit
edfb80a1f7
4 changed files with 19 additions and 12 deletions
|
@ -27,7 +27,7 @@
|
|||
* xdump.h: Extended dumps
|
||||
*
|
||||
* Known contributors to this file:
|
||||
* Markus Armbruster, 2008-2011
|
||||
* Markus Armbruster, 2008-2013
|
||||
*/
|
||||
|
||||
#ifndef XDUMP_H
|
||||
|
@ -42,11 +42,13 @@ struct xdstr {
|
|||
natid cnum; /* dump for this country */
|
||||
int divine; /* is this a deity dump? */
|
||||
int human; /* dump human-readable format */
|
||||
int sloppy; /* try to cope with invalid data */
|
||||
void (*pr)(char *fmt, ...) /* callback for printing dump */
|
||||
ATTRIBUTE((format (printf, 1, 2)));
|
||||
};
|
||||
|
||||
struct xdstr *xdinit(struct xdstr *, natid, int, void (*)(char *, ...));
|
||||
struct xdstr *xdinit(struct xdstr *, natid, int, int,
|
||||
void (*)(char *, ...));
|
||||
extern void xdhdr(struct xdstr *, char *, int);
|
||||
extern void xdcolhdr(struct xdstr *, struct castr[]);
|
||||
extern void xdflds(struct xdstr *, struct castr[], void *);
|
||||
|
|
|
@ -189,7 +189,7 @@ xdump(void)
|
|||
if (!p || !*p)
|
||||
return RET_SYN;
|
||||
|
||||
xdinit(&xd, player->cnum, 0, pr);
|
||||
xdinit(&xd, player->cnum, 0, 0, pr);
|
||||
natp = getnatp(player->cnum);
|
||||
type = isdigit(p[0]) ? atoi(p) : ef_byname(p);
|
||||
if (type < 0 || type >= EF_MAX)
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
* xdump.c: Extended dumps
|
||||
*
|
||||
* Known contributors to this file:
|
||||
* Markus Armbruster, 2004-2010
|
||||
* Markus Armbruster, 2004-2013
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@ -84,15 +84,19 @@
|
|||
* Initialize XD.
|
||||
* Translate dump for country CNUM, except when CNUM is NATID_BAD.
|
||||
* If HUMAN, dump in human-readable format.
|
||||
* If SLOPPY, try to cope with invalid data (may result in invalid
|
||||
* dump).
|
||||
* Dump is to be delivered through callback PR.
|
||||
* Return XD.
|
||||
*/
|
||||
struct xdstr *
|
||||
xdinit(struct xdstr *xd, natid cnum, int human, void (*pr)(char *fmt, ...))
|
||||
xdinit(struct xdstr *xd, natid cnum, int human, int sloppy,
|
||||
void (*pr)(char *fmt, ...))
|
||||
{
|
||||
xd->cnum = cnum;
|
||||
xd->divine = cnum == NATID_BAD || getnatp(cnum)->nat_stat == STAT_GOD;
|
||||
xd->human = human;
|
||||
xd->sloppy = sloppy;
|
||||
xd->pr = pr;
|
||||
return xd;
|
||||
}
|
||||
|
@ -181,9 +185,10 @@ xdprsym(struct xdstr *xd, int key, int type, char *sep)
|
|||
{
|
||||
char *sym = symbol_by_value(key, ef_ptr(type, 0));
|
||||
|
||||
if (CANT_HAPPEN(!sym))
|
||||
if (!sym) {
|
||||
CANT_HAPPEN(!xd->sloppy);
|
||||
xd->pr("%s%d", sep, key);
|
||||
else {
|
||||
} else {
|
||||
xd->pr("%s", sep);
|
||||
xdpresc(xd, sym, INT_MAX);
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
* empdump.c: Export/import Empire game state
|
||||
*
|
||||
* Known contributors to this file:
|
||||
* Markus Armbruster, 2008-2011
|
||||
* Markus Armbruster, 2008-2013
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
@ -46,7 +46,7 @@
|
|||
|
||||
static void exit_bad_arg(char *, ...)
|
||||
ATTRIBUTE((noreturn, format (printf, 1, 2)));
|
||||
static void dump_table(int, int);
|
||||
static void dump_table(int, int, int);
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
|
@ -159,7 +159,7 @@ main(int argc, char *argv[])
|
|||
for (i = 0; i < EF_MAX; i++) {
|
||||
if (!EF_IS_GAME_STATE(i))
|
||||
continue;
|
||||
dump_table(i, human);
|
||||
dump_table(i, human, !verified);
|
||||
}
|
||||
if (fclose(stdout) != 0) {
|
||||
fprintf(stderr, "%s: error writing export (%s)\n",
|
||||
|
@ -213,7 +213,7 @@ printf_wrapper(char *fmt, ...)
|
|||
}
|
||||
|
||||
static void
|
||||
dump_table(int type, int human)
|
||||
dump_table(int type, int human, int sloppy)
|
||||
{
|
||||
struct xdstr xd;
|
||||
struct castr *ca;
|
||||
|
@ -224,7 +224,7 @@ dump_table(int type, int human)
|
|||
if (!ca)
|
||||
return;
|
||||
|
||||
xdinit(&xd, NATID_BAD, human, printf_wrapper);
|
||||
xdinit(&xd, NATID_BAD, human, sloppy, printf_wrapper);
|
||||
xdhdr(&xd, ef_nameof(type), 0);
|
||||
xdcolhdr(&xd, ca);
|
||||
for (i = 0; (p = ef_ptr(type, i)); i++) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue