From e31496c9382ebdaa6ed1c6889c0d6ecde6f57de7 Mon Sep 17 00:00:00 2001 From: Michael Meeks Date: Fri, 21 Oct 2011 10:08:02 +0100 Subject: misc trivial tweaks, and documentation addition --- basic/Module_basic.mk | 2 +- basic/qa/cppunit/test_scanner.cxx | 22 +++++++--------------- basic/source/comp/scanner.cxx | 10 +++++----- basic/source/comp/token.cxx | 4 ++-- sal/inc/rtl/ustring.hxx | 20 ++++++++++++++++++++ 5 files changed, 35 insertions(+), 23 deletions(-) diff --git a/basic/Module_basic.mk b/basic/Module_basic.mk index d1b5deea0d86..885a0c0353d7 100644 --- a/basic/Module_basic.mk +++ b/basic/Module_basic.mk @@ -39,6 +39,6 @@ $(eval $(call gb_Module_add_targets,basic,\ $(eval $(call gb_Module_add_check_targets,basic,\ CppunitTest_basic_scanner \ -)) +)) # vim: set noet sw=4 ts=4: diff --git a/basic/qa/cppunit/test_scanner.cxx b/basic/qa/cppunit/test_scanner.cxx index f6459a53864f..25f5147f46ff 100644 --- a/basic/qa/cppunit/test_scanner.cxx +++ b/basic/qa/cppunit/test_scanner.cxx @@ -36,7 +36,7 @@ namespace void testGoto(); void testExclamation(); void testNumbers(); - + // Adds code needed to register the test suite CPPUNIT_TEST_SUITE(ScannerTest); @@ -51,14 +51,6 @@ namespace // End of test suite definition CPPUNIT_TEST_SUITE_END(); - public: - void setUp() - { - } - - void tearDown() - { - } }; const static rtl::OUString cr(RTL_CONSTASCII_USTRINGPARAM("\n")); @@ -309,7 +301,7 @@ namespace CPPUNIT_ASSERT(symbols[1].type == SbxVARIANT); CPPUNIT_ASSERT(symbols[2].text == cr); CPPUNIT_ASSERT(symbols[2].type == SbxVARIANT); - + symbols = getSymbols(source10); CPPUNIT_ASSERT(symbols.size() == 8); CPPUNIT_ASSERT(symbols[0].text == cr); @@ -405,7 +397,7 @@ namespace CPPUNIT_ASSERT(symbols[0].type == SbxVARIANT); CPPUNIT_ASSERT(symbols[1].text == rem); CPPUNIT_ASSERT(symbols[1].type == SbxVARIANT); - + symbols = getSymbols(source7); CPPUNIT_ASSERT(symbols.size() == 4); CPPUNIT_ASSERT(symbols[0].text == rem); @@ -471,7 +463,7 @@ namespace CPPUNIT_ASSERT(symbols[0].text == asdf); CPPUNIT_ASSERT(symbols[1].text == excl); CPPUNIT_ASSERT(symbols[2].text == asdf); - CPPUNIT_ASSERT(symbols[3].text == cr); + CPPUNIT_ASSERT(symbols[3].text == cr); symbols = getSymbols(source2); CPPUNIT_ASSERT(symbols.size() == 3); @@ -497,7 +489,7 @@ namespace CPPUNIT_ASSERT(symbols[0].text == excl); CPPUNIT_ASSERT(symbols[1].text == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("%"))); CPPUNIT_ASSERT(symbols[2].text == cr); - + symbols = getSymbols(source6); CPPUNIT_ASSERT(symbols.size() == 2); CPPUNIT_ASSERT(symbols[0].text == excl); @@ -523,12 +515,12 @@ namespace CPPUNIT_ASSERT(symbols.size() == 2); CPPUNIT_ASSERT(symbols[0].number == 12345); CPPUNIT_ASSERT(symbols[1].text == cr); - + symbols = getSymbols(source2); CPPUNIT_ASSERT(symbols.size() == 2); CPPUNIT_ASSERT(symbols[0].number == 1.23); CPPUNIT_ASSERT(symbols[1].text == cr); - + symbols = getSymbols(source3); CPPUNIT_ASSERT(symbols.size() == 2); CPPUNIT_ASSERT(symbols[0].number = 123.4); diff --git a/basic/source/comp/scanner.cxx b/basic/source/comp/scanner.cxx index 998ecbf8aa0d..0211b75292b2 100644 --- a/basic/source/comp/scanner.cxx +++ b/basic/source/comp/scanner.cxx @@ -391,7 +391,7 @@ sal_Bool SbiScanner::NextSym() break; default : // treated as an operator - pLine--; nCol--; nCol1 = nCol-1; + pLine--; nCol--; nCol1 = nCol-1; aSym = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("&")); return SYMBOL; } @@ -459,14 +459,14 @@ sal_Bool SbiScanner::NextSym() // get out duplicate string delimiters String s( cSep ); s += cSep; - sal_uInt16 nIdx = 0; + sal_Int32 nIdx = 0; do { nIdx = aSym.indexOf( s, nIdx ); - if( nIdx == STRING_NOTFOUND ) + if( nIdx < 0 ) break; - ::rtl::OUStringBuffer aSymBuf(aSym); - aSymBuf.remove(nIdx, 1); + ::rtl::OUStringBuffer aSymBuf( aSym ); + aSymBuf.remove( nIdx, 1 ); aSym = aSymBuf.makeStringAndClear(); nIdx++; } diff --git a/basic/source/comp/token.cxx b/basic/source/comp/token.cxx index d09d5390f482..dc8287fe39e4 100644 --- a/basic/source/comp/token.cxx +++ b/basic/source/comp/token.cxx @@ -291,10 +291,10 @@ const ::rtl::OUString& SbiTokenizer::Symbol( SbiToken t ) } switch( t ) { - case NEG : + case NEG : aSym = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-")); return aSym; - case EOS : + case EOS : aSym = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(":/CRLF")); return aSym; case EOLN : diff --git a/sal/inc/rtl/ustring.hxx b/sal/inc/rtl/ustring.hxx index 63bab1894122..edf7c9747962 100644 --- a/sal/inc/rtl/ustring.hxx +++ b/sal/inc/rtl/ustring.hxx @@ -343,6 +343,8 @@ public: @return 0 - if both strings are equal < 0 - if this string is less than the string argument > 0 - if this string is greater than the string argument + + @since UDK 3.2.7 */ sal_Int32 compareTo( const OUString & str, sal_Int32 maxLength ) const SAL_THROW(()) { @@ -598,6 +600,24 @@ public: return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr ) == 0; } + /** + Compares two ASCII strings ignoring case + + The comparison is based on the numeric value of each character in + the strings and return a value indicating their relationship. + Since this method is optimized for performance, the ASCII character + values are not converted in any way. The caller has to make sure that + all ASCII characters are in the allowed range between 0 and + 127. The ASCII string must be NULL-terminated. + This function can't be used for language specific sorting. + + @param asciiStr the 8-Bit ASCII character string to be compared. + @return 0 - if both strings are equal + < 0 - if this string is less than the string argument + > 0 - if this string is greater than the string argument + + @since LibreOffice 3.5 + */ sal_Int32 compareToIgnoreAsciiCaseAscii( const sal_Char * asciiStr ) const SAL_THROW(()) { return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr ); -- cgit