From 433073dfed7447ec250735c7a1e52c301dedce40 Mon Sep 17 00:00:00 2001 From: Samuel Huang Date: Sat, 21 Dec 2024 01:45:19 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=90=9B=20Fix=20compile=20error=20prod?= =?UTF-8?q?uced=20by=20G++=2012.2.0=20on=20Debian=2012.2=20when=20compilin?= =?UTF-8?q?g=20the=20code=20with=20"-Werror=3Drestrict":=20=5F=5Fbuiltin?= =?UTF-8?q?=5Fmemcpy=20may=20have=20overlapped=20memory=20region.=20The=20?= =?UTF-8?q?performance=20is=20also=20optimized=20to=20avoid=20redundant=20?= =?UTF-8?q?memory=20copy.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/cli/cli_tab.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/cli/cli_tab.cpp b/src/cli/cli_tab.cpp index 7414c932..68d4bb57 100644 --- a/src/cli/cli_tab.cpp +++ b/src/cli/cli_tab.cpp @@ -232,12 +232,17 @@ dvlab::CommandLineInterface::TabActionResult dvlab::CommandLineInterface::_match // no auto complete : list matched files for (auto& file : files) { - for (size_t i = 0; i < file.size(); ++i) { - if (_is_special_char(file[i])) { - file.insert(i, "\\"); - ++i; + std::string new_file; + bool modified = false; + for (char c : file) { + if (_is_special_char(c)) { + new_file += '\\'; + modified = true; } + new_file += c; } + if (modified) + file = std::move(new_file); } for (auto& file : files) { From dfbac2fe245d767f49f8136113e2aeda979329a9 Mon Sep 17 00:00:00 2001 From: Samuel Huang Date: Sat, 21 Dec 2024 01:45:33 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=90=9B=20Fix=20compile=20error=20prod?= =?UTF-8?q?uced=20by=20G++=2012.2.0=20on=20Debian=2012.2=20when=20compilin?= =?UTF-8?q?g=20the=20code=20with=20"-Werror=3Drestrict":=20=5F=5Fbuiltin?= =?UTF-8?q?=5Fmemcpy=20may=20have=20overlapped=20memory=20region.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/util/phase.cpp | 4 ++-- src/util/text_format.cpp | 4 +++- vendor/tqdm/tqdm.hpp | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/util/phase.cpp b/src/util/phase.cpp index 71ae811a..46550534 100644 --- a/src/util/phase.cpp +++ b/src/util/phase.cpp @@ -27,7 +27,7 @@ std::string Phase::get_ascii_string() const { str += std::to_string(_rational.numerator()) + "*"; str += "pi"; if (_rational.denominator() != 1) - str += "/" + std::to_string(_rational.denominator()); + str += std::string("/") + std::to_string(_rational.denominator()); return str; } @@ -42,7 +42,7 @@ std::string Phase::get_print_string() const { : _rational.numerator() == -1 ? "-" : std::to_string(_rational.numerator())) + - ((_rational.numerator() != 0) ? "\u03C0" : "") + ((_rational.denominator() != 1) ? ("/" + std::to_string(_rational.denominator())) : ""); + ((_rational.numerator() != 0) ? std::string("\u03C0") : std::string("")) + ((_rational.denominator() != 1) ? (std::string("/") + std::to_string(_rational.denominator())) : std::string("")); } std::ostream& operator<<(std::ostream& os, dvlab::Phase const& p) { diff --git a/src/util/text_format.cpp b/src/util/text_format.cpp index 80d7d3bb..ad27bc3d 100644 --- a/src/util/text_format.cpp +++ b/src/util/text_format.cpp @@ -144,7 +144,9 @@ fmt::text_style ls_color(fs::path const& path) { return ls_color_internal("ex"); } - return ls_color_internal("*" + path.extension().string()); + std::string ret = std::string("*"); + ret += path.extension().string(); + return ls_color_internal(ret); } } // namespace fmt_ext diff --git a/vendor/tqdm/tqdm.hpp b/vendor/tqdm/tqdm.hpp index 7c917fa4..21cbd0e4 100644 --- a/vendor/tqdm/tqdm.hpp +++ b/vendor/tqdm/tqdm.hpp @@ -126,7 +126,7 @@ class tqdm { void set_theme_vertical() { bars = {"▁", "▂", "▃", "▄", "▅", "▆", "▇", "█", "█"}; } void set_theme_basic() { bars = {" ", " ", " ", " ", " ", " ", " ", " ", "#"}; - right_pad = "|"; + right_pad = std::string("|"); } void set_label(std::string label_) { label = label_; } void disable_colors() {