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) (unidiff)
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
@@ -521,32 +521,36 @@ void Config::read()
521 f.close(); 521 f.close();
522 522
523 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { 523 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
524 if ( !parse( *it ) ) { 524 if ( !parse( *it ) ) {
525 git = groups.end(); 525 git = groups.end();
526 return; 526 return;
527 } 527 }
528 } 528 }
529} 529}
530 530
531/*! 531/*!
532 \internal 532 \internal
533*/ 533*/
534bool Config::parse( const QString &l ) 534bool Config::parse( const QString &l )
535{ 535{
536 QString line = l.stripWhiteSpace(); 536 QString line = l.stripWhiteSpace();
537
538 if ( line [0] == QChar ( '#' ))
539 return true; // ignore comments
540
537 if ( line[ 0 ] == QChar( '[' ) ) { 541 if ( line[ 0 ] == QChar( '[' ) ) {
538 QString gname = line; 542 QString gname = line;
539 gname = gname.remove( 0, 1 ); 543 gname = gname.remove( 0, 1 );
540 if ( gname[ (int)gname.length() - 1 ] == QChar( ']' ) ) 544 if ( gname[ (int)gname.length() - 1 ] == QChar( ']' ) )
541 gname = gname.remove( gname.length() - 1, 1 ); 545 gname = gname.remove( gname.length() - 1, 1 );
542 git = groups.insert( gname, ConfigGroup() ); 546 git = groups.insert( gname, ConfigGroup() );
543 } else if ( !line.isEmpty() ) { 547 } else if ( !line.isEmpty() ) {
544 if ( git == groups.end() ) 548 if ( git == groups.end() )
545 return FALSE; 549 return FALSE;
546 int eq = line.find( '=' ); 550 int eq = line.find( '=' );
547 if ( eq == -1 ) 551 if ( eq == -1 )
548 return FALSE; 552 return FALSE;
549 QString key = line.left(eq).stripWhiteSpace(); 553 QString key = line.left(eq).stripWhiteSpace();
550 QString value = line.mid(eq+1).stripWhiteSpace(); 554 QString value = line.mid(eq+1).stripWhiteSpace();
551 ( *git ).insert( key, value ); 555 ( *git ).insert( key, value );
552 } 556 }