From 478f900b7dc6864069fe004358977507e9509558 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 29 Dec 2013 09:31:49 +0100 Subject: [PATCH] fixing up what my last commit broke, so it compiles on a regular linux again. platform.h needs some cleanup. --- core/src/gamecode/creport.c | 2 ++ core/src/gamecode/laws.c | 6 ++++-- core/src/gamecode/summary.c | 6 ++++-- core/src/kernel/textstore.c | 3 ++- core/src/platform.h | 19 +++++++++++++------ 5 files changed, 25 insertions(+), 11 deletions(-) diff --git a/core/src/gamecode/creport.c b/core/src/gamecode/creport.c index b7fe57358..4f998d248 100644 --- a/core/src/gamecode/creport.c +++ b/core/src/gamecode/creport.c @@ -504,6 +504,8 @@ static unsigned int messagehash(const struct message *msg) return (unsigned int)var.i; } +extern int fwritestr(FILE * F, const char *str); + static void render_messages(FILE * F, faction * f, message_list * msgs) { struct mlist *m = msgs->begin; diff --git a/core/src/gamecode/laws.c b/core/src/gamecode/laws.c index 372ab7c77..215d238e7 100755 --- a/core/src/gamecode/laws.c +++ b/core/src/gamecode/laws.c @@ -4668,8 +4668,10 @@ int writepasswd(void) char zText[128]; sprintf(zText, "%s/passwd", basepath()); - F = cfopen(zText, "w"); - if (F) { + F = fopen(zText, "w"); + if (!F) { + perror(zText); + } else { faction *f; log_info("writing passwords..."); diff --git a/core/src/gamecode/summary.c b/core/src/gamecode/summary.c index e169c2ff9..8ac9d546a 100644 --- a/core/src/gamecode/summary.c +++ b/core/src/gamecode/summary.c @@ -149,9 +149,11 @@ void report_summary(summary * s, summary * o, bool full) } else { sprintf(zText, "%s/parteien", basepath()); } - F = cfopen(zText, "w"); - if (!F) + F = fopen(zText, "w"); + if (!F) { + perror(zText); return; + } #ifdef SUMMARY_BOM else { const unsigned char utf8_bom[4] = { 0xef, 0xbb, 0xbf, 0 }; diff --git a/core/src/kernel/textstore.c b/core/src/kernel/textstore.c index 81cb79a46..b04b8b076 100644 --- a/core/src/kernel/textstore.c +++ b/core/src/kernel/textstore.c @@ -17,6 +17,7 @@ without prior permission by the authors of Eressea. #include #include +#include #include #include #include @@ -27,7 +28,7 @@ without prior permission by the authors of Eressea. /** writes a quoted string to the file * no trailing space, since this is used to make the creport. */ -static int fwritestr(FILE * F, const char *str) +int fwritestr(FILE * F, const char *str) { int nwrite = 0; fputc('\"', F); diff --git a/core/src/platform.h b/core/src/platform.h index 7e1fd72b4..dfce03b80 100644 --- a/core/src/platform.h +++ b/core/src/platform.h @@ -117,7 +117,6 @@ extern "C" { # define HAVE_STAT typedef struct stat stat_type; # include -# define HAVE_STRDUP # define HAVE_SNPRINTF #ifdef _POSIX_SOURCE /* MINGW doesn't seem to have these */ # define HAVE_EXECINFO @@ -143,7 +142,6 @@ typedef struct stat stat_type; typedef struct stat stat_type; # define HAVE_STRICMP # define HAVE_STRNICMP -# define HAVE_STRDUP # define HAVE_SLEEP # define snprintf _snprintf # define HAVE_SNPRINTF @@ -175,10 +173,6 @@ typedef struct stat stat_type; # define stat(a, b) _stat(a, b) typedef struct _stat stat_type; -/* MSVC has _strdup */ -# define strdup _strdup -# define HAVE_STRDUP - # define stricmp(a, b) _stricmp(a, b) # define HAVE_STRICMP @@ -256,4 +250,17 @@ extern char *strdup(const char *s); #define isxspace(c) (c==160 || isspace(c)) #define TOLUA_CAST (char*) + +#if !defined(HAVE_STRDUP) +# if defined(HAVE__STRDUP) +# define strdup(s) _strdup(s) +# endif +#endif + +#if !defined(HAVE__STRDUP) +# if defined(HAVE_STRDUP) +# define _strdup(s) strdup(s) +# endif +#endif + #endif