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(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])
|
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 ========================
|
||||||
dnl = checking for ncurses =
|
dnl = checking for ncurses =
|
||||||
dnl ========================
|
dnl ========================
|
||||||
@@ -23,11 +32,6 @@ if test "$unicode" = "yes" ; then
|
|||||||
else
|
else
|
||||||
ncurses_config_bin=ncurses5-config
|
ncurses_config_bin=ncurses5-config
|
||||||
ncurses_lib=ncurses
|
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
|
fi
|
||||||
AC_PATH_PROG(NCURSES_CONFIG, $ncurses_config_bin)
|
AC_PATH_PROG(NCURSES_CONFIG, $ncurses_config_bin)
|
||||||
if test "$NCURSES_CONFIG" != "" ; then
|
if test "$NCURSES_CONFIG" != "" ; then
|
||||||
|
|||||||
@@ -20,12 +20,13 @@
|
|||||||
|
|
||||||
#include "charset.h"
|
#include "charset.h"
|
||||||
|
|
||||||
#if !defined(_UTF8) && defined(HAVE_ICONV_H)
|
#if defined(SUPPORTED_LOCALES) && defined(HAVE_ICONV_H)
|
||||||
|
|
||||||
#include <iconv.h>
|
#include <iconv.h>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <iostream>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
#include "locale.h"
|
#include "locale.h"
|
||||||
@@ -95,7 +96,10 @@ void init_current_locale()
|
|||||||
return;
|
return;
|
||||||
std::ifstream f(SUPPORTED_LOCALES);
|
std::ifstream f(SUPPORTED_LOCALES);
|
||||||
if (!f.is_open())
|
if (!f.is_open())
|
||||||
|
{
|
||||||
|
std::cerr << "ncmpcpp: cannot open file "SUPPORTED_LOCALES"!\n";
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
envlocale += " ";
|
envlocale += " ";
|
||||||
std::string line;
|
std::string line;
|
||||||
while (!f.eof())
|
while (!f.eof())
|
||||||
@@ -105,10 +109,19 @@ void init_current_locale()
|
|||||||
{
|
{
|
||||||
try
|
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)
|
catch (std::out_of_range)
|
||||||
{
|
{
|
||||||
|
f.close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -165,5 +178,5 @@ void str_pool_locale_to_utf(char *&s)
|
|||||||
charset_convert(locale_charset, "utf8", s);
|
charset_convert(locale_charset, "utf8", s);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif // SUPPORTED_LOCALES && HAVE_ICONV_H
|
||||||
|
|
||||||
|
|||||||
@@ -25,9 +25,9 @@
|
|||||||
#include <config.h>
|
#include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <string>
|
#if defined(SUPPORTED_LOCALES) && defined(HAVE_ICONV_H)
|
||||||
|
|
||||||
#if !defined(_UTF8) && defined(HAVE_ICONV_H)
|
#include <string>
|
||||||
|
|
||||||
void init_current_locale();
|
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_utf_to_locale(x);
|
||||||
#define str_pool_locale_to_utf(x);
|
#define str_pool_locale_to_utf(x);
|
||||||
|
|
||||||
#endif // !_UTF8 && HAVE_ICONV_H
|
#endif // SUPPORTED_LOCALES && HAVE_ICONV_H
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -533,7 +533,8 @@ void DisplaySongInColumns(const Song &s, void *s_template, Menu<Song> *menu)
|
|||||||
|
|
||||||
void DisplaySong(const Song &s, void *data, Menu<Song> *menu)
|
void DisplaySong(const Song &s, void *data, Menu<Song> *menu)
|
||||||
{
|
{
|
||||||
const_cast<Song *>(&s)->Localize();
|
if (!s.Localized())
|
||||||
|
const_cast<Song *>(&s)->Localize();
|
||||||
|
|
||||||
const string &song_template = data ? *static_cast<string *>(data) : "";
|
const string &song_template = data ? *static_cast<string *>(data) : "";
|
||||||
basic_buffer<my_char_t> buf;
|
basic_buffer<my_char_t> buf;
|
||||||
|
|||||||
@@ -193,6 +193,11 @@ int main(int argc, char *argv[])
|
|||||||
if (!ConnectToMPD())
|
if (!ConnectToMPD())
|
||||||
return -1;
|
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);
|
InitScreen(Config.colors_enabled);
|
||||||
init_current_locale();
|
init_current_locale();
|
||||||
|
|
||||||
@@ -359,11 +364,6 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
signal(SIGPIPE, SIG_IGN);
|
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
|
# ifdef HAVE_CURL_CURL_H
|
||||||
pthread_attr_t attr_detached;
|
pthread_attr_t attr_detached;
|
||||||
pthread_attr_init(&attr_detached);
|
pthread_attr_init(&attr_detached);
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ string Song::GetLength() const
|
|||||||
|
|
||||||
void Song::Localize()
|
void Song::Localize()
|
||||||
{
|
{
|
||||||
# if !defined(_UTF8) && defined(HAVE_ICONV_H)
|
# if defined(SUPPORTED_LOCALES) && defined(HAVE_ICONV_H)
|
||||||
if (isLocalised)
|
if (isLocalised)
|
||||||
return;
|
return;
|
||||||
str_pool_utf_to_locale(itsSong->file);
|
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->disc);
|
||||||
str_pool_utf_to_locale(itsSong->comment);
|
str_pool_utf_to_locale(itsSong->comment);
|
||||||
isLocalised = 1;
|
isLocalised = 1;
|
||||||
# endif // !_UTF8 && HAVE_ICONV_H
|
# endif // SUPPORTED_LOCALES && HAVE_ICONV_H
|
||||||
}
|
}
|
||||||
|
|
||||||
/*void Song::Delocalize()
|
/*void Song::Delocalize()
|
||||||
|
|||||||
Reference in New Issue
Block a user