Skip to content

Commit

Permalink
Moved Linux-only define into Makefile and cleaned up Makefile.
Browse files Browse the repository at this point in the history
  • Loading branch information
orbitalquark committed Sep 30, 2022
1 parent 83b27a9 commit 1dbcff6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
18 changes: 8 additions & 10 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ $(call all-objs, $(textadept_objs)): CFLAGS += $(lua_flags) $(ta_flags)
$(call all-objs, $(textadept_gtk_objs)): CFLAGS += -DGTK $(gtk_flags)
$(call all-objs, $(textadept_curses_objs)): CFLAGS += -DCURSES -Iscintilla/curses -Itermkey -Icdk \
$(curses_flags)
# For readlink from unistd.h on Linux only.
$(textadept_gtk_objs): CFLAGS += -D_XOPEN_SOURCE=500

$(call all-objs, $(textadept_objs)): textadept.c ; $(build-cc)
$(textadept_rc_objs): textadept.rc ; $(WINDRES) $< $@
Expand All @@ -63,9 +65,7 @@ $(textadept_rc_objs): textadept.rc ; $(WINDRES) $< $@

sci_objs := $(call objs, scintilla/src/*.cxx)
sci_lexlib_objs := $(call objs, lexilla/lexlib/*.cxx)
sci_lexer_gtk_objs := $(call objs, Scintillua.cxx)
sci_lexer_curses_objs := $(call curses-objs, Scintillua.cxx)
sci_lexer_objs := $(sci_lexer_gtk_objs) $(sci_lexer_curses_objs)
sci_lexer_objs := $(call objs, Scintillua.cxx)
sci_gtk_objs := $(call objs, scintilla/gtk/*.cxx)
sci_gtk_c_objs := $(call objs, scintilla/gtk/*.c)
sci_curses_objs := $(call objs, scintilla/curses/*.cxx)
Expand All @@ -76,8 +76,6 @@ sci_flags := -pedantic -DSCI_LEXER -DNDEBUG -Iscintilla/include -Iscintilla/src
$(call all-objs, $(sci_objs)): CXXFLAGS += $(sci_flags)
$(call all-objs, $(sci_lexlib_objs)): CXXFLAGS += $(sci_flags)
$(call all-objs, $(sci_lexer_objs)): CXXFLAGS += $(sci_flags) $(lua_flags) -DNO_DLL
$(call all-objs, $(sci_lexer_gtk_objs)): CXXFLAGS += -DGTK
$(call all-objs, $(sci_lexer_curses_objs)): CXXFLAGS += -DCURSES $(curses_flags)
$(call all-objs, $(sci_gtk_objs)): CXXFLAGS += $(sci_flags) -DGTK $(gtk_flags)
$(call all-objs, $(sci_gtk_c_objs)): CFLAGS += $(gtk_flags)
$(call all-objs, $(sci_curses_objs)): CXXFLAGS += $(sci_flags) -DCURSES $(curses_flags)
Expand Down Expand Up @@ -179,11 +177,11 @@ endif

# Compilers and platform-specific flags for all objects.

common_objs := $(sci_objs) $(sci_lexlib_objs) $(lua_objs) $(lua_lib_objs)
gui_objs := $(sci_lexer_gtk_objs) $(sci_gtk_objs) $(sci_gtk_c_objs) $(textadept_gtk_objs) \
$(lua_oslib_gtk_objs) $(gtdialog_gtk_objs)
curses_objs := $(sci_lexer_curses_objs) $(sci_curses_objs) $(textadept_curses_objs) \
$(lua_oslib_curses_objs) $(gtdialog_curses_objs) $(termkey_objs) $(cdk_objs)
common_objs := $(sci_objs) $(sci_lexlib_objs) $(sci_lexer_objs) $(lua_objs) $(lua_lib_objs)
gui_objs := $(sci_gtk_objs) $(sci_gtk_c_objs) $(textadept_gtk_objs) $(lua_oslib_gtk_objs) \
$(gtdialog_gtk_objs)
curses_objs := $(sci_curses_objs) $(textadept_curses_objs) $(lua_oslib_curses_objs) \
$(gtdialog_curses_objs) $(termkey_objs) $(cdk_objs)

linux_objs := $(common_objs) $(gui_objs) $(curses_objs) $(termkey_unix_objs)
win_objs := $(call win-objs, $(common_objs) $(gui_objs) $(curses_objs)) $(termkey_win_objs) \
Expand Down
6 changes: 1 addition & 5 deletions src/textadept.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
// Copyright 2007-2022 Mitchell. See LICENSE.

#if __linux__
#define _XOPEN_SOURCE 500 // for readlink from unistd.h
#endif

// Library includes.
#include <errno.h>
#include <limits.h> // for MB_LEN_MAX
Expand Down Expand Up @@ -720,7 +716,7 @@ static int goto_view(lua_State *L) {
if (lua_isnumber(L, 1)) {
lua_getfield(L, LUA_REGISTRYINDEX, VIEWS);
lua_pushview(L, focused_view);
int n = ((lua_gettable(L, -2), lua_tointeger(L, -1)) + lua_tointeger(L, 1)) %lua_rawlen(L, -2);
int n = ((lua_gettable(L, -2), lua_tointeger(L, -1)) + lua_tointeger(L, 1)) % lua_rawlen(L, -2);
if (n == 0) n = lua_rawlen(L, -2);
lua_rawgeti(L, -2, n), lua_replace(L, 1); // index
}
Expand Down

0 comments on commit 1dbcff6

Please sign in to comment.