mirror of
https://github.com/fwbuilder/fwbuilder
synced 2026-09-13 08:29:32 +02:00
see #2556 "PF import:
impor of rules referring to undefined macros". Importer displays warnings for all undefined macros found in the file, even if there are several.
This commit is contained in:
@@ -1,5 +1,10 @@
|
|||||||
2011-07-08 vadim <vadim@netcitadel.com>
|
2011-07-08 vadim <vadim@netcitadel.com>
|
||||||
|
|
||||||
|
* PFImporterRun.cpp (substituteMacros): see #2556 "PF import:
|
||||||
|
impor of rules referring to undefined macros". Importer displays
|
||||||
|
warnings for all undefined macros found in the file, even if there
|
||||||
|
are several.
|
||||||
|
|
||||||
* objectSignature.cpp: fixes #2559 "Crash on import when at least
|
* objectSignature.cpp: fixes #2559 "Crash on import when at least
|
||||||
one DynamicGroup object already exists in the object tree."
|
one DynamicGroup object already exists in the object tree."
|
||||||
|
|
||||||
|
|||||||
@@ -260,7 +260,7 @@ void PFImporter::substituteMacros(const QMap<QString,QString> ¯os,
|
|||||||
{
|
{
|
||||||
// make several passes: sometimes macros can use other macros
|
// make several passes: sometimes macros can use other macros
|
||||||
QRegExp any_macro_instance("\\$(\\w+)\\W");
|
QRegExp any_macro_instance("\\$(\\w+)\\W");
|
||||||
|
QSet<QString> undefined_macros;
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
QMapIterator<QString, QString> it(macros);
|
QMapIterator<QString, QString> it(macros);
|
||||||
@@ -275,18 +275,22 @@ void PFImporter::substituteMacros(const QMap<QString,QString> ¯os,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool has_known_macros = false;
|
bool has_known_macros = false;
|
||||||
if (any_macro_instance.indexIn(buffer) != -1)
|
int idx = 0;
|
||||||
|
while ((idx = buffer.indexOf(any_macro_instance, idx)) != -1)
|
||||||
{
|
{
|
||||||
QString macro_name = any_macro_instance.cap(1);
|
QString macro_name = any_macro_instance.cap(1);
|
||||||
if (macros.contains(macro_name)) has_known_macros = true;
|
if (macros.contains(macro_name)) has_known_macros = true;
|
||||||
else
|
else undefined_macros.insert(macro_name);
|
||||||
|
idx++;
|
||||||
|
}
|
||||||
|
if (!has_known_macros) break;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach(QString macro_name, undefined_macros)
|
||||||
{
|
{
|
||||||
QString err;
|
QString err;
|
||||||
err = QObject::tr("Warning: Macro %1 is undefined").arg(macro_name);
|
err = QObject::tr("Warning: Macro %1 is undefined").arg(macro_name);
|
||||||
*logger << err.toUtf8().constData();
|
*logger << err.toUtf8().constData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!has_known_macros) break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user