Commit 73229006 authored by Oswald Buddenhagen's avatar Oswald Buddenhagen
Browse files

make ProFileParser API less bug-prone

QString::isNull() vs. isEmpty() discrimination is a time bomb ...
parent 34a8a57d
......@@ -227,7 +227,7 @@ void MaemoProFileWrapper::parseProFile(ParseType type) const
m_proFileReader->setCumulative(false);
// TODO: Set output dir to build dir?
if (type == ParseFromLines) {
m_proFile = m_proFileReader->parsedProFile(m_proFileName, false,
m_proFile = m_proFileReader->parsedProBlock(m_proFileName,
m_proFileContents.join("\n"));
} else {
m_proFileContents.clear();
......
......@@ -1050,7 +1050,7 @@ void Qt4PriFileNode::changeFiles(const FileType fileType,
ProMessageHandler handler;
ProFileParser parser(0, &handler);
includeFile = parser.parsedProFile(m_projectFilePath, false, contents);
includeFile = parser.parsedProBlock(m_projectFilePath, contents);
}
const QStringList vars = varNames(fileType);
......
......@@ -1274,8 +1274,8 @@ ProFileEvaluator::Private::VisitReturn ProFileEvaluator::Private::visitProFile(
tgt.append(ProString(QFileInfo(pro->fileName()).baseName(), NoHash));
if (!m_cmdArgs.isEmpty()) {
if (ProFile *pro = m_parser->parsedProFile(
fL1S("(command line)"), false, m_cmdArgs.join(fL1S("\n")))) {
if (ProFile *pro = m_parser->parsedProBlock(
fL1S("(command line)"), m_cmdArgs.join(fL1S("\n")))) {
m_locationStack.push(m_current);
visitProBlock(pro, pro->tokPtr());
m_current = m_locationStack.pop();
......@@ -2420,7 +2420,7 @@ ProFileEvaluator::Private::VisitReturn ProFileEvaluator::Private::evaluateCondit
case T_REQUIRES:
#endif
case T_EVAL: {
ProFile *pro = m_parser->parsedProFile(fL1S("(eval)"), false,
ProFile *pro = m_parser->parsedProBlock(fL1S("(eval)"),
args.join(statics.field_sep));
if (!pro)
return ReturnFalse;
......
......@@ -124,7 +124,7 @@ ProFileParser::ProFileParser(ProFileCache *cache, ProFileParserHandler *handler)
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;
if (cache && m_cache) {
......@@ -156,7 +156,7 @@ ProFile *ProFileParser::parsedProFile(const QString &fileName, bool cache, const
locker.unlock();
#endif
pro = new ProFile(fileName);
if (!(contents.isNull() ? read(pro) : read(pro, contents))) {
if (!(!contents ? read(pro) : read(pro, *contents))) {
delete pro;
pro = 0;
} else {
......@@ -176,7 +176,7 @@ ProFile *ProFileParser::parsedProFile(const QString &fileName, bool cache, const
}
} else {
pro = new ProFile(fileName);
if (!(contents.isNull() ? read(pro) : read(pro, contents))) {
if (!(!contents ? read(pro) : read(pro, *contents))) {
delete pro;
pro = 0;
}
......
......@@ -70,7 +70,9 @@ public:
// 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
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:
struct BlockScope {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment