diff options
-rw-r--r-- | src/Makefile | 16 | ||||
-rw-r--r-- | src/textadept.c | 13 |
2 files changed, 15 insertions, 14 deletions
diff --git a/src/Makefile b/src/Makefile index 6b9a1ea7..9c4416ae 100644 --- a/src/Makefile +++ b/src/Makefile @@ -6,7 +6,7 @@ ifeq (win, $(findstring win, $(MAKECMDGOALS))) # Cross-compile for Win32. CROSS = i686-w64-mingw32- CFLAGS = -mms-bitfields -Os - CXXFLAGS = -mms-bitfields -static-libgcc -static-libstdc++ -Os + CXXFLAGS = -mms-bitfields -static-libgcc -static-libstdc++ -Os -std=g++0x LUA_CFLAGS = -DLUA_BUILD_AS_DLL -DLUA_LIB LDFLAGS = -Wl,--retain-symbols-file -Wl,lua.sym ifeq (, $(findstring curses, $(MAKECMDGOALS))) @@ -129,8 +129,8 @@ lexlpeg_objs = LexLPeg.o LexLPegjit.o LexLPeg-curses.o LexLPegjit-curses.o # Textadept. -ta_flags = -std=c99 -pedantic -D_POSIX_C_SOURCE=200809L -D_DARWIN_C_SOURCE \ - $(plat_flag) -Iscintilla/include -Igtdialog -W -Wall -Wno-unused +ta_flags = -std=c99 -pedantic $(plat_flag) -Iscintilla/include -Igtdialog -W \ + -Wall -Wno-unused textadept_gtk_objs = textadept.o textadeptjit.o textadept_curses_objs = textadept-curses.o textadeptjit-curses.o @@ -192,8 +192,8 @@ $(lua_lib_objs): %.o: lua/src/lib/%.c $(luajit_lib_objs): %jit.o: lua/src/lib/%.c $(CROSS)$(CC) -c $(CFLAGS) $(LUA_CFLAGS) $< -o $@ $(lua_spawn_objs): lua/src/lib/lspawn.c - $(CROSS)$(CC) -c $(CFLAGS) $(LUA_CFLAGS) -std=c99 -pedantic -D_XOPEN_SOURCE \ - $(spawn_flags) $< -o $@ + $(CROSS)$(CC) -c $(CFLAGS) $(LUA_CFLAGS) -std=c99 -pedantic $(spawn_flags) \ + $< -o $@ luajit/src/libluajit.a: ; $(MAKE) -C luajit CC="$(CC) $(CFLAGS)" luajit/src/lua51.dll: $(MAKE) -C luajit HOST_CC="$(CC) -m32" CROSS=$(CROSS) TARGET_SYS=Windows @@ -201,13 +201,12 @@ luajit/src/libluajit.osx.a: $(MAKE) -C luajit CC="$(CC) -m32" CROSS=$(CROSS) TARGET_SYS=Darwin \ LUAJIT_A=$(notdir $@) || return 0 $(gtdialog_objs): gtdialog/gtdialog.c - $(CROSS)$(CC) -c $(CFLAGS) -std=c99 -pedantic -D_POSIX_C_SOURCE=200809L \ - $(gtdialog_flags) $< -o $@ + $(CROSS)$(CC) -c $(CFLAGS) -std=c99 -pedantic $(gtdialog_flags) $< -o $@ $(cdk_objs): %.o: cdk/%.c $(CROSS)$(CC) -c $(CFLAGS) -D_GNU_SOURCE -Itermkey -Icdk $(CURSES_CFLAGS) $< \ -o $@ $(termkey_objs): %.o: termkey/%.c - $(CROSS)$(CC) -c $(CFLAGS) -std=c99 $(termkey_flags) $< -o $@ + $(CROSS)$(CC) -c $(CFLAGS) -std=c99 $(CURSES_CFLAGS) $< -o $@ textadept_rc.o: textadept.rc ; $(CROSS)$(WINDRES) $< $@ # Target-specific variables. @@ -228,7 +227,6 @@ lspawn.o lspawnjit.o: spawn_flags = -DGTK $(GLIB_CFLAGS) $(gtdialog_objs): gtdialog_flags = $(plat_flag) -DNOHELP -DLIBRARY gtdialog.o: gtdialog_flags += $(GTK_CFLAGS) gtdialog-curses.o: gtdialog_flags += -Icdk $(CURSES_CFLAGS) -$(termkey_win32_objs): termkey_flags += $(CURSES_CFLAGS) # Lua 5.3 compatibility with LuaJIT. lbitlib.o linit.o: LUA_CFLAGS += -DLUA_COMPAT_BITLIB -DLUA_COMPAT_APIINTCASTS lutf8libjit.o: LUA_CFLAGS += -Ilua/src 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 <errno.h> #include <locale.h> @@ -17,7 +21,6 @@ #elif __APPLE__ #include <mach-o/dyld.h> #elif (__FreeBSD__ || __NetBSD__ || __OpenBSD__) -#define u_int unsigned int // 'u_int' undefined when _POSIX_SOURCE is defined #include <sys/types.h> #include <sys/sysctl.h> #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 |