do not exclude iconv support if unicode is enabled
This commit is contained in:
14
configure.in
14
configure.in
@@ -13,6 +13,15 @@ AC_ARG_ENABLE(unicode, AS_HELP_STRING([--enable-unicode], [Enable utf8 support])
|
||||
AC_ARG_WITH(taglib, AS_HELP_STRING([--with-taglib], [Enable tag editor]), [taglib=$withval], [taglib=no])
|
||||
AC_ARG_WITH(curl, AS_HELP_STRING([--with-curl], [Enable fetching lyrics from the Internet]), [curl=$withval], [curl=no])
|
||||
|
||||
dnl ======================
|
||||
dnl = checking for iconv =
|
||||
dnl ======================
|
||||
AC_CHECK_FILE([/usr/share/i18n/SUPPORTED], AC_DEFINE([SUPPORTED_LOCALES], ["/usr/share/i18n/SUPPORTED"], [ ]),
|
||||
AC_CHECK_FILE([/etc/locale.gen], AC_DEFINE([SUPPORTED_LOCALES], ["/etc/locale.gen"], [ ]),
|
||||
AC_MSG_NOTICE(cannot find list of supported locales, iconv support will be disabled))
|
||||
)
|
||||
AC_CHECK_HEADERS([iconv.h], , AC_MSG_NOTICE(cannot find iconv.h header, iconv support will be disabled))
|
||||
|
||||
dnl ========================
|
||||
dnl = checking for ncurses =
|
||||
dnl ========================
|
||||
@@ -23,11 +32,6 @@ if test "$unicode" = "yes" ; then
|
||||
else
|
||||
ncurses_config_bin=ncurses5-config
|
||||
ncurses_lib=ncurses
|
||||
AC_CHECK_FILE([/usr/share/i18n/SUPPORTED], AC_DEFINE([SUPPORTED_LOCALES], ["/usr/share/i18n/SUPPORTED"], [ ]),
|
||||
AC_CHECK_FILE([/etc/locale.gen], AC_DEFINE([SUPPORTED_LOCALES], ["/etc/locale.gen"], [ ]),
|
||||
AC_MSG_ERROR([cannot find list of supported locales]))
|
||||
)
|
||||
AC_CHECK_HEADERS([iconv.h], ,)
|
||||
fi
|
||||
AC_PATH_PROG(NCURSES_CONFIG, $ncurses_config_bin)
|
||||
if test "$NCURSES_CONFIG" != "" ; then
|
||||
|
||||
@@ -20,12 +20,13 @@
|
||||
|
||||
#include "charset.h"
|
||||
|
||||
#if !defined(_UTF8) && defined(HAVE_ICONV_H)
|
||||
#if defined(SUPPORTED_LOCALES) && defined(HAVE_ICONV_H)
|
||||
|
||||
#include <iconv.h>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "locale.h"
|
||||
@@ -95,7 +96,10 @@ void init_current_locale()
|
||||
return;
|
||||
std::ifstream f(SUPPORTED_LOCALES);
|
||||
if (!f.is_open())
|
||||
{
|
||||
std::cerr << "ncmpcpp: cannot open file "SUPPORTED_LOCALES"!\n";
|
||||
return;
|
||||
}
|
||||
envlocale += " ";
|
||||
std::string line;
|
||||
while (!f.eof())
|
||||
@@ -105,10 +109,19 @@ void init_current_locale()
|
||||
{
|
||||
try
|
||||
{
|
||||
locale_charset = strdup((line.substr(line.find(" ")+1) + "//TRANSLIT").c_str());
|
||||
std::string charset = line.substr(line.find(" ")+1);
|
||||
if (charset == "UTF-8"
|
||||
|| charset == "utf-8"
|
||||
|| charset == "utf8")
|
||||
{
|
||||
f.close();
|
||||
return;
|
||||
}
|
||||
locale_charset = strdup((charset + "//TRANSLIT").c_str());
|
||||
}
|
||||
catch (std::out_of_range)
|
||||
{
|
||||
f.close();
|
||||
return;
|
||||
}
|
||||
break;
|
||||
@@ -165,5 +178,5 @@ void str_pool_locale_to_utf(char *&s)
|
||||
charset_convert(locale_charset, "utf8", s);
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // SUPPORTED_LOCALES && HAVE_ICONV_H
|
||||
|
||||
|
||||
@@ -25,9 +25,9 @@
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
#if defined(SUPPORTED_LOCALES) && defined(HAVE_ICONV_H)
|
||||
|
||||
#if !defined(_UTF8) && defined(HAVE_ICONV_H)
|
||||
#include <string>
|
||||
|
||||
void init_current_locale();
|
||||
|
||||
@@ -53,7 +53,7 @@ void str_pool_locale_to_utf(char *&);
|
||||
#define str_pool_utf_to_locale(x);
|
||||
#define str_pool_locale_to_utf(x);
|
||||
|
||||
#endif // !_UTF8 && HAVE_ICONV_H
|
||||
#endif // SUPPORTED_LOCALES && HAVE_ICONV_H
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -533,6 +533,7 @@ void DisplaySongInColumns(const Song &s, void *s_template, Menu<Song> *menu)
|
||||
|
||||
void DisplaySong(const Song &s, void *data, Menu<Song> *menu)
|
||||
{
|
||||
if (!s.Localized())
|
||||
const_cast<Song *>(&s)->Localize();
|
||||
|
||||
const string &song_template = data ? *static_cast<string *>(data) : "";
|
||||
|
||||
@@ -193,6 +193,11 @@ int main(int argc, char *argv[])
|
||||
if (!ConnectToMPD())
|
||||
return -1;
|
||||
|
||||
// redirect std::cerr output to ~/.ncmpcpp/error.log file
|
||||
std::ofstream errorlog((config_dir + "error.log").c_str(), std::ios::app);
|
||||
std::streambuf *cerr_buffer = std::cerr.rdbuf();
|
||||
std::cerr.rdbuf(errorlog.rdbuf());
|
||||
|
||||
InitScreen(Config.colors_enabled);
|
||||
init_current_locale();
|
||||
|
||||
@@ -359,11 +364,6 @@ int main(int argc, char *argv[])
|
||||
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
|
||||
// redirect std::cerr output to ~/.ncmpcpp/error.log file
|
||||
std::ofstream errorlog((config_dir + "error.log").c_str(), std::ios::app);
|
||||
std::streambuf * cerr_buffer = std::cerr.rdbuf();
|
||||
std::cerr.rdbuf(errorlog.rdbuf());
|
||||
|
||||
# ifdef HAVE_CURL_CURL_H
|
||||
pthread_attr_t attr_detached;
|
||||
pthread_attr_init(&attr_detached);
|
||||
|
||||
@@ -77,7 +77,7 @@ string Song::GetLength() const
|
||||
|
||||
void Song::Localize()
|
||||
{
|
||||
# if !defined(_UTF8) && defined(HAVE_ICONV_H)
|
||||
# if defined(SUPPORTED_LOCALES) && defined(HAVE_ICONV_H)
|
||||
if (isLocalised)
|
||||
return;
|
||||
str_pool_utf_to_locale(itsSong->file);
|
||||
@@ -94,7 +94,7 @@ void Song::Localize()
|
||||
str_pool_utf_to_locale(itsSong->disc);
|
||||
str_pool_utf_to_locale(itsSong->comment);
|
||||
isLocalised = 1;
|
||||
# endif // !_UTF8 && HAVE_ICONV_H
|
||||
# endif // SUPPORTED_LOCALES && HAVE_ICONV_H
|
||||
}
|
||||
|
||||
/*void Song::Delocalize()
|
||||
|
||||
Reference in New Issue
Block a user