[Libreoffice-commits] core.git: 2 commits - sal/qa vcl/win

Michael Stahl mstahl at redhat.com
Thu Sep 29 21:24:00 UTC 2016


 sal/qa/rtl/strings/test_ostring.cxx          |   20 ++++++++++++++++++++
 sal/qa/rtl/strings/test_oustring_compare.cxx |   22 +++++++++++++++++++++-
 vcl/win/gdi/salfont.cxx                      |    6 +++---
 3 files changed, 44 insertions(+), 4 deletions(-)

New commits:
commit a0687f7e656a137cd0c1661094afc72f466ba629
Author: Michael Stahl <mstahl at redhat.com>
Date:   Thu Sep 29 23:05:53 2016 +0200

    tdf#83306 add unit test for compareWithLength and '\0'
    
    Change-Id: Iba48390035c560ea499c7fd793d5dd84d1f63cf0

diff --git a/sal/qa/rtl/strings/test_ostring.cxx b/sal/qa/rtl/strings/test_ostring.cxx
index 2929b78..ffdd468 100644
--- a/sal/qa/rtl/strings/test_ostring.cxx
+++ b/sal/qa/rtl/strings/test_ostring.cxx
@@ -19,9 +19,11 @@ namespace {
 class Test: public CppUnit::TestFixture {
 private:
     void testStartsWithIgnoreAsciiCase();
+    void testCompareTo();
 
     CPPUNIT_TEST_SUITE(Test);
     CPPUNIT_TEST(testStartsWithIgnoreAsciiCase);
+    CPPUNIT_TEST(testCompareTo);
     CPPUNIT_TEST_SUITE_END();
 };
 
@@ -85,6 +87,24 @@ void Test::testStartsWithIgnoreAsciiCase() {
     }
 }
 
+void Test::testCompareTo()
+{
+    // test that embedded NUL does not stop the compare
+    sal_Char str1[2] = { '\0', 'x' };
+    sal_Char str2[2] = { '\0', 'y' };
+
+    OString s1(str1, 2);
+    OString s2(str2, 2);
+    CPPUNIT_ASSERT(s1.compareTo(s1) == 0);
+    CPPUNIT_ASSERT(s2.compareTo(s2) == 0);
+    CPPUNIT_ASSERT(s1.compareTo(s2) < 0);
+    CPPUNIT_ASSERT(s2.compareTo(s1) > 0);
+    CPPUNIT_ASSERT(s1.compareTo(OString(s2 + "y")) < 0);
+    CPPUNIT_ASSERT(s2.compareTo(OString(s1 + "x")) > 0);
+    CPPUNIT_ASSERT(OString(s1 + "x").compareTo(s2) < 0);
+    CPPUNIT_ASSERT(OString(s2 + "y").compareTo(s1) > 0);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 }
diff --git a/sal/qa/rtl/strings/test_oustring_compare.cxx b/sal/qa/rtl/strings/test_oustring_compare.cxx
index 4f056e1..77f2fb7 100644
--- a/sal/qa/rtl/strings/test_oustring_compare.cxx
+++ b/sal/qa/rtl/strings/test_oustring_compare.cxx
@@ -29,12 +29,13 @@ class Compare: public CppUnit::TestFixture
 {
 private:
     void equalsIgnoreAsciiCaseAscii();
-
     void compareToIgnoreAsciiCase();
+    void compareTo();
 
 CPPUNIT_TEST_SUITE(Compare);
 CPPUNIT_TEST(equalsIgnoreAsciiCaseAscii);
 CPPUNIT_TEST(compareToIgnoreAsciiCase);
+CPPUNIT_TEST(compareTo);
 CPPUNIT_TEST_SUITE_END();
 };
 
@@ -74,4 +75,23 @@ void test::oustring::Compare::compareToIgnoreAsciiCase()
         rtl::OUString("A").compareToIgnoreAsciiCase("_") > 0);
 }
 
+void test::oustring::Compare::compareTo()
+{
+    // test that embedded NUL does not stop the compare
+    // this sort of thing is how we assing shape ids in oox
+    sal_Unicode str1[2] = { '\0', 'x' };
+    sal_Unicode str2[2] = { '\0', 'y' };
+
+    OUString s1(str1, 2);
+    OUString s2(str2, 2);
+    CPPUNIT_ASSERT(s1.compareTo(s1) == 0);
+    CPPUNIT_ASSERT(s2.compareTo(s2) == 0);
+    CPPUNIT_ASSERT(s1.compareTo(s2) < 0);
+    CPPUNIT_ASSERT(s2.compareTo(s1) > 0);
+    CPPUNIT_ASSERT(s1.compareTo(OUString(s2 + "y")) < 0);
+    CPPUNIT_ASSERT(s2.compareTo(OUString(s1 + "x")) > 0);
+    CPPUNIT_ASSERT(OUString(s1 + "x").compareTo(s2) < 0);
+    CPPUNIT_ASSERT(OUString(s2 + "y").compareTo(s1) > 0);
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit d3db7589f14ea1874095a66810e64577a6f004b0
Author: Michael Stahl <mstahl at redhat.com>
Date:   Thu Sep 29 22:39:55 2016 +0200

    vcl: fix some mysterious WNT font cache file
    
    Apparently VCL maintains a mysterious fontnames.dat file in the user
    config, but it's currently completely borked because the "styleName" is
    written differently than it is read.  Also increment the magic number to
    ignore existing invalid files.
    
    (presumably regression from 5c24789ca33d7b2b0c39626208cf0708fb470d95)
    
    Change-Id: Id94eef1c56ab928d3d2e43ec13d9a5d91b37df90

diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index f7ad89a..9741098 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -87,7 +87,7 @@ private:
 protected:
     OUString OptimizeURL( const OUString& rURL ) const;
 
-    enum{ MAGIC = 0x12349876 }; // change if fontattrcache format changes
+    enum{ MAGIC = 0x12346789 }; // change if fontattrcache format changes
 
 public:
             ImplFontAttrCache(const OUString& rCacheFileName,
@@ -139,8 +139,8 @@ ImplFontAttrCache::ImplFontAttrCache( const OUString& rFileNameURL, const OUStri
         aCacheFile.ReadInt16(n);
         aDFA.SetSymbolFlag(n != 0);
 
-        OUString styleName;
-        aCacheFile.ReadByteStringLine( styleName, RTL_TEXTENCODING_UTF8 );
+        OUString const styleName = read_uInt16_lenPrefixed_uInt8s_ToOUString(
+                aCacheFile, RTL_TEXTENCODING_UTF8);
         aDFA.SetStyleName( styleName );
 
         aFontAttributes[ aFontFileURL ] = aDFA;


More information about the Libreoffice-commits mailing list