summaryrefslogtreecommitdiff
path: root/library/config.cpp
authorsandman <sandman>2002-11-01 12:55:33 (UTC)
committer sandman <sandman>2002-11-01 12:55:33 (UTC)
commit14bd24ba233e370b44ec23cab2733289a3387ca7 (patch) (side-by-side diff)
tree5dc1bd3b37521f8817e0cef9fb19446b8d8e09f1 /library/config.cpp
parent2c809a930ac38a95727c777f52e6673e316d25f2 (diff)
downloadopie-14bd24ba233e370b44ec23cab2733289a3387ca7.zip
opie-14bd24ba233e370b44ec23cab2733289a3387ca7.tar.gz
opie-14bd24ba233e370b44ec23cab2733289a3387ca7.tar.bz2
Config ignores comment lines now (all lines that start with a '#'). This is
necessary to load some pixmap themes from KDE and shouldn't change anything else ('#' not at the beginning of a line are not treated as a comment)
Diffstat (limited to 'library/config.cpp') (more/less context) (show whitespace changes)
-rw-r--r--library/config.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/library/config.cpp b/library/config.cpp
index e07eecb..1121cd4 100644
--- a/library/config.cpp
+++ b/library/config.cpp
@@ -513,42 +513,46 @@ void Config::read()
#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
// The below should work, but doesn't in Qt 2.3.0
s.setCodec( QTextCodec::codecForMib( 106 ) );
#else
s.setEncoding( QTextStream::UnicodeUTF8 );
#endif
QStringList list = QStringList::split('\n', s.read() );
f.close();
for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
if ( !parse( *it ) ) {
git = groups.end();
return;
}
}
}
/*!
\internal
*/
bool Config::parse( const QString &l )
{
QString line = l.stripWhiteSpace();
+
+ if ( line [0] == QChar ( '#' ))
+ return true; // ignore comments
+
if ( line[ 0 ] == QChar( '[' ) ) {
QString gname = line;
gname = gname.remove( 0, 1 );
if ( gname[ (int)gname.length() - 1 ] == QChar( ']' ) )
gname = gname.remove( gname.length() - 1, 1 );
git = groups.insert( gname, ConfigGroup() );
} else if ( !line.isEmpty() ) {
if ( git == groups.end() )
return FALSE;
int eq = line.find( '=' );
if ( eq == -1 )
return FALSE;
QString key = line.left(eq).stripWhiteSpace();
QString value = line.mid(eq+1).stripWhiteSpace();
( *git ).insert( key, value );
}
return TRUE;
}