[Libreoffice-commits] core.git: starmath/qa starmath/source

Takeshi Abe tabe at fixedpoint.jp
Wed Apr 27 23:40:58 UTC 2016


 starmath/qa/cppunit/test_nodetotextvisitors.cxx |    3 +++
 starmath/source/parse.cxx                       |    8 ++++++++
 2 files changed, 11 insertions(+)

New commits:
commit 615e3502c5217585501dac27318a2f22847a5605
Author: Takeshi Abe <tabe at fixedpoint.jp>
Date:   Wed Apr 20 20:00:32 2016 +0900

    Resolves: tdf#88320 parsing fails with a subscript number
    
    ... ending with comma and followed by non-space.
    
    Change-Id: Ia00c662e31940270690c64e1840417436565a6c7
    Reviewed-on: https://gerrit.libreoffice.org/24260
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Takeshi Abe <tabe at fixedpoint.jp>

diff --git a/starmath/qa/cppunit/test_nodetotextvisitors.cxx b/starmath/qa/cppunit/test_nodetotextvisitors.cxx
index b0dfaf5..ffa3f59 100644
--- a/starmath/qa/cppunit/test_nodetotextvisitors.cxx
+++ b/starmath/qa/cppunit/test_nodetotextvisitors.cxx
@@ -658,6 +658,9 @@ void Test::testMiscEquivalent()
     // check non-BMP Unicode char
     ParseAndCompare("{\xf0\x9d\x91\x8e}", "\xf0\x9d\x91\x8e", "non-BMP variable in brace");
     ParseAndCompare("{ \xf0\x9d\x91\x8e }", "\xf0\x9d\x91\x8e", "non-BMP variable in brace");
+
+    // tdf#88320
+    ParseAndCompare("A_1,B_2", "A_{1},B_2", "Comma between a digit and non-digit delimits subscript");
 }
 
 void Test::testParser()
diff --git a/starmath/source/parse.cxx b/starmath/source/parse.cxx
index ada838a..6a7d76b 100644
--- a/starmath/source/parse.cxx
+++ b/starmath/source/parse.cxx
@@ -460,6 +460,14 @@ void SmParser::NextToken()
     }
     else if (aRes.TokenType & KParseType::ANY_NUMBER)
     {
+        assert(aRes.EndPos > 0);
+        if ( m_aBufferString[aRes.EndPos-1] == ',' &&
+             aRes.EndPos < nBufLen &&
+             aCC.getType( m_aBufferString, aRes.EndPos ) != UnicodeType::SPACE_SEPARATOR )
+        {
+            // Comma followed by a non-space char is unlikely for decimal/thousands separator.
+            --aRes.EndPos;
+        }
         sal_Int32 n = aRes.EndPos - nRealStart;
         OSL_ENSURE( n >= 0, "length < 0" );
         m_aCurToken.eType      = TNUMBER;


More information about the Libreoffice-commits mailing list