From baba04991f7e08fbd3c0b1314c2e52ef205a93a4 Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Wed, 15 Jan 2020 12:56:40 +0100 Subject: [PATCH 1/2] string: adding base58_strip() for strlist_t --- src/string.cpp | 6 ++++++ src/string.h | 1 + 2 files changed, 7 insertions(+) diff --git a/src/string.cpp b/src/string.cpp index a8c4e99..91b0960 100644 --- a/src/string.cpp +++ b/src/string.cpp @@ -78,3 +78,9 @@ std::string& base58_strip(std::string &str) { ), str.end()); return str; } + +strlist_t& base58_strip(strlist_t& list) { + + std::transform(list.begin(), list.end(), list.begin(), [](std::string& str){ return base58_strip(str); }); + return list; +} diff --git a/src/string.h b/src/string.h index 38c0440..e364fed 100644 --- a/src/string.h +++ b/src/string.h @@ -40,5 +40,6 @@ std::string& ltrim(std::string& str); std::string& trim(std::string& str); std::string& base58_strip(std::string &str); +strlist_t& base58_strip(strlist_t& list); #endif /* STRING_H */ From 58406e0c246f4ac9abc378fd9838bd78b1c34dc0 Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Wed, 15 Jan 2020 12:58:43 +0100 Subject: [PATCH 2/2] src/main.cpp: must do base58_strip after we have split into list. otherwise we will strip the delimiter "," --- src/main.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index ffa54da..e5fcd02 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -56,7 +56,10 @@ void cmd_search(int argc, char **argv) { int n = 100; n_thread_decl; std::string search(argv[0]); - strlist_t words = strsplitwords(strtolower(base58_strip(search))); + strlist_t words = strsplitwords(strtolower(search)); + + // Strip words from non-base58. + base58_strip(words); if (argc > 1) { n = atoi(argv[1]);