From 9141f0d9703447bbee1026f9d4b55a86b93d69b7 Mon Sep 17 00:00:00 2001 From: mitchell <70453897+667e-11@users.noreply.github.com> Date: Sat, 24 Feb 2018 20:22:57 -0500 Subject: Define header flags in source code rather than in Makefile. Requires lspawn r60 (changeset 9a8b4b5e4137) and gtdialog r112 (changeset 6435a42450c7). --- src/textadept.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/textadept.c') diff --git a/src/textadept.c b/src/textadept.c index 156ffcbf..3be679b1 100644 --- a/src/textadept.c +++ b/src/textadept.c @@ -1,5 +1,9 @@ // Copyright 2007-2018 Mitchell mitchell.att.foicica.com. See LICENSE. +#if __linux__ +#define _XOPEN_SOURCE 500 // for readlink from unistd.h +#endif + // Library includes. #include #include @@ -17,7 +21,6 @@ #elif __APPLE__ #include #elif (__FreeBSD__ || __NetBSD__ || __OpenBSD__) -#define u_int unsigned int // 'u_int' undefined when _POSIX_SOURCE is defined #include #include #endif @@ -1377,11 +1380,11 @@ static int lquit(lua_State *L) { return 0; } -#if _WIN32 -char *stpcpy(char *dest, const char *src) { +// stpcpy() does not exist on _WIN32, but exists on other platforms with or +// without feature test macros. In order to minimize confusion, just define it. +char *stpcpy_(char *dest, const char *src) { return (strcpy(dest, src), dest + strlen(src)); } -#endif /** * Loads and runs the given file. @@ -1391,7 +1394,7 @@ char *stpcpy(char *dest, const char *src) { */ static int lL_dofile(lua_State *L, const char *filename) { char *file = malloc(strlen(textadept_home) + 1 + strlen(filename) + 1); - stpcpy(stpcpy(stpcpy(file, textadept_home), "/"), filename); + stpcpy_(stpcpy_(stpcpy_(file, textadept_home), "/"), filename); int ok = (luaL_dofile(L, file) == LUA_OK); if (!ok) { #if GTK -- cgit v1.2.3