Refactorization: Use std::string::pop_back

Merged from LCppC.
This commit is contained in:
Philipp Kloke 2021-02-17 22:39:29 +01:00 committed by Daniel Marjamäki
parent 2fa2fec24f
commit ef82897af5
3 changed files with 6 additions and 6 deletions

View File

@ -257,7 +257,7 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
else if (std::strncmp(argv[i], "--cppcheck-build-dir=", 21) == 0) { else if (std::strncmp(argv[i], "--cppcheck-build-dir=", 21) == 0) {
mSettings->buildDir = Path::fromNativeSeparators(argv[i] + 21); mSettings->buildDir = Path::fromNativeSeparators(argv[i] + 21);
if (endsWith(mSettings->buildDir, '/')) if (endsWith(mSettings->buildDir, '/'))
mSettings->buildDir.erase(mSettings->buildDir.size() - 1U); mSettings->buildDir.pop_back();
} }
// Show --debug output after the first simplifications // Show --debug output after the first simplifications

View File

@ -561,7 +561,7 @@ void simplecpp::TokenList::readfile(std::istream &istr, const std::string &filen
portabilityBackslash(outputList, files, location); portabilityBackslash(outputList, files, location);
if (currentToken[currentToken.size() - 1U] == '\\') { if (currentToken[currentToken.size() - 1U] == '\\') {
++multiline; ++multiline;
currentToken.erase(currentToken.size() - 1U); currentToken.pop_back();
} else { } else {
ungetChar(istr, bom); ungetChar(istr, bom);
} }
@ -606,7 +606,7 @@ void simplecpp::TokenList::readfile(std::istream &istr, const std::string &filen
if (ch == '\"' && !prefix.empty() && *cback()->str().rbegin() == 'R') { if (ch == '\"' && !prefix.empty() && *cback()->str().rbegin() == 'R') {
std::string delim; std::string delim;
currentToken = ch; currentToken = ch;
prefix.resize(prefix.size() - 1); prefix.pop_back();
ch = readChar(istr,bom); ch = readChar(istr,bom);
while (istr.good() && ch != '(' && ch != '\n') { while (istr.good() && ch != '(' && ch != '\n') {
delim += ch; delim += ch;
@ -1147,7 +1147,7 @@ std::string simplecpp::TokenList::readUntil(std::istream &istr, const Location &
do { do {
next = readChar(istr, bom); next = readChar(istr, bom);
if (next == '\r' || next == '\n') { if (next == '\r' || next == '\n') {
ret.erase(ret.size()-1U); ret.pop_back();
backslash = (next == '\r'); backslash = (next == '\r');
update_ch = false; update_ch = false;
} else if (next == '\\') } else if (next == '\\')
@ -2176,7 +2176,7 @@ namespace simplecpp {
// remove trailing dot if path ends with "/." // remove trailing dot if path ends with "/."
if (endsWith(path,"/.")) if (endsWith(path,"/."))
path.erase(path.size()-1); path.pop_back();
// simplify ".." // simplify ".."
pos = 1; // don't simplify ".." if path starts with that pos = 1; // don't simplify ".." if path starts with that

View File

@ -175,7 +175,7 @@ bool Token::isUpperCaseName() const
void Token::concatStr(std::string const& b) void Token::concatStr(std::string const& b)
{ {
mStr.erase(mStr.length() - 1); mStr.pop_back();
mStr.append(getStringLiteral(b) + "\""); mStr.append(getStringLiteral(b) + "\"");
if (isCChar() && isStringLiteral(b) && b[0] != '"') { if (isCChar() && isStringLiteral(b) && b[0] != '"') {