Always verify that position1 is not equal to string_view::npos in main.cpp
This commit is contained in:
parent
cf6e5cfaf8
commit
b351280b5b
@ -50,14 +50,15 @@ int main(int argc, char* argv[]) {
|
|||||||
} catch (const Yerbacon::Exception& error) {
|
} catch (const Yerbacon::Exception& error) {
|
||||||
unsigned long lastSlash = 0;
|
unsigned long lastSlash = 0;
|
||||||
unsigned long position1 = fileName.find_last_of('/');
|
unsigned long position1 = fileName.find_last_of('/');
|
||||||
|
const bool isNPOS = cmp_equal(position1, string_view::npos)
|
||||||
if constexpr(filesystem::path::preferred_separator == '/') {
|
if constexpr(filesystem::path::preferred_separator == '/') {
|
||||||
if (cmp_not_equal(position1, string_view::npos)) {
|
if (not isNPOS) {
|
||||||
lastSlash = position1;
|
lastSlash = position1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
unsigned long position2 = fileName.find_last_of(filesystem::path::preferred_separator);
|
unsigned long position2 = fileName.find_last_of(filesystem::path::preferred_separator);
|
||||||
if (cmp_not_equal(position2, string_view::npos)) {
|
if (cmp_not_equal(position2, string_view::npos)) {
|
||||||
lastSlash = max(position1, position2);
|
lastSlash = (isNPOS) ? position2 : max(position1, position2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
resultingPair.first = fileName.substr(lastSlash + 1);
|
resultingPair.first = fileName.substr(lastSlash + 1);
|
||||||
|
Loading…
Reference in New Issue
Block a user