mirror of
https://github.com/Dushistov/sdcv.git
synced 2025-12-15 17:31:56 +00:00
@@ -1,24 +1,14 @@
|
|||||||
project(sdcv)
|
project(sdcv)
|
||||||
|
|
||||||
# Older versions have a different signature for CMAKE_MINIMUM_REQUIRED,
|
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
|
||||||
# check it manually just to make sure
|
cmake_policy(VERSION 3.5)
|
||||||
if (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} LESS 2.8)
|
|
||||||
message(FATAL_ERROR "${PROJECT_NAME} requires at least CMake v2.8."
|
|
||||||
" You are running v${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}."
|
|
||||||
" Please upgrade." )
|
|
||||||
endif(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} LESS 2.8)
|
|
||||||
|
|
||||||
# If we get this far, use the modern signature. This will also cause newer
|
|
||||||
# CMake versions to try to be backwards-compatible with the desired version
|
|
||||||
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
|
|
||||||
cmake_policy(VERSION 2.8)
|
|
||||||
|
|
||||||
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/compiler.cmake")
|
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/compiler.cmake")
|
||||||
|
|
||||||
set(ZLIB_FIND_REQUIRED True)
|
set(ZLIB_FIND_REQUIRED True)
|
||||||
include(FindZLIB)
|
include(FindZLIB)
|
||||||
|
|
||||||
set(GLIB2_REQ "'glib-2.0 >= 2.6.1'")
|
set(GLIB2_REQ "'glib-2.0 >= 2.36'")
|
||||||
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
|
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
|
||||||
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindGLIB2.cmake")
|
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindGLIB2.cmake")
|
||||||
|
|
||||||
|
|||||||
@@ -314,7 +314,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
FILE *output;
|
FILE *output;
|
||||||
};
|
};
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
search_result Library::process_phrase(const char *loc_str, IReadLine &io, bool force)
|
search_result Library::process_phrase(const char *loc_str, IReadLine &io, bool force)
|
||||||
{
|
{
|
||||||
@@ -330,7 +330,7 @@ search_result Library::process_phrase(const char *loc_str, IReadLine &io, bool f
|
|||||||
gsize bytes_read;
|
gsize bytes_read;
|
||||||
gsize bytes_written;
|
gsize bytes_written;
|
||||||
glib::Error err;
|
glib::Error err;
|
||||||
search_result rval = SEARCH_SUCCESS;
|
search_result rval = SEARCH_SUCCESS;
|
||||||
glib::CharStr str;
|
glib::CharStr str;
|
||||||
if (!utf8_input_)
|
if (!utf8_input_)
|
||||||
str.reset(g_locale_to_utf8(loc_str, -1, &bytes_read, &bytes_written, get_addr(err)));
|
str.reset(g_locale_to_utf8(loc_str, -1, &bytes_read, &bytes_written, get_addr(err)));
|
||||||
@@ -444,7 +444,7 @@ search_result Library::process_phrase(const char *loc_str, IReadLine &io, bool f
|
|||||||
loc_str = utf8_to_locale_ign_err(get_impl(str));
|
loc_str = utf8_to_locale_ign_err(get_impl(str));
|
||||||
if (!json_)
|
if (!json_)
|
||||||
printf(_("Nothing similar to %s, sorry :(\n"), utf8_output_ ? get_impl(str) : loc_str.c_str());
|
printf(_("Nothing similar to %s, sorry :(\n"), utf8_output_ ? get_impl(str) : loc_str.c_str());
|
||||||
rval = SEARCH_NO_RESULT;
|
rval = SEARCH_NO_RESULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (json_) {
|
if (json_) {
|
||||||
|
|||||||
@@ -25,9 +25,9 @@ typedef std::vector<TSearchResult> TSearchResultList;
|
|||||||
|
|
||||||
//possible return values for Library.process_phase()
|
//possible return values for Library.process_phase()
|
||||||
enum search_result {
|
enum search_result {
|
||||||
SEARCH_SUCCESS = 0,
|
SEARCH_SUCCESS = 0,
|
||||||
SEARCH_FAILURE,
|
SEARCH_FAILURE,
|
||||||
SEARCH_NO_RESULT
|
SEARCH_NO_RESULT
|
||||||
};
|
};
|
||||||
|
|
||||||
//this class is wrapper around Dicts class for easy use
|
//this class is wrapper around Dicts class for easy use
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public:
|
|||||||
return stdio_getline(stdin, line);
|
return stdio_getline(stdin, line);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
} // namespace
|
||||||
#else
|
#else
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
@@ -72,7 +72,7 @@ std::string get_hist_file_path()
|
|||||||
const std::string hist_file_path = std::string(g_get_home_dir()) + G_DIR_SEPARATOR + ".sdcv_history";
|
const std::string hist_file_path = std::string(g_get_home_dir()) + G_DIR_SEPARATOR + ".sdcv_history";
|
||||||
if (g_file_test(hist_file_path.c_str(), G_FILE_TEST_IS_REGULAR))
|
if (g_file_test(hist_file_path.c_str(), G_FILE_TEST_IS_REGULAR))
|
||||||
return hist_file_path;
|
return hist_file_path;
|
||||||
|
|
||||||
return std::string(g_get_user_data_dir()) + G_DIR_SEPARATOR + "sdcv_history";
|
return std::string(g_get_user_data_dir()) + G_DIR_SEPARATOR + "sdcv_history";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,7 +116,7 @@ public:
|
|||||||
add_history(phrase.c_str());
|
add_history(phrase.c_str());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
} // namespace
|
||||||
#endif //WITH_READLINE
|
#endif //WITH_READLINE
|
||||||
|
|
||||||
IReadLine *create_readline_object()
|
IReadLine *create_readline_object()
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ static void free_str_array(gchar **arr)
|
|||||||
g_free(*p);
|
g_free(*p);
|
||||||
g_free(arr);
|
g_free(arr);
|
||||||
}
|
}
|
||||||
}
|
} // namespace
|
||||||
namespace glib
|
namespace glib
|
||||||
{
|
{
|
||||||
using StrArr = ResourceWrapper<gchar *, gchar *, free_str_array>;
|
using StrArr = ResourceWrapper<gchar *, gchar *, free_str_array>;
|
||||||
@@ -61,13 +61,14 @@ using StrArr = ResourceWrapper<gchar *, gchar *, free_str_array>;
|
|||||||
|
|
||||||
static void list_dicts(const std::list<std::string> &dicts_dir_list, bool use_json);
|
static void list_dicts(const std::list<std::string> &dicts_dir_list, bool use_json);
|
||||||
|
|
||||||
int main(int argc, char *argv[]) try {
|
int main(int argc, char *argv[])
|
||||||
|
try {
|
||||||
setlocale(LC_ALL, "");
|
setlocale(LC_ALL, "");
|
||||||
#if ENABLE_NLS
|
#if ENABLE_NLS
|
||||||
bindtextdomain("sdcv",
|
bindtextdomain("sdcv",
|
||||||
//"./locale"//< for testing
|
//"./locale"//< for testing
|
||||||
GETTEXT_TRANSLATIONS_PATH //< should be
|
GETTEXT_TRANSLATIONS_PATH //< should be
|
||||||
);
|
);
|
||||||
textdomain("sdcv");
|
textdomain("sdcv");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -210,7 +211,7 @@ int main(int argc, char *argv[]) try {
|
|||||||
|
|
||||||
std::unique_ptr<IReadLine> io(create_readline_object());
|
std::unique_ptr<IReadLine> io(create_readline_object());
|
||||||
if (optind < argc) {
|
if (optind < argc) {
|
||||||
search_result rval = SEARCH_SUCCESS;
|
search_result rval = SEARCH_SUCCESS;
|
||||||
for (int i = optind; i < argc; ++i)
|
for (int i = optind; i < argc; ++i)
|
||||||
if ((rval = lib.process_phrase(argv[i], *io, non_interactive)) != SEARCH_SUCCESS) {
|
if ((rval = lib.process_phrase(argv[i], *io, non_interactive)) != SEARCH_SUCCESS) {
|
||||||
return rval;
|
return rval;
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ static void unicode_strdown(gunichar *str)
|
|||||||
++str;
|
++str;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
bool DictInfo::load_from_ifo_file(const std::string &ifofilename,
|
bool DictInfo::load_from_ifo_file(const std::string &ifofilename,
|
||||||
bool istreedict)
|
bool istreedict)
|
||||||
@@ -334,6 +334,7 @@ bool DictBase::SearchData(std::vector<std::string> &SearchWords, guint32 idxitem
|
|||||||
|
|
||||||
if (dictfile)
|
if (dictfile)
|
||||||
fseek(dictfile, idxitem_offset, SEEK_SET);
|
fseek(dictfile, idxitem_offset, SEEK_SET);
|
||||||
|
THROW_IF_ERROR(origin_data != nullptr);
|
||||||
if (dictfile) {
|
if (dictfile) {
|
||||||
const size_t nitems = fread(origin_data, idxitem_size, 1, dictfile);
|
const size_t nitems = fread(origin_data, idxitem_size, 1, dictfile);
|
||||||
THROW_IF_ERROR(nitems == 1);
|
THROW_IF_ERROR(nitems == 1);
|
||||||
@@ -758,7 +759,7 @@ bool OffsetIndex::lookup(const char *str, glong &idx)
|
|||||||
return bFound;
|
return bFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WordListIndex::load(const std::string &url, gulong wc, gulong fsize, bool verbose)
|
bool WordListIndex::load(const std::string &url, gulong wc, gulong fsize, bool)
|
||||||
{
|
{
|
||||||
gzFile in = gzopen(url.c_str(), "rb");
|
gzFile in = gzopen(url.c_str(), "rb");
|
||||||
if (in == nullptr)
|
if (in == nullptr)
|
||||||
@@ -826,7 +827,7 @@ bool WordListIndex::lookup(const char *str, glong &idx)
|
|||||||
}
|
}
|
||||||
return bFound;
|
return bFound;
|
||||||
}
|
}
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
bool SynFile::load(const std::string &url, gulong wc)
|
bool SynFile::load(const std::string &url, gulong wc)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ namespace glib
|
|||||||
{
|
{
|
||||||
typedef ResourceWrapper<gchar, void, g_free> CharStr;
|
typedef ResourceWrapper<gchar, void, g_free> CharStr;
|
||||||
typedef ResourceWrapper<GError, GError, g_error_free> Error;
|
typedef ResourceWrapper<GError, GError, g_error_free> Error;
|
||||||
}
|
} // namespace glib
|
||||||
|
|
||||||
extern std::string utf8_to_locale_ign_err(const std::string &utf8_str);
|
extern std::string utf8_to_locale_ign_err(const std::string &utf8_str);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user