trim white spaces
This commit is contained in:
parent
99d85220f8
commit
30c302d13d
|
@ -3,6 +3,7 @@
|
||||||
// $ patchelf --set-rpath /usr/local/lib/gcc13 hakurei
|
// $ patchelf --set-rpath /usr/local/lib/gcc13 hakurei
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
@ -18,6 +19,8 @@
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct Entry {
|
struct Entry {
|
||||||
const std::string_view decoded_view;
|
const std::string_view decoded_view;
|
||||||
const uint64_t id;
|
const uint64_t id;
|
||||||
|
@ -46,6 +49,19 @@ inline std::pair<std::string, std::string> remove_one_utf8_char(const std::strin
|
||||||
return {"", ""};
|
return {"", ""};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::string trim(const std::string& str) {
|
||||||
|
size_t start = str.find_first_not_of(" \t\n\r\f\v");
|
||||||
|
size_t end = str.find_last_not_of(" \t\n\r\f\v");
|
||||||
|
|
||||||
|
if (start == std::string::npos || end == std::string::npos)
|
||||||
|
return ""; // String contains only whitespace
|
||||||
|
|
||||||
|
return str.substr(start, end - start + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
inline std::string get_input(const int argc, char* const argv[], const bool goldendict_mode) {
|
inline std::string get_input(const int argc, char* const argv[], const bool goldendict_mode) {
|
||||||
std::string search_string;
|
std::string search_string;
|
||||||
if (!isatty(fileno(stdin))) {
|
if (!isatty(fileno(stdin))) {
|
||||||
|
@ -79,7 +95,8 @@ inline std::string get_input(const int argc, char* const argv[], const bool gold
|
||||||
std::cerr << "Search string not provided." << std::endl;
|
std::cerr << "Search string not provided." << std::endl;
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
return search_string;
|
|
||||||
|
return trim(search_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::filesystem::path find_dic_file() {
|
inline std::filesystem::path find_dic_file() {
|
||||||
|
|
Loading…
Reference in a new issue