Skip to content
New issue

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

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

Already on GitHub? # to your account

Fix compiler warning (gcc -Wconversion) #8

Merged
merged 1 commit into from
Sep 19, 2023
Merged
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
10 changes: 7 additions & 3 deletions include/semver/semver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,15 @@ namespace semver

prerelease_descriptor increment() const {
std::vector<prerelease_part> new_parts = (m_parts);
int last_numeric_index = -1;
size_t last_numeric_index = 0;
bool last_numeric_index_found = false;
for (size_t i = 0; i < new_parts.size(); ++i) {
if (new_parts[i].numeric()) last_numeric_index = i;
if (new_parts[i].numeric()){
last_numeric_index = i;
last_numeric_index_found = true;
}
}
if (last_numeric_index != -1) {
if (last_numeric_index_found) {
prerelease_part last = new_parts[last_numeric_index];
new_parts[last_numeric_index] = prerelease_part(std::to_string(last.numeric_value() + 1));
} else {
Expand Down