fix strdup compilications when compiling with gcc and autoconf.

This commit is contained in:
Enno Rehling 2016-11-26 16:21:41 +01:00
parent 68ce6907f3
commit 43b8ff1ea8
5 changed files with 43 additions and 41 deletions

View File

@ -60,7 +60,9 @@ CONFIGURE_FILE (
${CMAKE_CURRENT_SOURCE_DIR}/autoconf.h.in
${CMAKE_BINARY_DIR}/include/autoconf.h)
INCLUDE_DIRECTORIES (${CMAKE_BINARY_DIR}/include)
add_definitions(-DUSE_AUTOCONF)
## skip compiler/libc detection and force cmake autoconf:
#add_definitions(-DUSE_AUTOCONF)
add_subdirectory (cutest)
add_subdirectory (cJSON)

View File

@ -84,6 +84,7 @@ TOLUA_BINDING(settings.pkg kenel/config.h)
ENDIF()
set (ERESSEA_SRC
vortex.c
calendar.c
move.c
piracy.c
@ -92,7 +93,6 @@ set (ERESSEA_SRC
alchemy.c
academy.c
upkeep.c
vortex.c
names.c
lighthouse.c
reports.c

View File

@ -16,22 +16,39 @@ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
**/
#ifndef CONFIG_H
#define CONFIG_H
#ifndef PLATFORM_H
#define PLATFORM_H
#ifdef NDEBUG
#define LOMEM
#endif
#undef USE_AUTOCONF
// enable X/Open 7 extensions (like strdup):
#ifndef _XOPEN_SOURCE
#define _XOPEN_SOURCE 700
#endif
// enable bsd string extensions, prior to glibc 2.12:
#ifndef _BSD_SOURCE
#define _BSD_SOURCE
#endif
// enable bsd string extensions, since glibc 2.12:
#ifndef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200809L
#endif
#ifndef USE_AUTOCONF
#define USE_AUTOCONF
#ifdef _MSC_VER
# define HAVE_STDBOOL_H
# define HAVE_DIRECT__MKDIR
# define HAVE__ACCESS
# define VC_EXTRALEAN
# define WIN32_LEAN_AND_MEAN
#undef USE_AUTOCONF
#define HAVE_STDBOOL_H
#define HAVE_DIRECT__MKDIR
#define HAVE__ACCESS
#define VC_EXTRALEAN
#define WIN32_LEAN_AND_MEAN
#pragma warning(push)
#pragma warning(disable:4820 4255 4668)
# include <windows.h>
@ -66,7 +83,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
/* warning C4100: <name> was declared deprecated */
#ifndef _CRT_SECURE_NO_DEPRECATE
# define _CRT_SECURE_NO_DEPRECATE
#define _CRT_SECURE_NO_DEPRECATE
#endif
/*
@ -75,39 +92,25 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
* single-threaded I/O model and use the _nolock forms of the functions.
*/
#ifndef _CRT_DISABLE_PERFCRIT_LOCKS
# define _CRT_DISABLE_PERFCRIT_LOCKS
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
/* define CRTDBG to enable MSVC CRT Debug library functions */
#if defined(_DEBUG) && defined(CRTDBG)
# include <crtdbg.h>
# define _CRTDBG_MAP_ALLOC
#endif
#undef USE_AUTOCONF
#elif __GNUC__
# define _POSIX_C_SOURCE 200809L
# undef _DEFAULT_SOURCE
# define _DEFAULT_SOURCE
# undef __USE_BSD
# define __USE_BSD
# define HAVE_SNPRINTF
# define HAVE_SYS_STAT_MKDIR
# define HAVE_STRDUP
# define HAVE_UNISTD_H
# undef USE_AUTOCONF
#undef USE_AUTOCONF
#define HAVE_SNPRINTF
#define HAVE_SYS_STAT_MKDIR
#define HAVE_STRDUP
#define HAVE_UNISTD_H
#endif
#endif
#ifdef USE_AUTOCONF
// unknown toolchain, using autoconf
#include <autoconf.h>
#endif
#define unused_arg (void)
#ifndef INLINE_FUNCTION
# define INLINE_FUNCTION
#endif
#define iswxspace(c) (c==160 || iswspace(c))
#define isxspace(c) (c==160 || isspace(c))
@ -125,10 +128,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <unistd.h>
#endif
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
#if defined(HAVE_STDBOOL_H)
# include <stdbool.h>
#else
@ -171,7 +170,7 @@ typedef unsigned char _Bool;
#if !defined(HAVE__STRDUP)
#if defined(HAVE_STRDUP)
#undef _strdup
#define _strdup(a) strdup(a)
#define _strdup strdup
#endif
#endif

View File

@ -18,7 +18,7 @@ static void unicode_warning(const char *bp)
log_warning("invalid sequence in UTF-8 string: %s\n", bp);
}
INLINE_FUNCTION int eatwhite(const char *ptr, size_t * total_size)
static int eatwhite(const char *ptr, size_t * total_size)
{
int ret = 0;

View File

@ -14,8 +14,9 @@
#include <storage.h>
#include <assert.h>
#include <string.h>
#include <stdlib.h>
#include <string.h>
typedef struct dir_lookup {
char *name;
@ -32,7 +33,7 @@ void register_special_direction(struct locale *lang, const char *name)
if (token) {
void **tokens = get_translations(lang, UT_SPECDIR);
variant var;
char *str = _strdup(name);
char *str = strdup(name);
var.v = str;
addtoken((struct tnode **)tokens, token, var);