Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update sdcv #1287

Merged
merged 1 commit into from
Jan 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions thirdparty/sdcv/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,11 @@ set(CMAKE_SKIP_BUILD_RPATH True)
set(ENABLE_NLS False CACHE BOOL "")
set(WITH_READLINE False CACHE BOOL "")

# https://github.com/Dushistov/sdcv/pull/68
set(PATCH_CMD1 "${KO_PATCH_SH} ${CMAKE_CURRENT_SOURCE_DIR}/sdcv-pr68.patch")

# Force utf8 command line parsing, and accept not-found -u dictnames
set(PATCH_CMD "${KO_PATCH_SH} ${CMAKE_CURRENT_SOURCE_DIR}/sdcv.patch")
set(PATCH_CMD2 "${KO_PATCH_SH} ${CMAKE_CURRENT_SOURCE_DIR}/sdcv-locale-hack.patch")

ko_write_gitclone_script(
GIT_CLONE_SCRIPT_FILENAME
Expand All @@ -81,7 +84,7 @@ download_project(
GIT_TAG
4ae420734990ab9f5ccc038262368256b9323f4a
#DOWNLOAD_COMMAND ${CMAKE_COMMAND} -P ${GIT_CLONE_SCRIPT_FILENAME}
PATCH_COMMAND COMMAND ${PATCH_CMD}
PATCH_COMMAND COMMAND ${PATCH_CMD1} COMMAND ${PATCH_CMD2}
)

add_subdirectory("${CMAKE_BINARY_DIR}/sdcv-src"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/src/sdcv.cpp b/src/sdcv.cpp
index ca222b8..84ec948 100644
index 60a21ad..8b585b4 100644
--- a/src/sdcv.cpp
+++ b/src/sdcv.cpp
@@ -63,7 +63,10 @@ static void list_dicts(const std::list<std::string> &dicts_dir_list, bool use_js
Expand All @@ -14,9 +14,9 @@ index ca222b8..84ec948 100644
#if ENABLE_NLS
bindtextdomain("sdcv",
//"./locale"//< for testing
@@ -84,12 +87,19 @@ try {
gboolean only_data_dir = FALSE;
@@ -85,12 +88,19 @@ try {
gboolean colorize = FALSE;
glib::StrArr word_list;

+ // Glib, with G_OPTION_ARG_STRING* option, would convert it to utf8
+ // according to current locale (LC_ALL). But for that, even when locale
Expand All @@ -35,7 +35,7 @@ index ca222b8..84ec948 100644
_("for search use only dictionary with this bookname"),
_("bookname") },
{ "non-interactive", 'n', 0, G_OPTION_ARG_NONE, &non_interactive,
@@ -102,7 +112,7 @@ try {
@@ -103,7 +113,7 @@ try {
_("output must be in utf8"), nullptr },
{ "utf8-input", '1', 0, G_OPTION_ARG_NONE, &utf8_input,
_("input of sdcv in utf8"), nullptr },
Expand All @@ -44,7 +44,7 @@ index ca222b8..84ec948 100644
_("use this directory as path to stardict data directory"),
_("path/to/dir") },
{ "only-data-dir", 'x', 0, G_OPTION_ARG_NONE, &only_data_dir,
@@ -183,7 +193,9 @@ try {
@@ -186,7 +196,9 @@ try {
// add bookname to list
gchar **p = get_impl(use_dict_list);
while (*p) {
Expand Down
45 changes: 45 additions & 0 deletions thirdparty/sdcv/sdcv-pr68.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
diff --git a/src/sdcv.cpp b/src/sdcv.cpp
index ca222b8..60a21ad 100644
--- a/src/sdcv.cpp
+++ b/src/sdcv.cpp
@@ -83,6 +83,7 @@ try {
glib::CharStr opt_data_dir;
gboolean only_data_dir = FALSE;
gboolean colorize = FALSE;
+ glib::StrArr word_list;

const GOptionEntry entries[] = {
{ "version", 'v', 0, G_OPTION_ARG_NONE, &show_version,
@@ -109,11 +110,13 @@ try {
_("only use the dictionaries in data-dir, do not search in user and system directories"), nullptr },
{ "color", 'c', 0, G_OPTION_ARG_NONE, &colorize,
_("colorize the output"), nullptr },
+ { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, get_addr(word_list),
+ _("search terms"), _(" words") },
{},
};

glib::Error error;
- GOptionContext *context = g_option_context_new(_(" words"));
+ GOptionContext *context = g_option_context_new(nullptr);
g_option_context_set_help_enabled(context, TRUE);
g_option_context_add_main_entries(context, entries, nullptr);
const gboolean parse_res = g_option_context_parse(context, &argc, &argv, get_addr(error));
@@ -210,12 +213,14 @@ try {
lib.load(dicts_dir_list, order_list, disable_list);

std::unique_ptr<IReadLine> io(create_readline_object());
- if (optind < argc) {
+ if (word_list != nullptr) {
search_result rval = SEARCH_SUCCESS;
- for (int i = optind; i < argc; ++i)
- if ((rval = lib.process_phrase(argv[i], *io, non_interactive)) != SEARCH_SUCCESS) {
+ gchar **p = get_impl(word_list);
+ while (*p) {
+ if ((rval = lib.process_phrase(*p++, *io, non_interactive)) != SEARCH_SUCCESS) {
return rval;
}
+ }
} else if (!non_interactive) {

std::string phrase;