[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    Re: KDE/kdelibs/kdecore/config
From:       Jakub Stachowski <stachowski () hypair ! net>
Date:       2008-04-27 8:59:36
Message-ID: 200804271059.36919.stachowski () hypair ! net
[Download RAW message or body]

Dnia niedziela, 27 kwietnia 2008, Oswald Buddenhagen napisaƂ:
> reviewing it again ...
>
> On Mon, Apr 21, 2008 at 02:01:58PM +0000, Jakub Stachowski wrote:
> > SVN commit 799413 by qbast:
> >
> > Ini parsing optimization - avoid using QByteArray and excessive memory
> > copying.
> >
> > --- trunk/KDE/kdelibs/kdecore/config/kconfigini.cpp #799412:799413
> > @@ -165,17 +174,17 @@
> >              if (groupOptionImmutable)
> >                  entryOptions |= KEntryMap::EntryImmutable;
> >
> >              BufferFragment locale;
> >              BufferFragment rawKey;
> >              int start;
> > -            while ((start = aKey.indexOf('[')) >= 0) {
> > +            while ((start = aKey.lastIndexOf('[')) >= 0) {
> >                  int end = aKey.indexOf(']', start);
> > @@ -188,8 +197,9 @@
> >                                  break;
> >                              case 'd':
> >                                  entryOptions |= KEntryMap::EntryDeleted;
> > -                                aKey =
> > printableToString(aKey.left(start), file, lineNo); -                     
> >           entryMap.setEntry(currentGroup, aKey, QByteArray(),
> > entryOptions); +                                aKey = aKey.left(start);
> > +                                printableToString(&aKey, file, lineNo);
> > +                                entryMap.setEntry(currentGroup,
> > aKey.toByteArray(), QByteArray(), entryOptions); goto next_line;
> >                              default:
> >                                  break;
> > @@ -203,17 +213,16 @@
> >                          goto next_line;
> >                      }
> >
> >                      locale = aKey.mid(start + 1,end - start - 1);
> >                      rawKey = aKey.left(end + 1);
> >                  }
> > -                aKey.remove(start, end-start+1);
> > +                aKey.truncate(start);
> >              }
>
> i *think* you broke the case where the immutability marker comes before
> the locale marker:
>
> Key[$i][de_DE]=foo
>
> care to craft a test?

Test attached. Does it look ok?

["doubleattr.patch" (text/x-diff)]

Index: kconfigtest.cpp
===================================================================
--- kconfigtest.cpp	(wersja 799070)
+++ kconfigtest.cpp	(kopia robocza)
@@ -760,7 +760,10 @@
         out << "[$i]" << endl
                 << "entry1=Testing" << endl
             << "[group][$i]" << endl
-            << "[group][subgroup][$i]" << endl;
+            << "[group][subgroup][$i]" << endl
+            << "[group3]" << endl
+            << "entry2=unlocalized" << endl
+            << "entry2[de_DE][$i]=t2" << endl;
     }
 
     KConfig config("immutabletest", KConfig::SimpleConfig);
@@ -771,8 +774,32 @@
     QVERIFY(cg1.isImmutable());
     KConfigGroup cg2 = cg1.group("subgroup");
     QVERIFY(cg2.isImmutable());
+    
 }
 
+void KConfigTest::testDoubleAttribute()
+{
+    {
+        QFile file(KStandardDirs::locateLocal("config", "doubleattrtest"));
+        file.open(QIODevice::WriteOnly|QIODevice::Text);
+        QTextStream out(&file);
+        out.setCodec("UTF-8");
+        out << "[group3]" << endl
+            << "entry2=unlocalized" << endl
+            << "entry2[$i][de_DE]=t2" << endl;
+    }
+    KConfig config("doubleattrtest", KConfig::SimpleConfig);
+    config.setLocale("de_DE");
+    KConfigGroup cg3 = config.group("group3");
+    QVERIFY(!cg3.isImmutable());
+    QCOMPARE(cg3.readEntry("entry2",""), QString("t2"));
+    QVERIFY(cg3.isEntryImmutable("entry2"));
+    config.setLocale("C");
+    QCOMPARE(cg3.readEntry("entry2",""), QString("unlocalized"));
+    QVERIFY(!cg3.isEntryImmutable("entry2"));
+}
+
+
 void KConfigTest::testGroupEscape()
 {
     KConfig config("groupescapetest", KConfig::SimpleConfig);
Index: kconfigtest.h
===================================================================
--- kconfigtest.h	(wersja 799070)
+++ kconfigtest.h	(kopia robocza)
@@ -63,6 +63,7 @@
     void testWriteOnSync();
     void testCreateDir();
     void testSharedConfig();
+    void testDoubleAttribute();
 
     // unrelated
     void testKAboutDataOrganizationDomain();


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic