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

Addressing -Werror=restrict: Harmonizing C++ std::string with C-Style Strings #144

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/cli/cli_tab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions src/util/phase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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) {
Expand Down
4 changes: 3 additions & 1 deletion src/util/text_format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion vendor/tqdm/tqdm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down