Fixed #5836: Make showing $ in stringified tokens optional

This commit is contained in:
PKEuS 2014-09-29 14:50:00 +02:00
parent 448195f255
commit 1df1b9c2bd
3 changed files with 7 additions and 6 deletions

View File

@ -1867,7 +1867,7 @@ void CheckIO::argumentType(std::ostream& os, const ArgumentInfo * argInfo)
os << type->str() << "::";
type = type->tokAt(2);
}
type->stringify(os, false, true);
type->stringify(os, false, true, false);
if (type->strAt(1) == "*" && !argInfo->element)
os << " *";
else if (argInfo->variableInfo && !argInfo->element && argInfo->variableInfo->isArray())
@ -1883,7 +1883,7 @@ void CheckIO::argumentType(std::ostream& os, const ArgumentInfo * argInfo)
if (type->strAt(1) == "*" || argInfo->address)
os << " *";
os << " {aka ";
type->stringify(os, false, true);
type->stringify(os, false, true, false);
if (type->strAt(1) == "*" || argInfo->address)
os << " *";
os << "}";

View File

@ -928,7 +928,7 @@ void Token::printOut(const char *title, const std::vector<std::string> &fileName
std::cout << stringifyList(true, true, true, true, true, &fileNames, 0) << std::endl;
}
void Token::stringify(std::ostream& os, bool varid, bool attributes) const
void Token::stringify(std::ostream& os, bool varid, bool attributes, bool macro) const
{
if (attributes) {
if (isUnsigned())
@ -942,7 +942,7 @@ void Token::stringify(std::ostream& os, bool varid, bool attributes) const
os << "long ";
}
}
if (isExpandedMacro())
if (macro && isExpandedMacro())
os << "$";
if (_str[0] != '\"' || _str.find("\0") == std::string::npos)
os << _str;
@ -1007,7 +1007,7 @@ std::string Token::stringifyList(bool varid, bool attributes, bool linenumbers,
lineNumber = tok->linenr();
}
tok->stringify(ret, varid, attributes); // print token
tok->stringify(ret, varid, attributes, attributes); // print token
if (tok->next() != end && (!linebreaks || (tok->next()->linenr() <= tok->linenr() && tok->next()->fileIndex() == tok->fileIndex())))
ret << ' ';
}

View File

@ -481,8 +481,9 @@ public:
* @param os The result is shifted into that output stream
* @param varid Print varids. (Style: "varname@id")
* @param attributes Print attributes of tokens like "unsigned" in front of it.
* @param macro Prints $ in front of the token if it was expanded from a macro.
*/
void stringify(std::ostream& os, bool varid, bool attributes) const;
void stringify(std::ostream& os, bool varid, bool attributes, bool macro) const;
/**
* Stringify a list of token, from current instance on.