diff --git a/configure.ac b/configure.ac index 19f51764..fb9fbbb6 100644 --- a/configure.ac +++ b/configure.ac @@ -22,6 +22,7 @@ AC_CANONICAL_HOST PLATFORM="unknown" AS_CASE([$host_os], [freebsd*], [PLATFORM="freebsd"], + [netbsd*], [PLATFORM="netbsd"], [openbsd*], [PLATFORM="openbsd"], [darwin*], [PLATFORM="osx"], [cygwin], [PLATFORM="cygwin"], @@ -81,7 +82,7 @@ elif test "x$enable_python_plugins" != xno; then rm -f Python.framework ln -s $PYTHON_FRAMEWORK Python.framework ]) AC_CHECK_PROG(PYTHON_CONFIG_EXISTS, python-config, yes, no) - if test "$PYTHON_CONFIG_EXISTS" == "yes"; then + if test "$PYTHON_CONFIG_EXISTS" = "yes"; then AX_PYTHON_DEVEL AM_CONDITIONAL([BUILD_PYTHON_API], [true]) AC_DEFINE([HAVE_PYTHON], [1], [Python support]) @@ -106,9 +107,9 @@ else if test "x$enable_plugins" = xno; then AM_CONDITIONAL([BUILD_C_API], [false]) elif test "x$enable_c_plugins" != xno; then - # libdl doesn't exist as a separate library in OpenBSD/FreeBSD and is + # libdl doesn't exist as a separate library in the BSDs and is # provided in the standard libraries. - AS_IF([test "x$PLATFORM" = xopenbsd -o "x$PLATFORM" = xfreebsd], + AS_IF([test "x$PLATFORM" = xopenbsd -o "x$PLATFORM" = xfreebsd -o "x$PLATFORM" = xnetbsd], [AM_CONDITIONAL([BUILD_C_API], [true]) AC_DEFINE([HAVE_C], [1], [C support])], [AC_CHECK_LIB([dl], [main], [AM_CONDITIONAL([BUILD_C_API], [true]) LIBS="$LIBS -ldl" AC_DEFINE([HAVE_C], [1], [C support])], @@ -160,21 +161,23 @@ AC_LINK_IFELSE([AC_LANG_SOURCE([[ [AC_MSG_RESULT([yes])], [AC_MSG_ERROR([${XMPP_LIB} is broken, check config.log for details])]) -### Check for ncurses library +### Check for curses library PKG_CHECK_MODULES([ncursesw], [ncursesw], - [NCURSES_CFLAGS="$ncursesw_CFLAGS"; NCURSES_LIBS="$ncursesw_LIBS"; NCURSES="ncursesw"], + [NCURSES_CFLAGS="$ncursesw_CFLAGS"; NCURSES_LIBS="$ncursesw_LIBS"; CURSES="ncursesw"], [PKG_CHECK_MODULES([ncurses], [ncurses], - [NCURSES_CFLAGS="$ncurses_CFLAGS"; NCURSES_LIBS="$ncurses_LIBS"; NCURSES="ncurses"], + [NCURSES_CFLAGS="$ncurses_CFLAGS"; NCURSES_LIBS="$ncurses_LIBS"; CURSES="ncurses"], [AC_CHECK_LIB([ncursesw], [main], [], [AC_CHECK_LIB([ncurses], [main], [], - [AC_MSG_ERROR([ncurses is required for profanity])])])])]) + [AC_CHECK_LIB([curses], [main], + [LIBS="$LIBS -lcurses"; CURSES="curses"], + [AC_MSG_ERROR([ncurses or curses is required for profanity])])])])])]) AM_CPPFLAGS="$AM_CPPFLAGS $NCURSES_CFLAGS" LIBS="$NCURSES_LIBS $LIBS" -### Check wide characters support in ncurses library +### Check wide characters support in curses library CFLAGS_RESTORE="$CFLAGS" CFLAGS="$CFLAGS $NCURSES_CFLAGS" -AC_CACHE_CHECK([for wget_wch support in $NCURSES], ncurses_cv_wget_wch, +AC_CACHE_CHECK([for wget_wch support in $CURSES], ncurses_cv_wget_wch, [AC_LINK_IFELSE([AC_LANG_SOURCE([ void wget_wch(void); int main() { @@ -354,6 +357,7 @@ AC_CHECK_LIB([expect], [exp_expectl], [AM_CONDITIONAL([HAVE_EXPECT], [true])], ### Check for ncursesw/ncurses.h first, Arch linux uses ncurses.h for ncursesw AC_CHECK_HEADERS([ncursesw/ncurses.h], [], []) AC_CHECK_HEADERS([ncurses.h], [], []) +AC_CHECK_HEADERS([curses.h], [], []) ### Default parameters AM_CFLAGS="-Wall -Wno-deprecated-declarations -std=gnu99" diff --git a/src/common.c b/src/common.c index 5825c0ca..d339a37a 100644 --- a/src/common.c +++ b/src/common.c @@ -54,6 +54,8 @@ #include #elif HAVE_NCURSES_H #include +#elif HAVE_CURSES_H +#include #endif #include "log.h" diff --git a/src/config/color.c b/src/config/color.c index 790febc7..63089fd8 100644 --- a/src/config/color.c +++ b/src/config/color.c @@ -46,6 +46,8 @@ #include #elif HAVE_NCURSES_H #include +#elif HAVE_CURSES_H +#include #endif #include "config/color.h" diff --git a/src/config/theme.c b/src/config/theme.c index 147b31c2..2ec256ad 100644 --- a/src/config/theme.c +++ b/src/config/theme.c @@ -45,6 +45,8 @@ #include #elif HAVE_NCURSES_H #include +#elif HAVE_CURSES_H +#include #endif #include "common.h" diff --git a/src/ui/buffer.c b/src/ui/buffer.c index f78168ac..58399a69 100644 --- a/src/ui/buffer.c +++ b/src/ui/buffer.c @@ -46,6 +46,8 @@ #include #elif HAVE_NCURSES_H #include +#elif HAVE_CURSES_H +#include #endif #include "ui/window.h" diff --git a/src/ui/console.c b/src/ui/console.c index bd149f3d..a9966bcd 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -42,6 +42,8 @@ #include #elif HAVE_NCURSES_H #include +#elif HAVE_CURSES_H +#include #endif #include "common.h" diff --git a/src/ui/core.c b/src/ui/core.c index d4893f67..4bbb23de 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -55,6 +55,8 @@ #include #elif HAVE_NCURSES_H #include +#elif HAVE_CURSES_H +#include #endif #include "log.h" diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c index 45cd3313..5da6ae97 100644 --- a/src/ui/inputwin.c +++ b/src/ui/inputwin.c @@ -52,6 +52,8 @@ #include #elif HAVE_NCURSES_H #include +#elif HAVE_CURSES_H +#include #endif #include "profanity.h" @@ -306,7 +308,9 @@ _inp_win_update_virtual(void) { int wcols = getmaxx(stdscr); int row = screen_inputwin_row(); - pnoutrefresh(inp_win, 0, pad_start, row, 0, row, wcols - 2); + if (inp_win != NULL) { + pnoutrefresh(inp_win, 0, pad_start, row, 0, row, wcols - 2); + } } static void diff --git a/src/ui/rosterwin.c b/src/ui/rosterwin.c index 3375414c..7c4468d8 100644 --- a/src/ui/rosterwin.c +++ b/src/ui/rosterwin.c @@ -95,7 +95,10 @@ rosterwin_roster(void) ProfLayoutSplit* layout = (ProfLayoutSplit*)console->layout; assert(layout->memcheck == LAYOUT_SPLIT_MEMCHECK); - werase(layout->subwin); + + if (layout->subwin != NULL) { + werase(layout->subwin); + } char* roomspos = prefs_get_string(PREF_ROSTER_ROOMS_POS); if (prefs_get_boolean(PREF_ROSTER_ROOMS) && (g_strcmp0(roomspos, "first") == 0)) { @@ -1106,9 +1109,11 @@ _rosterwin_contacts_header(ProfLayoutSplit* layout, const char* const title, GSL gboolean wrap = prefs_get_boolean(PREF_ROSTER_WRAP); - wattron(layout->subwin, theme_attrs(THEME_ROSTER_HEADER)); - win_sub_print(layout->subwin, header->str, FALSE, wrap, 1); - wattroff(layout->subwin, theme_attrs(THEME_ROSTER_HEADER)); + if (layout->subwin != NULL) { + wattron(layout->subwin, theme_attrs(THEME_ROSTER_HEADER)); + win_sub_print(layout->subwin, header->str, FALSE, wrap, 1); + wattroff(layout->subwin, theme_attrs(THEME_ROSTER_HEADER)); + } g_string_free(header, TRUE); } @@ -1166,9 +1171,11 @@ _rosterwin_rooms_header(ProfLayoutSplit* layout, GList* rooms, char* title) gboolean wrap = prefs_get_boolean(PREF_ROSTER_WRAP); - wattron(layout->subwin, theme_attrs(THEME_ROSTER_HEADER)); - win_sub_print(layout->subwin, header->str, FALSE, wrap, 1); - wattroff(layout->subwin, theme_attrs(THEME_ROSTER_HEADER)); + if (layout->subwin != NULL) { + wattron(layout->subwin, theme_attrs(THEME_ROSTER_HEADER)); + win_sub_print(layout->subwin, header->str, FALSE, wrap, 1); + wattroff(layout->subwin, theme_attrs(THEME_ROSTER_HEADER)); + } g_string_free(header, TRUE); } diff --git a/src/ui/screen.c b/src/ui/screen.c index 8a676082..a7be6c2a 100644 --- a/src/ui/screen.c +++ b/src/ui/screen.c @@ -39,6 +39,8 @@ #include #elif HAVE_NCURSES_H #include +#elif HAVE_CURSES_H +#include #endif #include "config/preferences.h" diff --git a/src/ui/statusbar.c b/src/ui/statusbar.c index 146cc1ea..3dfdf086 100644 --- a/src/ui/statusbar.c +++ b/src/ui/statusbar.c @@ -44,6 +44,8 @@ #include #elif HAVE_NCURSES_H #include +#elif HAVE_CURSES_H +#include #endif #include "config/theme.h" diff --git a/src/ui/win_types.h b/src/ui/win_types.h index d4196111..7beaca5f 100644 --- a/src/ui/win_types.h +++ b/src/ui/win_types.h @@ -45,6 +45,8 @@ #include #elif HAVE_NCURSES_H #include +#elif HAVE_CURSES_H +#include #endif #include "tools/autocomplete.h" diff --git a/src/ui/window.c b/src/ui/window.c index 06194012..5a1a90dc 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -48,6 +48,8 @@ #include #elif HAVE_NCURSES_H #include +#elif HAVE_CURSES_H +#include #endif #include "log.h" @@ -1861,7 +1863,12 @@ win_sub_print(WINDOW* win, char* msg, gboolean newline, gboolean wrap, int inden void win_sub_newline_lazy(WINDOW* win) { - int curx = getcurx(win); + int curx; + + if (win == NULL) { + return; + } + curx = getcurx(win); if (curx > 0) { int cury = getcury(win); wmove(win, cury + 1, 0); diff --git a/src/ui/window.h b/src/ui/window.h index 17316b05..c731d19b 100644 --- a/src/ui/window.h +++ b/src/ui/window.h @@ -45,6 +45,8 @@ #include #elif HAVE_NCURSES_H #include +#elif HAVE_CURSES_H +#include #endif #include "ui/ui.h"