Merge branches 'fix-out-of-range-memory', 'obey-configure' and 'other-improvements' into windows-mingw

This commit is contained in:
Ryan Pavlik 2011-10-31 10:53:05 -05:00
commit 5bf23bb05d
11 changed files with 69 additions and 41 deletions

View file

@ -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"
])

View file

@ -60,10 +60,10 @@ 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)
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
@ -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])

View file

@ -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();
}

View file

@ -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) {

View file

@ -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\""<<endl;
#endif // HAVE_SETLOCALE
#endif // defined(HAVE_SETLOCALE) && defined(NLS)
m_locale = "C";
#ifdef HAVE_SETLOCALE
#if defined(HAVE_SETLOCALE) && defined(NLS)
} else {
@ -102,7 +102,7 @@ I18n::I18n():m_multibyte(false), m_utf8_translate(false), m_catalog_fd((nl_catd)
if (index != string::npos)
m_locale.erase(0,index+1); //erase all characters starting up to index
}
#endif // HAVE_SETLOCALE
#endif // defined(HAVE_SETLOCALE) && defined(NLS)
}

View file

@ -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;

View file

@ -49,7 +49,9 @@
# include <string.h>
#endif
#ifdef HAVE_SYS_SELECT_H
# include <sys/select.h>
#endif
namespace FbTk {

View file

@ -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) {'; \

View file

@ -40,7 +40,10 @@
#include <iostream>
#include <sys/types.h>
#ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h>
#endif
#ifdef HAVE_CSTRING
#include <cstring>
#else

View file

@ -124,7 +124,9 @@
#include <sys/stat.h>
#endif // HAVE_SYS_STAT_H
#ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h>
#endif // HAVE_SYS_WAIT_H
#include <iostream>
#include <memory>

View file

@ -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[] = "-";
@ -220,12 +221,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";
}
@ -369,14 +370,15 @@ 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;
}
}
#ifdef HAVE_SYNC
if (sync_fs) {
sync();
}
#endif
}
@ -413,7 +415,9 @@ void updateConfigFilesIfNeeded(const std::string& rc_file) {
<< commandargs
<< "' failed." << endl;
}
#ifdef HAVE_SYNC
sync();
#endif // HAVE_SYNC
}
}