mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-27 00:21:03 +00:00
1. Fix bug in getBaseName where it mishandles suffixes
2. Fix bug in eraseSuffix where it allows /path/.suffix to become /path/ git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22362 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -271,7 +271,11 @@ Path::getBasename() const {
|
|||||||
else
|
else
|
||||||
slash++;
|
slash++;
|
||||||
|
|
||||||
return path.substr(slash, path.rfind('.'));
|
size_t dot = path.rfind('.');
|
||||||
|
if (dot == std::string::npos || dot < slash)
|
||||||
|
return path.substr(slash);
|
||||||
|
else
|
||||||
|
return path.substr(slash, dot - slash);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Path::hasMagicNumber(const std::string &Magic) const {
|
bool Path::hasMagicNumber(const std::string &Magic) const {
|
||||||
@@ -521,7 +525,7 @@ Path::eraseSuffix() {
|
|||||||
size_t dotpos = path.rfind('.',path.size());
|
size_t dotpos = path.rfind('.',path.size());
|
||||||
size_t slashpos = path.rfind('/',path.size());
|
size_t slashpos = path.rfind('/',path.size());
|
||||||
if (dotpos != std::string::npos) {
|
if (dotpos != std::string::npos) {
|
||||||
if (slashpos == std::string::npos || dotpos > slashpos) {
|
if (slashpos == std::string::npos || dotpos > slashpos+1) {
|
||||||
path.erase(dotpos, path.size()-dotpos);
|
path.erase(dotpos, path.size()-dotpos);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user