[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: kdelibs/kdecore/kconfig_compiler
From: Waldo Bastian <bastian () kde ! org>
Date: 2004-11-24 16:25:52
Message-ID: 20041124162552.92AAD1B5BC () office ! kde ! org
[Download RAW message or body]
CVS commit by waba:
Abort on invalid and non-unique names with a descriptive error message.
M +28 -2 kconfig_compiler.cpp 1.57
--- kdelibs/kdecore/kconfig_compiler/kconfig_compiler.cpp #1.56:1.57
@@ -52,4 +52,6 @@ static const KCmdLineOptions options[] =
bool globalEnums;
bool itemAccessors;
+QStringList allNames;
+QRegExp *validNameRegexp;
class CfgEntry
@@ -431,5 +433,6 @@ CfgEntry *parseEntry( const QString &gro
}
- if ( name.isEmpty() && key.isEmpty() ) {
+ bool nameIsEmpty = name.isEmpty();
+ if ( nameIsEmpty && key.isEmpty() ) {
kdError() << "Entry must have a name or a key: " << dumpNode(element) << endl;
return 0;
@@ -440,5 +443,5 @@ CfgEntry *parseEntry( const QString &gro
}
- if ( name.isEmpty() ) {
+ if ( nameIsEmpty ) {
name = key;
name.replace( " ", QString::null );
@@ -520,4 +523,25 @@ CfgEntry *parseEntry( const QString &gro
}
+ if (!validNameRegexp->exactMatch(name))
+ {
+ if (nameIsEmpty)
+ kdError() << "The key '" << key << "' can not be used as name for the entry \
because " + "it is not a valid name. You need to specify a valid \
name for this entry." << endl; + else
+ kdError() << "The name '" << name << "' is not a valid name for an entry." << \
endl; + return 0;
+ }
+
+ if (allNames.contains(name))
+ {
+ if (nameIsEmpty)
+ kdError() << "The key '" << key << "' can not be used as name for the entry \
because " + "it does not result in a unique name. You need to \
specify a unique name for this entry." << endl; + else
+ kdError() << "The name '" << name << "' is not unique." << endl;
+ return 0;
+ }
+ allNames.append(name);
+
if (!defaultCode)
{
@@ -766,4 +790,6 @@ int main( int argc, char **argv )
}
+ validNameRegexp = new QRegExp("[a-zA-Z_][a-zA-Z0-9_]*");
+
QString baseDir = QFile::decodeName(args->getOption("directory"));
if (!baseDir.endsWith("/"))
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic