[Libreoffice-commits] core.git: Branch 'libreoffice-6-4' - basic/qa basic/source

Andreas Heinisch (via logerrit) logerrit at kemper.freedesktop.org
Thu Sep 10 10:52:25 UTC 2020


 basic/qa/cppunit/test_scanner.cxx |   17 +++++++++++++++++
 basic/source/comp/scanner.cxx     |    3 ++-
 2 files changed, 19 insertions(+), 1 deletion(-)

New commits:
commit 3c36d4921cf9d9c4fd33b3e1dd810f7a63d51695
Author:     Andreas Heinisch <andreas.heinisch at yahoo.de>
AuthorDate: Sun Sep 6 09:26:47 2020 +0200
Commit:     Xisco Fauli <xiscofauli at libreoffice.org>
CommitDate: Thu Sep 10 12:51:51 2020 +0200

    tdf#136032 - abort scan of a string beginning with a hashtag
    
    Abort scan of a string beginning with a hashtag, if a comma is found. Otherwise, the compiler raises a syntax error. If
    the string ends with a hashtag too, it will be parsed later checking for
    a date literal.
    
    Change-Id: I078a2302f5c65206367a00fbc584ffa7b9ede031
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102099
    Tested-by: Mike Kaganski <mike.kaganski at collabora.com>
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
    (cherry picked from commit 11292d1cc405e7c3b9e1f374cc7581a63a54b994)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101973
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofauli at libreoffice.org>
    (cherry picked from commit cc17346d682d85b6c083d76cae2d55dcc022e58f)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102120

diff --git a/basic/qa/cppunit/test_scanner.cxx b/basic/qa/cppunit/test_scanner.cxx
index 42cd637cbd44..b5f14bc57691 100644
--- a/basic/qa/cppunit/test_scanner.cxx
+++ b/basic/qa/cppunit/test_scanner.cxx
@@ -46,6 +46,7 @@ namespace
     void testDataType();
     void testHexOctal();
     void testTdf103104();
+    void testTdf136032();
 
     // Adds code needed to register the test suite
     CPPUNIT_TEST_SUITE(ScannerTest);
@@ -62,6 +63,7 @@ namespace
     CPPUNIT_TEST(testDataType);
     CPPUNIT_TEST(testHexOctal);
     CPPUNIT_TEST(testTdf103104);
+    CPPUNIT_TEST(testTdf136032);
 
     // End of test suite definition
     CPPUNIT_TEST_SUITE_END();
@@ -959,6 +961,21 @@ namespace
     CPPUNIT_ASSERT_EQUAL(cr, symbols[3].text);
   }
 
+  void ScannerTest::testTdf136032()
+  {
+    std::vector<Symbol> symbols;
+    sal_Int32 errors;
+
+    // tdf#136032 - abort scan of a string beginning with a hashtag,
+    // if a comma/whitespace is found. Otherwise, the compiler raises a syntax error.
+    symbols = getSymbols("Print #i,\"A#B\"", errors);
+    CPPUNIT_ASSERT_EQUAL(size_t(5), symbols.size());
+    CPPUNIT_ASSERT_EQUAL(0u, static_cast<unsigned int>(errors));
+    symbols = getSymbols("Print #i, \"A#B\"", errors);
+    CPPUNIT_ASSERT_EQUAL(size_t(5), symbols.size());
+    CPPUNIT_ASSERT_EQUAL(0u, static_cast<unsigned int>(errors));
+  }
+
   // Put the test suite in the registry
   CPPUNIT_TEST_SUITE_REGISTRATION(ScannerTest);
 } // namespace
diff --git a/basic/source/comp/scanner.cxx b/basic/source/comp/scanner.cxx
index 7c192b3a0107..7c5a0d7b265d 100644
--- a/basic/source/comp/scanner.cxx
+++ b/basic/source/comp/scanner.cxx
@@ -251,7 +251,8 @@ bool SbiScanner::NextSym()
         do
         {
             nLineTempIdx++;
-        } while (nLineTempIdx < aLine.getLength() && !BasicCharClass::isWhitespace(aLine[nLineTempIdx]) && aLine[nLineTempIdx] != '#');
+        } while (nLineTempIdx < aLine.getLength() && !BasicCharClass::isWhitespace(aLine[nLineTempIdx])
+            && aLine[nLineTempIdx] != '#' && aLine[nLineTempIdx] != ',');
         // leave it if it is a date literal - it will be handled later
         if (nLineTempIdx >= aLine.getLength() || aLine[nLineTempIdx] != '#')
         {


More information about the Libreoffice-commits mailing list