diff --git a/Makefile.am b/Makefile.am index 17dd8235..4802e0b8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -171,7 +171,7 @@ twisterd_LDFLAGS = @OPENSSL_LDFLAGS@ @DB_CXX_LDFLAGS@ twisterd_DEPENDENCIES = $(LEVELDB_LIB) twisterd_LDADD = $(LEVELDB_LIB) $(UPNP_LIB) \ - @BOOST_SYSTEM_LIB@ @BOOST_FILESYSTEM_LIB@ @BOOST_PROGRAM_OPTIONS_LIB@ @BOOST_THREAD_LIB@ @BOOST_CHRONO_LIB@ \ + @BOOST_SYSTEM_LIB@ @BOOST_FILESYSTEM_LIB@ @BOOST_PROGRAM_OPTIONS_LIB@ @BOOST_THREAD_LIB@ @BOOST_CHRONO_LIB@ @BOOST_LOCALE_LIB@ \ @DB_CXX_LIBS@ @OPENSSL_LIBS@ AM_CPPFLAGS = -ftemplate-depth-100 -DBOOST_SPIRIT_THREADSAFE -D_FILE_OFFSET_BITS=64 \ diff --git a/configure.ac b/configure.ac index 9319a5e4..446228f8 100644 --- a/configure.ac +++ b/configure.ac @@ -91,6 +91,7 @@ AX_BOOST_FILESYSTEM() AX_BOOST_PROGRAM_OPTIONS() AX_BOOST_THREAD() AX_BOOST_CHRONO() +AX_BOOST_LOCALE() ############################################################################### # Checking for Berkeley DB C++ @@ -771,6 +772,7 @@ Boost libraries: boost.filesystem: ${BOOST_FILESYSTEM_LIB} boost.program_opts: ${BOOST_PROGRAM_OPTIONS_LIB} boost.thread: ${BOOST_THREAD_LIB} + boost.locale: ${BOOST_LOCALE_LIB} Berkeley DB C++ library: header: ${DB_CXX_HEADER} diff --git a/m4/ax_boost_locale.m4 b/m4/ax_boost_locale.m4 new file mode 100644 index 00000000..b6a97b23 --- /dev/null +++ b/m4/ax_boost_locale.m4 @@ -0,0 +1,118 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_boost_locale.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_BOOST_LOCALE +# +# DESCRIPTION +# +# Test for System library from the Boost C++ libraries. The macro requires +# a preceding call to AX_BOOST_BASE. Further documentation is available at +# . +# +# This macro calls: +# +# AC_SUBST(BOOST_LOCALE_LIB) +# +# And sets: +# +# HAVE_BOOST_LOCALE +# +# LICENSE +# +# Copyright (c) 2012 Xiyue Deng +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 1 + +AC_DEFUN([AX_BOOST_LOCALE], +[ + AC_ARG_WITH([boost-locale], + AS_HELP_STRING([--with-boost-locale@<:@=special-lib@:>@], + [use the Locale library from boost - it is possible to specify a certain library for the linker + e.g. --with-boost-locale=boost_locale-gcc-mt ]), + [ + if test "$withval" = "no"; then + want_boost="no" + elif test "$withval" = "yes"; then + want_boost="yes" + ax_boost_user_locale_lib="" + else + want_boost="yes" + ax_boost_user_locale_lib="$withval" + fi + ], + [want_boost="yes"] + ) + + if test "x$want_boost" = "xyes"; then + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_BUILD]) + CPPFLAGS_SAVED="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" + export CPPFLAGS + + LDFLAGS_SAVED="$LDFLAGS" + LDFLAGS="$LDFLAGS $BOOST_LDFLAGS" + export LDFLAGS + + AC_CACHE_CHECK(whether the Boost::Locale library is available, + ax_cv_boost_locale, + [AC_LANG_PUSH([C++]) + CXXFLAGS_SAVE=$CXXFLAGS + + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include ]], + [[boost::locale::generator gen;]])], + ax_cv_boost_locale=yes, ax_cv_boost_locale=no) + CXXFLAGS=$CXXFLAGS_SAVE + AC_LANG_POP([C++]) + ]) + if test "x$ax_cv_boost_locale" = "xyes"; then + AC_SUBST(BOOST_CPPFLAGS) + + AC_DEFINE(HAVE_BOOST_LOCALE,,[define if the Boost::Locale library is available]) + BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'` + + LDFLAGS_SAVE=$LDFLAGS + if test "x$ax_boost_user_locale_lib" = "x"; then + for libextension in `ls $BOOSTLIBDIR/libboost_locale*.so* $BOOSTLIBDIR/libboost_locale*.dylib* $BOOSTLIBDIR/libboost_locale*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_locale.*\)\.so.*$;\1;' -e 's;^lib\(boost_locale.*\)\.dylib.*$;\1;' -e 's;^lib\(boost_locale.*\)\.a.*$;\1;'` ; do + ax_lib=${libextension} + AC_CHECK_LIB($ax_lib, exit, + [BOOST_LOCALE_LIB="-l$ax_lib"; AC_SUBST(BOOST_LOCALE_LIB) link_locale="yes"; break], + [link_locale="no"]) + done + if test "x$link_locale" != "xyes"; then + for libextension in `ls $BOOSTLIBDIR/boost_locale*.dll* $BOOSTLIBDIR/boost_locale*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^\(boost_locale.*\)\.dll.*$;\1;' -e 's;^\(boost_locale.*\)\.a.*$;\1;'` ; do + ax_lib=${libextension} + AC_CHECK_LIB($ax_lib, exit, + [BOOST_LOCALE_LIB="-l$ax_lib"; AC_SUBST(BOOST_LOCALE_LIB) link_locale="yes"; break], + [link_locale="no"]) + done + fi + + else + for ax_lib in $ax_boost_user_locale_lib boost_locale-$ax_boost_user_locale_lib; do + AC_CHECK_LIB($ax_lib, exit, + [BOOST_LOCALE_LIB="-l$ax_lib"; AC_SUBST(BOOST_LOCALE_LIB) link_locale="yes"; break], + [link_locale="no"]) + done + + fi + if test "x$ax_lib" = "x"; then + AC_MSG_ERROR(Could not find a version of the library!) + fi + if test "x$link_locale" = "xno"; then + AC_MSG_ERROR(Could not link against $ax_lib !) + fi + fi + + CPPFLAGS="$CPPFLAGS_SAVED" + LDFLAGS="$LDFLAGS_SAVED" + fi +]) diff --git a/src/init.cpp b/src/init.cpp index e3966ab1..f079f694 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -22,6 +22,8 @@ #include #include #include +#include +#include #include #ifndef WIN32 @@ -399,6 +401,7 @@ bool AppInit2(boost::thread_group& threadGroup) #endif #endif #endif + std::locale::global(boost::locale::generator().generate("")); // ********************************************************* Step 2: parameter interactions diff --git a/src/makefile.android b/src/makefile.android index 6434e1b6..073d69cd 100644 --- a/src/makefile.android +++ b/src/makefile.android @@ -174,6 +174,7 @@ LIBS += \ -l boost_filesystem$(BOOST_LIB_SUFFIX) \ -l boost_program_options$(BOOST_LIB_SUFFIX) \ -l boost_thread$(BOOST_LIB_SUFFIX) \ + -l boost_locale$(BOOST_LIB_SUFFIX) \ -l db_cxx$(BDB_LIB_SUFFIX) \ -L$(NDK_BASE)/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi/ -lgnustl_static #-l ssl_static -l crypto_static diff --git a/src/makefile.linux-mingw b/src/makefile.linux-mingw index 26d54166..857694b5 100644 --- a/src/makefile.linux-mingw +++ b/src/makefile.linux-mingw @@ -30,6 +30,7 @@ LIBS= \ -l boost_program_options-mt-s \ -l boost_thread_win32-mt-s \ -l boost_chrono-mt-s \ + -l boost_locale-mt-s \ -l db_cxx \ -l ssl \ -l crypto diff --git a/src/makefile.mingw b/src/makefile.mingw index 3659f520..431bf0d7 100644 --- a/src/makefile.mingw +++ b/src/makefile.mingw @@ -39,6 +39,7 @@ LIBS= \ -l boost_program_options$(BOOST_SUFFIX) \ -l boost_thread$(BOOST_SUFFIX) \ -l boost_chrono$(BOOST_SUFFIX) \ + -l boost_locale$(BOOST_SUFFIX) \ -l db_cxx \ -l ssl \ -l crypto diff --git a/src/makefile.osx b/src/makefile.osx index ebe621be..98870b1d 100644 --- a/src/makefile.osx +++ b/src/makefile.osx @@ -37,6 +37,7 @@ LIBS += \ -l boost_filesystem$(BOOST_LIB_SUFFIX) \ -l boost_program_options$(BOOST_LIB_SUFFIX) \ -l boost_thread$(BOOST_LIB_SUFFIX) \ + -l boost_locale$(BOOST_LIB_SUFFIX) \ -l db_cxx$(BDB_LIB_SUFFIX) \ -l ssl \ -l crypto diff --git a/src/makefile.osx-bitcoin b/src/makefile.osx-bitcoin index 269460c1..08c967d8 100644 --- a/src/makefile.osx-bitcoin +++ b/src/makefile.osx-bitcoin @@ -50,6 +50,7 @@ LIBS += \ -lboost_program_options-mt \ -lboost_thread-mt \ -lboost_chrono-mt \ + -lboost_locale-mt \ -lssl \ -lcrypto \ -lz diff --git a/src/makefile.unix b/src/makefile.unix index f9c0485b..b6fb07c6 100644 --- a/src/makefile.unix +++ b/src/makefile.unix @@ -38,6 +38,7 @@ LIBS += \ -l boost_filesystem$(BOOST_LIB_SUFFIX) \ -l boost_program_options$(BOOST_LIB_SUFFIX) \ -l boost_thread$(BOOST_LIB_SUFFIX) \ + -l boost_locale$(BOOST_LIB_SUFFIX) \ -l db_cxx$(BDB_LIB_SUFFIX) \ -l ssl \ -l crypto \ diff --git a/src/twister.cpp b/src/twister.cpp index d8b7a252..f0762638 100644 --- a/src/twister.cpp +++ b/src/twister.cpp @@ -13,6 +13,7 @@ using namespace json_spirit; using namespace std; #include +#include #include #include @@ -1226,7 +1227,7 @@ void updateSeenHashtags(std::string &message, int64_t msgTime) BOOST_FOREACH(string const& token, tokens) { if( token.length() >= 2 ) { string word = token.substr(1); - boost::algorithm::to_lower(word); + word = boost::locale::to_lower(word); if( token.at(0) == '#') { hashtags.insert(word); } @@ -1489,7 +1490,7 @@ Value newpostmsg(const Array& params, bool fHelp) BOOST_FOREACH(string const& token, tokens) { if( token.length() >= 2 ) { string word = token.substr(1); - boost::algorithm::to_lower(word); + word = boost::locale::to_lower(word); if( token.at(0) == '#') { ses->dht_putData(word, "hashtag", true, v, strUsername, GetAdjustedTime(), 0); diff --git a/twister-qt.pro b/twister-qt.pro index 251e0206..0a9a1ebf 100644 --- a/twister-qt.pro +++ b/twister-qt.pro @@ -453,7 +453,7 @@ LIBS += $$join(BOOST_LIB_PATH,,-L,) $$join(BDB_LIB_PATH,,-L,) $$join(OPENSSL_LIB LIBS += -lssl -lcrypto -ldb_cxx$$BDB_LIB_SUFFIX # -lgdi32 has to happen after -lcrypto (see #681) win32:LIBS += -lws2_32 -lshlwapi -lmswsock -lole32 -loleaut32 -luuid -lgdi32 -LIBS += -lboost_system$$BOOST_LIB_SUFFIX -lboost_filesystem$$BOOST_LIB_SUFFIX -lboost_program_options$$BOOST_LIB_SUFFIX -lboost_thread$$BOOST_THREAD_LIB_SUFFIX +LIBS += -lboost_system$$BOOST_LIB_SUFFIX -lboost_filesystem$$BOOST_LIB_SUFFIX -lboost_program_options$$BOOST_LIB_SUFFIX -lboost_thread$$BOOST_THREAD_LIB_SUFFIX -lboost_locale$$BOOST_THREAD_LIB_SUFFIX win32:LIBS += -lboost_chrono$$BOOST_LIB_SUFFIX macx:LIBS += -lboost_chrono$$BOOST_LIB_SUFFIX