From f47ed1be51b079d9616b4d93a4181c89f3006d73 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Fri, 28 Oct 2011 11:59:28 -0500 Subject: FbTk/I18n.cc: Constructor should also check defined(NLS) --- src/FbTk/I18n.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/FbTk/I18n.cc b/src/FbTk/I18n.cc index 81ff078..3daa2e9 100644 --- a/src/FbTk/I18n.cc +++ b/src/FbTk/I18n.cc @@ -72,17 +72,17 @@ void NLSInit(const char *catalog) { I18n::I18n():m_multibyte(false), m_utf8_translate(false), m_catalog_fd((nl_catd)(-1)) { -#ifdef HAVE_SETLOCALE +#if defined(HAVE_SETLOCALE) && defined(NLS) //make sure we don't get 0 to m_locale string char *temp = setlocale(LC_MESSAGES, ""); m_locale = ( temp ? temp : ""); if (m_locale.empty()) { cerr<<"Warning: Failed to set locale, reverting to \"C\""< Date: Fri, 28 Oct 2011 12:00:36 -0500 Subject: fluxbox.cc: check HAVE_SYS_WAIT_H --- src/fluxbox.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/fluxbox.cc b/src/fluxbox.cc index 2e5e373..ff44e9f 100644 --- a/src/fluxbox.cc +++ b/src/fluxbox.cc @@ -124,7 +124,9 @@ #include #endif // HAVE_SYS_STAT_H +#ifdef HAVE_SYS_WAIT_H #include +#endif // HAVE_SYS_WAIT_H #include #include -- cgit v0.11.2 From 97b48ccb12a56512a7267462750cff3f18faa715 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Fri, 28 Oct 2011 12:15:32 -0500 Subject: configure.in: Check for sync() --- configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.in b/configure.in index 6e4a53c..60099e2 100644 --- a/configure.in +++ b/configure.in @@ -63,7 +63,7 @@ AC_FUNC_STAT AC_CHECK_FUNCS(basename, , AC_CHECK_LIB(gen, basename, LIBS="$LIBS -lgen")) AC_CHECK_FUNCS(catclose catgets catopen getpid gettimeofday memset mkdir \ nl_langinfo putenv regcomp select setenv setlocale sigaction snprintf \ - sqrt strcasecmp strcasestr strchr strstr strtol strtoul vsnprintf) + sqrt strcasecmp strcasestr strchr strstr strtol strtoul sync vsnprintf) dnl The autoconf test for strftime is broken now (due to gcc 3.3 bug?): dnl Gcc 3.3 testprog = ``extern "C" char strftime;'', build with g++ test.cc -- cgit v0.11.2 From 4bad431c90c72c945d9ce7053775d66be1e563ca Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Fri, 28 Oct 2011 12:15:48 -0500 Subject: main.cc: Only sync() if we can. --- src/main.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main.cc b/src/main.cc index c47e1d8..aab583f 100644 --- a/src/main.cc +++ b/src/main.cc @@ -373,10 +373,11 @@ void setupConfigFiles(const std::string& dirname, const std::string& rc) { sync_fs = true; } } - +#ifdef HAVE_SYNC if (sync_fs) { sync(); } +#endif } @@ -413,7 +414,9 @@ void updateConfigFilesIfNeeded(const std::string& rc_file) { << commandargs << "' failed." << endl; } +#ifdef HAVE_SYNC sync(); +#endif // HAVE_SYNC } } -- cgit v0.11.2 From 60c964a4d91f698b9eb1d66def9d8d7f1c691b78 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Fri, 28 Oct 2011 12:17:03 -0500 Subject: RootTheme.cc: Obey HAVE_SYS_WAIT_H --- src/RootTheme.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/RootTheme.cc b/src/RootTheme.cc index d303834..a2aa4a8 100644 --- a/src/RootTheme.cc +++ b/src/RootTheme.cc @@ -40,7 +40,10 @@ #include #include +#ifdef HAVE_SYS_WAIT_H #include +#endif + #ifdef HAVE_CSTRING #include #else -- cgit v0.11.2 From f40be36f7567a78423f93bb291ef61fe62f5337a Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Mon, 31 Oct 2011 10:47:59 -0500 Subject: FbTk/Timer.cc: Check HAVE_SYS_SELECT_H --- src/FbTk/Timer.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/FbTk/Timer.cc b/src/FbTk/Timer.cc index 9b3fe8c..4d9f54f 100644 --- a/src/FbTk/Timer.cc +++ b/src/FbTk/Timer.cc @@ -49,7 +49,9 @@ # include #endif -#include +#ifdef HAVE_SYS_SELECT_H +# include +#endif namespace FbTk { -- cgit v0.11.2 From cc1193ef0caaf5de9d7d1f443a7e90f44f5277a1 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Fri, 28 Oct 2011 11:59:51 -0500 Subject: FbTk/SignalHandler.cc: Use HAVE_SIGACTION, with signal() fallback This fixes platforms without sigaction, like Windows. --- src/FbTk/SignalHandler.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/FbTk/SignalHandler.cc b/src/FbTk/SignalHandler.cc index a0a4c4c..5f06210 100644 --- a/src/FbTk/SignalHandler.cc +++ b/src/FbTk/SignalHandler.cc @@ -46,6 +46,7 @@ bool SignalHandler::registerHandler(int signum, SignalEventHandler *eh, if (oldhandler_ret != 0) *oldhandler_ret = s_signal_handler[signum]; +#ifdef HAVE_SIGACTION struct sigaction sa; // set callback sa.sa_handler = SignalHandler::handleSignal; @@ -54,7 +55,12 @@ bool SignalHandler::registerHandler(int signum, SignalEventHandler *eh, if (sigaction(signum, &sa, 0) == -1) return false; - +#else + // Fallback code for Windows and other platforms lacking sigaction. + if (signal(signum, &SignalHandler::handleSignal) == SIG_ERR) { + return false; + } +#endif s_signal_handler[signum] = eh; return true; -- cgit v0.11.2 From 75c6cee969f6d88f7373d4cac00d1c670e0b76e6 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Fri, 28 Oct 2011 11:58:50 -0500 Subject: FbTk/FileUtil.cc: Use only file masks defined. Needed for mingw-cross-env --- src/FbTk/FileUtil.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/FbTk/FileUtil.cc b/src/FbTk/FileUtil.cc index 5de560b..c92b336 100644 --- a/src/FbTk/FileUtil.cc +++ b/src/FbTk/FileUtil.cc @@ -63,9 +63,14 @@ bool FileUtil::isExecutable(const char* filename) { if (!filename || stat(filename, &buf)) return false; - return buf.st_mode & S_IXUSR || - buf.st_mode & S_IXGRP || - buf.st_mode & S_IXOTH; + return buf.st_mode & S_IXUSR +#ifdef S_IXGRP + || buf.st_mode & S_IXGRP +#endif +#ifdef S_IXOTH + || buf.st_mode & S_IXOTH +#endif + ; } bool FileUtil::copyFile(const char* from, const char* to) { -- cgit v0.11.2 From 9a2c6f94b8a8c2b078084b552acc58909e831a07 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Fri, 28 Oct 2011 14:06:10 -0500 Subject: configure.in, acinclude.m4: always pre-pend new libs. --- acinclude.m4 | 2 +- configure.in | 38 +++++++++++++++++++------------------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/acinclude.m4 b/acinclude.m4 index ca5a789..a233530 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -227,5 +227,5 @@ AC_DEFUN([AM_PATH_XFT], CFLAGS="$CFLAGS $XFT_CFLAGS" CXXFLAGS="$CXXFLAGS $XFT_CFLAGS" - LIBS="$LIBS $XFT_LIBS" + LIBS="$XFT_LIBS $LIBS" ]) diff --git a/configure.in b/configure.in index 6e4a53c..d2014d9 100644 --- a/configure.in +++ b/configure.in @@ -60,7 +60,7 @@ AC_FUNC_REALLOC AC_FUNC_SELECT_ARGTYPES AC_FUNC_STAT -AC_CHECK_FUNCS(basename, , AC_CHECK_LIB(gen, basename, LIBS="$LIBS -lgen")) +AC_CHECK_FUNCS(basename, , AC_CHECK_LIB(gen, basename, LIBS="-lgen $LIBS")) AC_CHECK_FUNCS(catclose catgets catopen getpid gettimeofday memset mkdir \ nl_langinfo putenv regcomp select setenv setlocale sigaction snprintf \ sqrt strcasecmp strcasestr strchr strstr strtol strtoul vsnprintf) @@ -130,13 +130,13 @@ if test "x$ac_cv_header_iconv_h" = "xyes"; then AC_CHECK_LIB([iconv], [iconv_open], [ - LIBS="$LIBS -liconv" + LIBS="-liconv $LIBS" ], []) AC_CHECK_LIB([iconv], [libiconv_open], [ - LIBS="$LIBS -liconv" + LIBS="-liconv $LIBS" ], []) @@ -163,8 +163,8 @@ dnl Check if iconv uses const in prototype declaration fi fi -AC_CHECK_LIB(nsl, t_open, LIBS="$LIBS -lnsl") -AC_CHECK_LIB(socket, socket, LIBS="$LIBS -lsocket") +AC_CHECK_LIB(nsl, t_open, LIBS="-lnsl $LIBS") +AC_CHECK_LIB(socket, socket, LIBS="-lsocket $LIBS") dnl Check for X headers and libraries AC_PATH_X @@ -177,18 +177,18 @@ test x$x_libraries = "x" && x_libraries="/usr/lib" CFLAGS="$CFLAGS $X_CFLAGS" CXXFLAGS="$CXXFLAGS $X_CFLAGS" -LIBS="$LIBS $X_LIBS" +LIBS="$X_LIBS $LIBS" LDFLAGS="$LDFLAGS $LIBS $X_PRE_LIBS" dnl Check for required functions in -lX11 AC_CHECK_LIB(X11, XOpenDisplay, - LIBS="$LIBS -lX11", + LIBS="-lX11 $LIBS", AC_MSG_ERROR([Could not find XOpenDisplay in -lX11.]) ) -LIBS="$LIBS $X_EXTRA_LIBS" +LIBS="$X_EXTRA_LIBS $LIBS" -AC_CHECK_LIB(xpg4, setlocale, LIBS="$LIBS -lxpg4") +AC_CHECK_LIB(xpg4, setlocale, LIBS="-lxpg4 $LIBS") AC_CHECK_PROGS(gencat_cmd, gencat) if test x$gencat_cmd = "x"; then @@ -397,14 +397,14 @@ AC_ARG_ENABLE( AC_MSG_RESULT([yes]) AC_CHECK_LIB(Xrender, XRenderCreatePicture, AC_DEFINE(HAVE_XRENDER, 1, "Xrender support") - LIBS="$LIBS -lXrender") + LIBS="-lXrender $LIBS") else AC_MSG_RESULT([no]) fi, AC_MSG_RESULT([yes]) AC_CHECK_LIB(Xrender, XRenderCreatePicture, AC_DEFINE(HAVE_XRENDER, 1, "Xrender support") - LIBS="$LIBS -lXrender") + LIBS="-lXrender $LIBS") ) XPM=false @@ -417,7 +417,7 @@ AC_ARG_ENABLE( AC_CHECK_LIB(Xpm, XpmReadFileToPixmap, AC_DEFINE(HAVE_XPM, 1, "Xpm support") XPM=true - LIBS="$LIBS -lXpm") + LIBS="-lXpm $LIBS") else AC_MSG_RESULT([no]) fi, @@ -425,7 +425,7 @@ AC_ARG_ENABLE( AC_CHECK_LIB(Xpm, XpmReadFileToPixmap, AC_DEFINE(HAVE_XPM, 1, "Xpm support") XPM=true - LIBS="$LIBS -lXpm") + LIBS="-lXpm $LIBS") ) AM_CONDITIONAL(XPM, test x$XPM = xtrue) @@ -445,7 +445,7 @@ if test x$enable_imlib2 = "xyes"; then AC_DEFINE(HAVE_IMLIB2, [], [Imlib2 support]) IMLIB2_LIBS=`imlib2-config --libs` IMLIB2_CFLAGS=`imlib2-config --cflags` - LIBS="$LIBS $IMLIB2_LIBS" + LIBS="$IMLIB2_LIBS $LIBS" CXXFLAGS="$CXXFLAGS $IMLIB2_CFLAGS" ], [ AC_MSG_RESULT(no)] ) @@ -494,7 +494,7 @@ if test "x$enableval" = "xyes"; then , XineramaQueryScreens(0, 0), AC_MSG_RESULT([yes]) AC_DEFINE(XINERAMA, [1], [Define to 1 if you have XINERAMA]) - LIBS="$LIBS -lXinerama", + LIBS="-lXinerama $LIBS", AC_MSG_RESULT([no]))) else AC_MSG_RESULT([no]) @@ -519,7 +519,7 @@ if test "x$enableval" = "xyes"; then , long foo = ShapeSet, AC_MSG_RESULT([yes]) AC_DEFINE(SHAPE, [1], [Define to 1 if you have SHAPE]) - LIBS="$LIBS -lXext" + LIBS="-lXext $LIBS" FEATURES="$FEATURES XShape", AC_MSG_RESULT([no]))) else @@ -547,7 +547,7 @@ if test "x$enableval" = "xyes"; then , XRRQueryExtension(0, 0, 0), AC_MSG_RESULT([yes]) AC_DEFINE(HAVE_RANDR, [1], [Define to 1 if you have RANDR]) - LIBS="$LIBS -lXrandr", + LIBS="-lXrandr $LIBS", AC_MSG_RESULT([no]))) else AC_MSG_RESULT([no]) @@ -571,7 +571,7 @@ if test "x$enableval" = "xyes"; then , XRRUpdateConfiguration(0), AC_MSG_RESULT([yes]) AC_DEFINE(HAVE_RANDR1_2, [1], [Define to 1 if you have RANDR 1.2]) - LIBS="$LIBS -lXrandr", + LIBS="-lXrandr $LIBS", AC_MSG_RESULT([no]))) else AC_MSG_RESULT([no]) @@ -613,7 +613,7 @@ if test "x$enableval" = "xyes"; then , fribidi_version_info, AC_MSG_RESULT([yes]) AC_DEFINE(HAVE_FRIBIDI, [1], [Define to 1 if you have FRIBIDI]) - LIBS="$LIBS -lfribidi", + LIBS="-lfribidi $LIBS", AC_MSG_RESULT([no]))) else AC_MSG_RESULT([no]) -- cgit v0.11.2 From fa63fcdc669efb868ca8979374eca26d82708c38 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Fri, 28 Oct 2011 15:44:46 -0500 Subject: main.cc: Check getenv output better. Windows returns pointers to empty strings for non-existent env vars. --- src/main.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cc b/src/main.cc index c47e1d8..eaa732d 100644 --- a/src/main.cc +++ b/src/main.cc @@ -220,12 +220,12 @@ struct Options { const char* env; env = getenv("DISPLAY"); - if (env) { + if (env && strlen(env) > 0) { session_display.assign(env); } env = getenv("HOME"); - if (env) { + if (env && strlen(env) > 0) { rc_path.assign(std::string(env) + "/." + realProgramName("fluxbox")); rc_file = rc_path + "/init"; } -- cgit v0.11.2 From 7510c2d173009372f81274e2db666f268e3e5ac1 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Fri, 28 Oct 2011 16:15:32 -0500 Subject: src/Makefile.am: Add warning to defaults.cc as well --- src/Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Makefile.am b/src/Makefile.am index 8c204db..1a04e4e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -63,6 +63,7 @@ defaults.hh: Makefile defaults.cc: force @( \ GITDIR=$(top_srcdir)/.git; \ + echo '// This file is generated from Makefile. Do not edit!'; \ echo '#include "defaults.hh"'; \ echo ''; \ echo 'std::string realProgramName(const std::string& name) {'; \ -- cgit v0.11.2 From d5b58a8033233743b2ff1a6e88eb2d75b54c66ec Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Mon, 31 Oct 2011 10:17:28 -0500 Subject: main.cc: Use expandFilename for default paths --- src/main.cc | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main.cc b/src/main.cc index eaa732d..1e80c4b 100644 --- a/src/main.cc +++ b/src/main.cc @@ -34,6 +34,7 @@ #include "FbTk/I18n.hh" #include "FbTk/CommandParser.hh" #include "FbTk/FileUtil.hh" +#include "FbTk/StringUtil.hh" //use GNU extensions #ifndef _GNU_SOURCE @@ -114,22 +115,22 @@ static void showInfo(ostream &ostr) { ostr <<_FB_CONSOLETEXT(Common, DefaultMenuFile, " menu", "default menu file (right aligned - make sure same width as other default values)") << ": " - << DEFAULTMENU << endl; + << FbTk::StringUtil::expandFilename(DEFAULTMENU) << endl; ostr << _FB_CONSOLETEXT(Common, DefaultStyle, " style", "default style (right aligned - make sure same width as other default values)") << ": " - << DEFAULTSTYLE << endl; + << FbTk::StringUtil::expandFilename(DEFAULTSTYLE) << endl; ostr << _FB_CONSOLETEXT(Common, DefaultKeyFile, " keys", "default key file (right aligned - make sure same width as other default values)") << ": " - << DEFAULTKEYSFILE << endl; + << FbTk::StringUtil::expandFilename(DEFAULTKEYSFILE) << endl; ostr << _FB_CONSOLETEXT(Common, DefaultInitFile, " init", "default init file (right aligned - make sure same width as other default values)") << ": " - << DEFAULT_INITFILE << endl; + << FbTk::StringUtil::expandFilename(DEFAULT_INITFILE) << endl; #ifdef NLS ostr << _FB_CONSOLETEXT(Common, DefaultLocalePath, " nls", "location for localization files (right aligned - make sure same width as other default values)") << ": " - << LOCALEPATH << endl; + << FbTk::StringUtil::expandFilename(LOCALEPATH) << endl; #endif const char NOT[] = "-"; @@ -369,7 +370,7 @@ void setupConfigFiles(const std::string& dirname, const std::string& rc) { // copy default files if needed for (size_t i = 0; i < nr_of_cfiles; ++i) { if (cfiles[i].create_file) { - FbTk::FileUtil::copyFile(cfiles[i].default_name, cfiles[i].filename.c_str()); + FbTk::FileUtil::copyFile(FbTk::StringUtil::expandFilename(cfiles[i].default_name).c_str(), cfiles[i].filename.c_str()); sync_fs = true; } } -- cgit v0.11.2 From afa870802ba4296a4ce8c2b9185250f8da1124ca Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Mon, 31 Oct 2011 10:17:59 -0500 Subject: FbTk/App.cc: make startup failure easier to diagnose --- src/FbTk/App.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/FbTk/App.cc b/src/FbTk/App.cc index 8157839..f494a0e 100644 --- a/src/FbTk/App.cc +++ b/src/FbTk/App.cc @@ -60,8 +60,13 @@ App::App(const char *displayname):m_done(false), m_display(0) { if (displayname != 0 && displayname[0] == '\0') displayname = 0; m_display = XOpenDisplay(displayname); - if (!m_display) - throw std::string("Couldn't connect to XServer"); + if (!m_display) { + if (displayname) { + throw std::string("Couldn't connect to XServer") + displayname; + } else { + throw std::string("Couldn't connect to XServer passing null display"); + } + } FbStringUtil::init(); } -- cgit v0.11.2