forked from qt-creator/qt-creator
make ProFileParser API less bug-prone
QString::isNull() vs. isEmpty() discrimination is a time bomb ...
This commit is contained in:
@@ -227,7 +227,7 @@ void MaemoProFileWrapper::parseProFile(ParseType type) const
|
|||||||
m_proFileReader->setCumulative(false);
|
m_proFileReader->setCumulative(false);
|
||||||
// TODO: Set output dir to build dir?
|
// TODO: Set output dir to build dir?
|
||||||
if (type == ParseFromLines) {
|
if (type == ParseFromLines) {
|
||||||
m_proFile = m_proFileReader->parsedProFile(m_proFileName, false,
|
m_proFile = m_proFileReader->parsedProBlock(m_proFileName,
|
||||||
m_proFileContents.join("\n"));
|
m_proFileContents.join("\n"));
|
||||||
} else {
|
} else {
|
||||||
m_proFileContents.clear();
|
m_proFileContents.clear();
|
||||||
|
@@ -1050,7 +1050,7 @@ void Qt4PriFileNode::changeFiles(const FileType fileType,
|
|||||||
|
|
||||||
ProMessageHandler handler;
|
ProMessageHandler handler;
|
||||||
ProFileParser parser(0, &handler);
|
ProFileParser parser(0, &handler);
|
||||||
includeFile = parser.parsedProFile(m_projectFilePath, false, contents);
|
includeFile = parser.parsedProBlock(m_projectFilePath, contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
const QStringList vars = varNames(fileType);
|
const QStringList vars = varNames(fileType);
|
||||||
|
@@ -1274,8 +1274,8 @@ ProFileEvaluator::Private::VisitReturn ProFileEvaluator::Private::visitProFile(
|
|||||||
tgt.append(ProString(QFileInfo(pro->fileName()).baseName(), NoHash));
|
tgt.append(ProString(QFileInfo(pro->fileName()).baseName(), NoHash));
|
||||||
|
|
||||||
if (!m_cmdArgs.isEmpty()) {
|
if (!m_cmdArgs.isEmpty()) {
|
||||||
if (ProFile *pro = m_parser->parsedProFile(
|
if (ProFile *pro = m_parser->parsedProBlock(
|
||||||
fL1S("(command line)"), false, m_cmdArgs.join(fL1S("\n")))) {
|
fL1S("(command line)"), m_cmdArgs.join(fL1S("\n")))) {
|
||||||
m_locationStack.push(m_current);
|
m_locationStack.push(m_current);
|
||||||
visitProBlock(pro, pro->tokPtr());
|
visitProBlock(pro, pro->tokPtr());
|
||||||
m_current = m_locationStack.pop();
|
m_current = m_locationStack.pop();
|
||||||
@@ -2420,7 +2420,7 @@ ProFileEvaluator::Private::VisitReturn ProFileEvaluator::Private::evaluateCondit
|
|||||||
case T_REQUIRES:
|
case T_REQUIRES:
|
||||||
#endif
|
#endif
|
||||||
case T_EVAL: {
|
case T_EVAL: {
|
||||||
ProFile *pro = m_parser->parsedProFile(fL1S("(eval)"), false,
|
ProFile *pro = m_parser->parsedProBlock(fL1S("(eval)"),
|
||||||
args.join(statics.field_sep));
|
args.join(statics.field_sep));
|
||||||
if (!pro)
|
if (!pro)
|
||||||
return ReturnFalse;
|
return ReturnFalse;
|
||||||
|
@@ -124,7 +124,7 @@ ProFileParser::ProFileParser(ProFileCache *cache, ProFileParserHandler *handler)
|
|||||||
initialize();
|
initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
ProFile *ProFileParser::parsedProFile(const QString &fileName, bool cache, const QString &contents)
|
ProFile *ProFileParser::parsedProFile(const QString &fileName, bool cache, const QString *contents)
|
||||||
{
|
{
|
||||||
ProFile *pro;
|
ProFile *pro;
|
||||||
if (cache && m_cache) {
|
if (cache && m_cache) {
|
||||||
@@ -156,7 +156,7 @@ ProFile *ProFileParser::parsedProFile(const QString &fileName, bool cache, const
|
|||||||
locker.unlock();
|
locker.unlock();
|
||||||
#endif
|
#endif
|
||||||
pro = new ProFile(fileName);
|
pro = new ProFile(fileName);
|
||||||
if (!(contents.isNull() ? read(pro) : read(pro, contents))) {
|
if (!(!contents ? read(pro) : read(pro, *contents))) {
|
||||||
delete pro;
|
delete pro;
|
||||||
pro = 0;
|
pro = 0;
|
||||||
} else {
|
} else {
|
||||||
@@ -176,7 +176,7 @@ ProFile *ProFileParser::parsedProFile(const QString &fileName, bool cache, const
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
pro = new ProFile(fileName);
|
pro = new ProFile(fileName);
|
||||||
if (!(contents.isNull() ? read(pro) : read(pro, contents))) {
|
if (!(!contents ? read(pro) : read(pro, *contents))) {
|
||||||
delete pro;
|
delete pro;
|
||||||
pro = 0;
|
pro = 0;
|
||||||
}
|
}
|
||||||
|
@@ -70,7 +70,9 @@ public:
|
|||||||
// fileName is expected to be absolute and cleanPath()ed.
|
// fileName is expected to be absolute and cleanPath()ed.
|
||||||
// If contents is non-null, it will be used instead of the file's actual content
|
// If contents is non-null, it will be used instead of the file's actual content
|
||||||
ProFile *parsedProFile(const QString &fileName, bool cache = false,
|
ProFile *parsedProFile(const QString &fileName, bool cache = false,
|
||||||
const QString &contents = QString());
|
const QString *contents = 0);
|
||||||
|
ProFile *parsedProBlock(const QString &name, const QString &contents)
|
||||||
|
{ return parsedProFile(name, false, &contents); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct BlockScope {
|
struct BlockScope {
|
||||||
|
Reference in New Issue
Block a user