String->OUString, with accompanying tests
This commit is contained in:
committed by
Michael Meeks
parent
1af9425e82
commit
034350a509
@@ -0,0 +1,33 @@
|
||||
$(eval $(call gb_CppunitTest_CppunitTest,basic_scanner))
|
||||
|
||||
$(eval $(call gb_CppunitTest_add_exception_objects,basic_scanner, \
|
||||
basic/qa/cppunit/test_scanner \
|
||||
))
|
||||
|
||||
$(eval $(call gb_CppunitTest_add_library_objects,basic_scanner,sb))
|
||||
|
||||
# add a list of all needed libraries here
|
||||
$(eval $(call gb_CppunitTest_add_linked_libs,basic_scanner, \
|
||||
comphelper \
|
||||
cppu \
|
||||
cppuhelper \
|
||||
sal \
|
||||
salhelper \
|
||||
sb \
|
||||
sfx \
|
||||
sot \
|
||||
svl \
|
||||
svt \
|
||||
tl \
|
||||
utl \
|
||||
vcl \
|
||||
xcr \
|
||||
$(gb_STDLIBS) \
|
||||
))
|
||||
|
||||
$(eval $(call gb_CppunitTest_set_include,basic_scanner,\
|
||||
-I$(realpath $(SRCDIR)/basic/source/inc) \
|
||||
-I$(realpath $(SRCDIR)/basic/inc) \
|
||||
$$(INCLUDE) \
|
||||
-I$(OUTDIR)/inc \
|
||||
))
|
||||
@@ -37,4 +37,8 @@ $(eval $(call gb_Module_add_targets,basic,\
|
||||
StaticLibrary_sample \
|
||||
))
|
||||
|
||||
$(eval $(call gb_Module_add_check_targets,basic,\
|
||||
CppunitTest_basic_scanner \
|
||||
))
|
||||
|
||||
# vim: set noet sw=4 ts=4:
|
||||
|
||||
@@ -0,0 +1,578 @@
|
||||
#include "sal/config.h"
|
||||
#include "sal/precppunit.hxx"
|
||||
|
||||
#include "cppunit/TestAssert.h"
|
||||
#include "cppunit/TestFixture.h"
|
||||
#include "cppunit/extensions/HelperMacros.h"
|
||||
#include "cppunit/plugin/TestPlugIn.h"
|
||||
|
||||
#include "osl/file.hxx"
|
||||
#include "osl/process.h"
|
||||
|
||||
#include "scanner.hxx"
|
||||
|
||||
namespace
|
||||
{
|
||||
struct Symbol
|
||||
{
|
||||
sal_uInt16 line;
|
||||
sal_uInt16 col1;
|
||||
sal_uInt16 col2;
|
||||
rtl::OUString text;
|
||||
double number;
|
||||
SbxDataType type;
|
||||
};
|
||||
|
||||
/**
|
||||
* Perform tests on Scanner.
|
||||
*/
|
||||
class ScannerTest : public CppUnit::TestFixture
|
||||
{
|
||||
private:
|
||||
void testBlankLines();
|
||||
void testOperators();
|
||||
void testAlphanum();
|
||||
void testComments();
|
||||
void testGoto();
|
||||
void testExclamation();
|
||||
void testNumbers();
|
||||
|
||||
// Adds code needed to register the test suite
|
||||
CPPUNIT_TEST_SUITE(ScannerTest);
|
||||
|
||||
// Declares the method as a test to call
|
||||
CPPUNIT_TEST(testBlankLines);
|
||||
CPPUNIT_TEST(testOperators);
|
||||
CPPUNIT_TEST(testAlphanum);
|
||||
CPPUNIT_TEST(testComments);
|
||||
CPPUNIT_TEST(testGoto);
|
||||
CPPUNIT_TEST(testExclamation);
|
||||
CPPUNIT_TEST(testNumbers);
|
||||
|
||||
// End of test suite definition
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
public:
|
||||
void setUp()
|
||||
{
|
||||
}
|
||||
|
||||
void tearDown()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
const static rtl::OUString cr(RTL_CONSTASCII_USTRINGPARAM("\n"));
|
||||
const static rtl::OUString rem(RTL_CONSTASCII_USTRINGPARAM("REM"));
|
||||
const static rtl::OUString asdf(RTL_CONSTASCII_USTRINGPARAM("asdf"));
|
||||
const static rtl::OUString dot(RTL_CONSTASCII_USTRINGPARAM("."));
|
||||
const static rtl::OUString goto_(RTL_CONSTASCII_USTRINGPARAM("goto"));
|
||||
const static rtl::OUString excl(RTL_CONSTASCII_USTRINGPARAM("!"));
|
||||
|
||||
std::vector<Symbol> getSymbols(const rtl::OUString& source)
|
||||
{
|
||||
std::vector<Symbol> symbols;
|
||||
SbiScanner scanner(source);
|
||||
while(scanner.NextSym())
|
||||
{
|
||||
Symbol symbol;
|
||||
symbol.line = scanner.GetLine();
|
||||
symbol.col1 = scanner.GetCol1();
|
||||
symbol.col2 = scanner.GetCol2();
|
||||
symbol.text = scanner.GetSym();
|
||||
symbol.number = scanner.GetDbl();
|
||||
symbol.type = scanner.GetType();
|
||||
symbols.push_back(symbol);
|
||||
}
|
||||
return symbols;
|
||||
}
|
||||
|
||||
void ScannerTest::testBlankLines()
|
||||
{
|
||||
const rtl::OUString source1(RTL_CONSTASCII_USTRINGPARAM(""));
|
||||
const rtl::OUString source2(RTL_CONSTASCII_USTRINGPARAM("\r\n"));
|
||||
const rtl::OUString source3(RTL_CONSTASCII_USTRINGPARAM("\n"));
|
||||
const rtl::OUString source4(RTL_CONSTASCII_USTRINGPARAM("\r"));
|
||||
const rtl::OUString source5(RTL_CONSTASCII_USTRINGPARAM("\r\n\r\n"));
|
||||
const rtl::OUString source6(RTL_CONSTASCII_USTRINGPARAM("\n\r"));
|
||||
const rtl::OUString source7(RTL_CONSTASCII_USTRINGPARAM("\n\r\n"));
|
||||
const rtl::OUString source8(RTL_CONSTASCII_USTRINGPARAM("\r\n\r"));
|
||||
const rtl::OUString source9(RTL_CONSTASCII_USTRINGPARAM(" "));
|
||||
|
||||
std::vector<Symbol> symbols;
|
||||
symbols = getSymbols(source1);
|
||||
CPPUNIT_ASSERT(symbols.empty());
|
||||
|
||||
symbols = getSymbols(source2);
|
||||
CPPUNIT_ASSERT(symbols.size() == 1);
|
||||
CPPUNIT_ASSERT(symbols[0].text == cr);
|
||||
CPPUNIT_ASSERT(symbols[0].type == SbxVARIANT);
|
||||
|
||||
symbols = getSymbols(source3);
|
||||
CPPUNIT_ASSERT(symbols.size() == 1);
|
||||
CPPUNIT_ASSERT(symbols[0].text == cr);
|
||||
CPPUNIT_ASSERT(symbols[0].type == SbxVARIANT);
|
||||
|
||||
symbols = getSymbols(source4);
|
||||
CPPUNIT_ASSERT(symbols.size() == 1);
|
||||
CPPUNIT_ASSERT(symbols[0].text == cr);
|
||||
CPPUNIT_ASSERT(symbols[0].type == SbxVARIANT);
|
||||
|
||||
symbols = getSymbols(source5);
|
||||
CPPUNIT_ASSERT(symbols.size() == 2);
|
||||
CPPUNIT_ASSERT(symbols[0].text == cr);
|
||||
CPPUNIT_ASSERT(symbols[0].type == SbxVARIANT);
|
||||
CPPUNIT_ASSERT(symbols[1].text == cr);
|
||||
CPPUNIT_ASSERT(symbols[1].type == SbxVARIANT);
|
||||
|
||||
symbols = getSymbols(source6);
|
||||
CPPUNIT_ASSERT(symbols.size() == 2);
|
||||
CPPUNIT_ASSERT(symbols[0].text == cr);
|
||||
CPPUNIT_ASSERT(symbols[0].type == SbxVARIANT);
|
||||
CPPUNIT_ASSERT(symbols[1].text == cr);
|
||||
CPPUNIT_ASSERT(symbols[1].type == SbxVARIANT);
|
||||
|
||||
symbols = getSymbols(source7);
|
||||
CPPUNIT_ASSERT(symbols.size() == 2);
|
||||
CPPUNIT_ASSERT(symbols[0].text == cr);
|
||||
CPPUNIT_ASSERT(symbols[0].type == SbxVARIANT);
|
||||
CPPUNIT_ASSERT(symbols[1].text == cr);
|
||||
CPPUNIT_ASSERT(symbols[1].type == SbxVARIANT);
|
||||
|
||||
symbols = getSymbols(source8);
|
||||
CPPUNIT_ASSERT(symbols.size() == 2);
|
||||
CPPUNIT_ASSERT(symbols[0].text == cr);
|
||||
CPPUNIT_ASSERT(symbols[0].type == SbxVARIANT);
|
||||
CPPUNIT_ASSERT(symbols[1].text == cr);
|
||||
CPPUNIT_ASSERT(symbols[1].type == SbxVARIANT);
|
||||
|
||||
symbols = getSymbols(source9);
|
||||
CPPUNIT_ASSERT(symbols.size() == 1);
|
||||
CPPUNIT_ASSERT(symbols[0].text == cr);
|
||||
CPPUNIT_ASSERT(symbols[0].type == SbxVARIANT);
|
||||
}
|
||||
|
||||
void ScannerTest::testOperators()
|
||||
{
|
||||
const rtl::OUString sourceE(RTL_CONSTASCII_USTRINGPARAM("="));
|
||||
const rtl::OUString sourceLT(RTL_CONSTASCII_USTRINGPARAM("<"));
|
||||
const rtl::OUString sourceGT(RTL_CONSTASCII_USTRINGPARAM(">"));
|
||||
const rtl::OUString sourceLTE(RTL_CONSTASCII_USTRINGPARAM("<="));
|
||||
const rtl::OUString sourceGTE(RTL_CONSTASCII_USTRINGPARAM(">="));
|
||||
const rtl::OUString sourceEE(RTL_CONSTASCII_USTRINGPARAM("=="));
|
||||
const rtl::OUString sourceNE(RTL_CONSTASCII_USTRINGPARAM("<>"));
|
||||
const rtl::OUString sourceA(RTL_CONSTASCII_USTRINGPARAM(":="));
|
||||
|
||||
std::vector<Symbol> symbols;
|
||||
|
||||
symbols = getSymbols(sourceE);
|
||||
CPPUNIT_ASSERT(symbols.size() == 2);
|
||||
CPPUNIT_ASSERT(symbols[0].text == sourceE);
|
||||
CPPUNIT_ASSERT(symbols[0].type == SbxVARIANT);
|
||||
CPPUNIT_ASSERT(symbols[1].text == cr);
|
||||
CPPUNIT_ASSERT(symbols[1].type == SbxVARIANT);
|
||||
|
||||
symbols = getSymbols(sourceLT);
|
||||
CPPUNIT_ASSERT(symbols.size() == 2);
|
||||
CPPUNIT_ASSERT(symbols[0].text == sourceLT);
|
||||
CPPUNIT_ASSERT(symbols[0].type == SbxVARIANT);
|
||||
CPPUNIT_ASSERT(symbols[1].text == cr);
|
||||
CPPUNIT_ASSERT(symbols[1].type == SbxVARIANT);
|
||||
|
||||
symbols = getSymbols(sourceGT);
|
||||
CPPUNIT_ASSERT(symbols.size() == 2);
|
||||
CPPUNIT_ASSERT(symbols[0].text == sourceGT);
|
||||
CPPUNIT_ASSERT(symbols[0].type == SbxVARIANT);
|
||||
CPPUNIT_ASSERT(symbols[1].text == cr);
|
||||
CPPUNIT_ASSERT(symbols[1].type == SbxVARIANT);
|
||||
|
||||
symbols = getSymbols(sourceLTE);
|
||||
CPPUNIT_ASSERT(symbols.size() == 2);
|
||||
CPPUNIT_ASSERT(symbols[0].text == sourceLTE);
|
||||
CPPUNIT_ASSERT(symbols[0].type == SbxVARIANT);
|
||||
CPPUNIT_ASSERT(symbols[1].text == cr);
|
||||
CPPUNIT_ASSERT(symbols[1].type == SbxVARIANT);
|
||||
|
||||
symbols = getSymbols(sourceGTE);
|
||||
CPPUNIT_ASSERT(symbols.size() == 2);
|
||||
CPPUNIT_ASSERT(symbols[0].text == sourceGTE);
|
||||
CPPUNIT_ASSERT(symbols[0].type == SbxVARIANT);
|
||||
CPPUNIT_ASSERT(symbols[1].text == cr);
|
||||
CPPUNIT_ASSERT(symbols[1].type == SbxVARIANT);
|
||||
|
||||
symbols = getSymbols(sourceEE);
|
||||
CPPUNIT_ASSERT(symbols.size() == 3);
|
||||
CPPUNIT_ASSERT(symbols[0].text == sourceE);
|
||||
CPPUNIT_ASSERT(symbols[0].type == SbxVARIANT);
|
||||
CPPUNIT_ASSERT(symbols[1].text == sourceE);
|
||||
CPPUNIT_ASSERT(symbols[1].type == SbxVARIANT);
|
||||
CPPUNIT_ASSERT(symbols[2].text == cr);
|
||||
CPPUNIT_ASSERT(symbols[2].type == SbxVARIANT);
|
||||
|
||||
symbols = getSymbols(sourceNE);
|
||||
CPPUNIT_ASSERT(symbols.size() == 2);
|
||||
CPPUNIT_ASSERT(symbols[0].text == sourceNE);
|
||||
CPPUNIT_ASSERT(symbols[0].type == SbxVARIANT);
|
||||
CPPUNIT_ASSERT(symbols[1].text == cr);
|
||||
CPPUNIT_ASSERT(symbols[1].type == SbxVARIANT);
|
||||
|
||||
symbols = getSymbols(sourceA);
|
||||
CPPUNIT_ASSERT(symbols.size() == 2);
|
||||
CPPUNIT_ASSERT(symbols[0].text == sourceA);
|
||||
CPPUNIT_ASSERT(symbols[0].type == SbxVARIANT);
|
||||
CPPUNIT_ASSERT(symbols[1].text == cr);
|
||||
CPPUNIT_ASSERT(symbols[1].type == SbxVARIANT);
|
||||
}
|
||||
|
||||
void ScannerTest::testAlphanum()
|
||||
{
|
||||
const rtl::OUString source1(RTL_CONSTASCII_USTRINGPARAM("asdfghefg"));
|
||||
const rtl::OUString source2(RTL_CONSTASCII_USTRINGPARAM("1asfdasfd"));
|
||||
const rtl::OUString source3(RTL_CONSTASCII_USTRINGPARAM("AdfsaAUdsl10987"));
|
||||
const rtl::OUString source4(RTL_CONSTASCII_USTRINGPARAM("asdfa_mnvcnm"));
|
||||
const rtl::OUString source5(RTL_CONSTASCII_USTRINGPARAM("_asdf1"));
|
||||
const rtl::OUString source6(RTL_CONSTASCII_USTRINGPARAM("_6"));
|
||||
const rtl::OUString source7(RTL_CONSTASCII_USTRINGPARAM("joxclk_"));
|
||||
const rtl::OUString source8(RTL_CONSTASCII_USTRINGPARAM(" asdf "));
|
||||
const rtl::OUString source9(RTL_CONSTASCII_USTRINGPARAM(" 19395 asdfa "));
|
||||
const rtl::OUString source10(RTL_CONSTASCII_USTRINGPARAM("\n1\n2\na sdf"));
|
||||
const rtl::OUString source11(RTL_CONSTASCII_USTRINGPARAM("asdf.asdf"));
|
||||
const rtl::OUString source12(RTL_CONSTASCII_USTRINGPARAM(".."));
|
||||
|
||||
std::vector<Symbol> symbols;
|
||||
|
||||
symbols = getSymbols(source1);
|
||||
CPPUNIT_ASSERT(symbols.size() == 2);
|
||||
CPPUNIT_ASSERT(symbols[0].text == source1);
|
||||
CPPUNIT_ASSERT(symbols[0].type == SbxVARIANT);
|
||||
CPPUNIT_ASSERT(symbols[1].text == cr);
|
||||
CPPUNIT_ASSERT(symbols[1].type == SbxVARIANT);
|
||||
|
||||
symbols = getSymbols(source2);
|
||||
CPPUNIT_ASSERT(symbols.size() == 3);
|
||||
CPPUNIT_ASSERT(symbols[0].text.isEmpty()); // Can't start symbol with a digit
|
||||
CPPUNIT_ASSERT(symbols[0].number == 1);
|
||||
CPPUNIT_ASSERT(symbols[0].type == SbxINTEGER);
|
||||
CPPUNIT_ASSERT(symbols[1].text == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("asfdasfd")));
|
||||
CPPUNIT_ASSERT(symbols[1].type == SbxVARIANT);
|
||||
CPPUNIT_ASSERT(symbols[2].text == cr);
|
||||
CPPUNIT_ASSERT(symbols[2].type == SbxVARIANT);
|
||||
|
||||
symbols = getSymbols(source3);
|
||||
CPPUNIT_ASSERT(symbols.size() == 2);
|
||||
CPPUNIT_ASSERT(symbols[0].text == source3);
|
||||
CPPUNIT_ASSERT(symbols[0].type == SbxVARIANT);
|
||||
CPPUNIT_ASSERT(symbols[1].text == cr);
|
||||
CPPUNIT_ASSERT(symbols[1].type == SbxVARIANT);
|
||||
|
||||
symbols = getSymbols(source4);
|
||||
CPPUNIT_ASSERT(symbols.size() == 2);
|
||||
CPPUNIT_ASSERT(symbols[0].text == source4);
|
||||
CPPUNIT_ASSERT(symbols[0].type == SbxVARIANT);
|
||||
CPPUNIT_ASSERT(symbols[1].text == cr);
|
||||
CPPUNIT_ASSERT(symbols[1].type == SbxVARIANT);
|
||||
|
||||
symbols = getSymbols(source5);
|
||||
CPPUNIT_ASSERT(symbols.size() == 2);
|
||||
CPPUNIT_ASSERT(symbols[0].text == source5);
|
||||
CPPUNIT_ASSERT(symbols[0].type == SbxVARIANT);
|
||||
CPPUNIT_ASSERT(symbols[1].text == cr);
|
||||
CPPUNIT_ASSERT(symbols[1].type == SbxVARIANT);
|
||||
|
||||
symbols = getSymbols(source6);
|
||||
CPPUNIT_ASSERT(symbols.size() == 2);
|
||||
CPPUNIT_ASSERT(symbols[0].text == source6);
|
||||
CPPUNIT_ASSERT(symbols[0].type == SbxVARIANT);
|
||||
CPPUNIT_ASSERT(symbols[1].text == cr);
|
||||
CPPUNIT_ASSERT(symbols[1].type == SbxVARIANT);
|
||||
|
||||
symbols = getSymbols(source7);
|
||||
CPPUNIT_ASSERT(symbols.size() == 2);
|
||||
CPPUNIT_ASSERT(symbols[0].text == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("joxclk_")));
|
||||
CPPUNIT_ASSERT(symbols[0].type == SbxVARIANT);
|
||||
CPPUNIT_ASSERT(source7 == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("joxclk "))); // Change the trailing '_' to a ' '
|
||||
CPPUNIT_ASSERT(symbols[1].text == cr);
|
||||
CPPUNIT_ASSERT(symbols[1].type == SbxVARIANT);
|
||||
|
||||
symbols = getSymbols(source8);
|
||||
CPPUNIT_ASSERT(symbols.size() == 2);
|
||||
CPPUNIT_ASSERT(symbols[0].text == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("asdf")));
|
||||
CPPUNIT_ASSERT(symbols[0].type == SbxVARIANT);
|
||||
CPPUNIT_ASSERT(symbols[1].text == cr);
|
||||
CPPUNIT_ASSERT(symbols[1].type == SbxVARIANT);
|
||||
|
||||
symbols = getSymbols(source9);
|
||||
CPPUNIT_ASSERT(symbols.size() == 3);
|
||||
CPPUNIT_ASSERT(symbols[0].text.isEmpty());
|
||||
CPPUNIT_ASSERT(symbols[0].number = 19395);
|
||||
CPPUNIT_ASSERT(symbols[0].type == SbxINTEGER);
|
||||
CPPUNIT_ASSERT(symbols[1].text == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("asdfa")));
|
||||
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);
|
||||
CPPUNIT_ASSERT(symbols[0].type == SbxVARIANT);
|
||||
CPPUNIT_ASSERT(symbols[1].text.isEmpty());
|
||||
CPPUNIT_ASSERT(symbols[1].number == 1);
|
||||
CPPUNIT_ASSERT(symbols[1].type == SbxINTEGER);
|
||||
CPPUNIT_ASSERT(symbols[2].text == cr);
|
||||
CPPUNIT_ASSERT(symbols[2].type == SbxVARIANT);
|
||||
CPPUNIT_ASSERT(symbols[3].text.isEmpty());
|
||||
CPPUNIT_ASSERT(symbols[3].number == 2);
|
||||
CPPUNIT_ASSERT(symbols[3].type == SbxINTEGER);
|
||||
CPPUNIT_ASSERT(symbols[4].text == cr);
|
||||
CPPUNIT_ASSERT(symbols[4].type == SbxVARIANT);
|
||||
CPPUNIT_ASSERT(symbols[5].text.getLength() == 1);
|
||||
CPPUNIT_ASSERT(symbols[5].text[0] == 'a');
|
||||
CPPUNIT_ASSERT(symbols[5].type == SbxVARIANT);
|
||||
CPPUNIT_ASSERT(symbols[6].text == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdf")));
|
||||
CPPUNIT_ASSERT(symbols[6].type == SbxVARIANT);
|
||||
CPPUNIT_ASSERT(symbols[7].text == cr);
|
||||
CPPUNIT_ASSERT(symbols[7].type == SbxVARIANT);
|
||||
|
||||
symbols = getSymbols(source11);
|
||||
CPPUNIT_ASSERT(symbols.size() == 4);
|
||||
CPPUNIT_ASSERT(symbols[0].text == asdf);
|
||||
CPPUNIT_ASSERT(symbols[0].type == SbxVARIANT);
|
||||
CPPUNIT_ASSERT(symbols[1].text == dot);
|
||||
CPPUNIT_ASSERT(symbols[1].type == SbxVARIANT);
|
||||
CPPUNIT_ASSERT(symbols[2].text == asdf);
|
||||
CPPUNIT_ASSERT(symbols[2].type == SbxVARIANT);
|
||||
CPPUNIT_ASSERT(symbols[3].text == cr);
|
||||
CPPUNIT_ASSERT(symbols[3].type == SbxVARIANT);
|
||||
|
||||
symbols = getSymbols(source12);
|
||||
CPPUNIT_ASSERT(symbols.size() == 3);
|
||||
CPPUNIT_ASSERT(symbols[0].text == dot);
|
||||
CPPUNIT_ASSERT(symbols[0].type == SbxVARIANT);
|
||||
CPPUNIT_ASSERT(symbols[1].text == dot);
|
||||
CPPUNIT_ASSERT(symbols[1].type == SbxVARIANT);
|
||||
CPPUNIT_ASSERT(symbols[2].text == cr);
|
||||
CPPUNIT_ASSERT(symbols[2].type == SbxVARIANT);
|
||||
}
|
||||
|
||||
void ScannerTest::testComments()
|
||||
{
|
||||
const rtl::OUString source1(RTL_CONSTASCII_USTRINGPARAM("REM asdf"));
|
||||
const rtl::OUString source2(RTL_CONSTASCII_USTRINGPARAM("REMasdf"));
|
||||
const rtl::OUString source3(RTL_CONSTASCII_USTRINGPARAM("'asdf"));
|
||||
const rtl::OUString source4(RTL_CONSTASCII_USTRINGPARAM("asdf _\n'100"));
|
||||
const rtl::OUString source5(RTL_CONSTASCII_USTRINGPARAM("'asdf _\n100"));
|
||||
const rtl::OUString source6(RTL_CONSTASCII_USTRINGPARAM("'asdf _\n'100"));
|
||||
const rtl::OUString source7(RTL_CONSTASCII_USTRINGPARAM("'asdf _\n 1234 _\n asdf'"));
|
||||
|
||||
std::vector<Symbol> symbols;
|
||||
|
||||
symbols = getSymbols(source1);
|
||||
CPPUNIT_ASSERT(symbols.size() == 1);
|
||||
CPPUNIT_ASSERT(symbols[0].text == rem);
|
||||
CPPUNIT_ASSERT(symbols[0].type == SbxVARIANT);
|
||||
|
||||
symbols = getSymbols(source2);
|
||||
CPPUNIT_ASSERT(symbols.size() == 2);
|
||||
CPPUNIT_ASSERT(symbols[0].text == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("REMasdf")));
|
||||
CPPUNIT_ASSERT(symbols[0].type == SbxVARIANT);
|
||||
CPPUNIT_ASSERT(symbols[1].text == cr);
|
||||
CPPUNIT_ASSERT(symbols[1].type == SbxVARIANT);
|
||||
|
||||
symbols = getSymbols(source3);
|
||||
CPPUNIT_ASSERT(symbols.size() == 1);
|
||||
CPPUNIT_ASSERT(symbols[0].text == rem);
|
||||
CPPUNIT_ASSERT(symbols[0].type == SbxVARIANT);
|
||||
|
||||
symbols = getSymbols(source4);
|
||||
CPPUNIT_ASSERT(symbols.size() == 2);
|
||||
CPPUNIT_ASSERT(symbols[0].text == asdf);
|
||||
CPPUNIT_ASSERT(symbols[0].type == SbxVARIANT);
|
||||
CPPUNIT_ASSERT(symbols[1].text == rem);
|
||||
CPPUNIT_ASSERT(symbols[1].type == SbxVARIANT);
|
||||
|
||||
symbols = getSymbols(source5);
|
||||
CPPUNIT_ASSERT(symbols.size() == 3);
|
||||
CPPUNIT_ASSERT(symbols[0].text == rem);
|
||||
CPPUNIT_ASSERT(symbols[0].type == SbxVARIANT);
|
||||
CPPUNIT_ASSERT(symbols[1].text.isEmpty());
|
||||
CPPUNIT_ASSERT(symbols[1].number == 100);
|
||||
CPPUNIT_ASSERT(symbols[1].type == SbxINTEGER);
|
||||
CPPUNIT_ASSERT(symbols[2].text == cr);
|
||||
CPPUNIT_ASSERT(symbols[2].type == SbxVARIANT);
|
||||
|
||||
symbols = getSymbols(source6);
|
||||
CPPUNIT_ASSERT(symbols.size() == 2);
|
||||
CPPUNIT_ASSERT(symbols[0].text == rem);
|
||||
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);
|
||||
CPPUNIT_ASSERT(symbols[0].type == SbxVARIANT);
|
||||
CPPUNIT_ASSERT(symbols[1].text.isEmpty());
|
||||
CPPUNIT_ASSERT(symbols[1].number == 1234);
|
||||
CPPUNIT_ASSERT(symbols[1].type == SbxINTEGER);
|
||||
CPPUNIT_ASSERT(symbols[2].text == asdf);
|
||||
CPPUNIT_ASSERT(symbols[2].type == SbxVARIANT);
|
||||
CPPUNIT_ASSERT(symbols[3].text == rem);
|
||||
CPPUNIT_ASSERT(symbols[3].type == SbxVARIANT);
|
||||
}
|
||||
|
||||
void ScannerTest::testGoto()
|
||||
{
|
||||
const rtl::OUString source1(RTL_CONSTASCII_USTRINGPARAM("goto"));
|
||||
const rtl::OUString source2(RTL_CONSTASCII_USTRINGPARAM("go to"));
|
||||
const rtl::OUString source3(RTL_CONSTASCII_USTRINGPARAM("go\nto"));
|
||||
|
||||
std::vector<Symbol> symbols;
|
||||
|
||||
symbols = getSymbols(source1);
|
||||
CPPUNIT_ASSERT(symbols.size() == 2);
|
||||
CPPUNIT_ASSERT(symbols[0].text == goto_);
|
||||
CPPUNIT_ASSERT(symbols[0].type == SbxVARIANT);
|
||||
CPPUNIT_ASSERT(symbols[1].text == cr);
|
||||
CPPUNIT_ASSERT(symbols[1].type == SbxVARIANT);
|
||||
|
||||
symbols = getSymbols(source2);
|
||||
CPPUNIT_ASSERT(symbols.size() == 3);
|
||||
CPPUNIT_ASSERT(symbols[0].text == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("go")));
|
||||
CPPUNIT_ASSERT(symbols[0].type == SbxVARIANT);
|
||||
CPPUNIT_ASSERT(symbols[1].text == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("to")));
|
||||
CPPUNIT_ASSERT(symbols[1].type == SbxVARIANT);
|
||||
CPPUNIT_ASSERT(symbols[2].text == cr);
|
||||
CPPUNIT_ASSERT(symbols[2].type == SbxVARIANT);
|
||||
|
||||
symbols = getSymbols(source3);
|
||||
CPPUNIT_ASSERT(symbols.size() == 4);
|
||||
CPPUNIT_ASSERT(symbols[0].text == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("go")));
|
||||
CPPUNIT_ASSERT(symbols[0].type == SbxVARIANT);
|
||||
CPPUNIT_ASSERT(symbols[1].text == cr);
|
||||
CPPUNIT_ASSERT(symbols[1].type == SbxVARIANT);
|
||||
CPPUNIT_ASSERT(symbols[2].text == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("to")));
|
||||
CPPUNIT_ASSERT(symbols[2].type == SbxVARIANT);
|
||||
CPPUNIT_ASSERT(symbols[3].text == cr);
|
||||
CPPUNIT_ASSERT(symbols[3].type == SbxVARIANT);
|
||||
}
|
||||
|
||||
void ScannerTest::testExclamation()
|
||||
{
|
||||
const rtl::OUString source1(RTL_CONSTASCII_USTRINGPARAM("asdf!asdf"));
|
||||
const rtl::OUString source2(RTL_CONSTASCII_USTRINGPARAM("!1234"));
|
||||
const rtl::OUString source3(RTL_CONSTASCII_USTRINGPARAM("!_3"));
|
||||
const rtl::OUString source4(RTL_CONSTASCII_USTRINGPARAM("!$"));
|
||||
const rtl::OUString source5(RTL_CONSTASCII_USTRINGPARAM("!%"));
|
||||
const rtl::OUString source6(RTL_CONSTASCII_USTRINGPARAM("!\n"));
|
||||
|
||||
std::vector<Symbol> symbols;
|
||||
|
||||
symbols = getSymbols(source1);
|
||||
CPPUNIT_ASSERT(symbols.size() == 4);
|
||||
CPPUNIT_ASSERT(symbols[0].text == asdf);
|
||||
CPPUNIT_ASSERT(symbols[1].text == excl);
|
||||
CPPUNIT_ASSERT(symbols[2].text == asdf);
|
||||
CPPUNIT_ASSERT(symbols[3].text == cr);
|
||||
|
||||
symbols = getSymbols(source2);
|
||||
CPPUNIT_ASSERT(symbols.size() == 3);
|
||||
CPPUNIT_ASSERT(symbols[0].text == excl);
|
||||
CPPUNIT_ASSERT(symbols[1].text.isEmpty());
|
||||
CPPUNIT_ASSERT(symbols[1].number == 1234);
|
||||
CPPUNIT_ASSERT(symbols[2].text == cr);
|
||||
|
||||
symbols = getSymbols(source3);
|
||||
CPPUNIT_ASSERT(symbols.size() == 3);
|
||||
CPPUNIT_ASSERT(symbols[0].text == excl);
|
||||
CPPUNIT_ASSERT(symbols[1].text == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("_3")));
|
||||
CPPUNIT_ASSERT(symbols[2].text == cr);
|
||||
|
||||
symbols = getSymbols(source4);
|
||||
CPPUNIT_ASSERT(symbols.size() == 3);
|
||||
CPPUNIT_ASSERT(symbols[0].text == excl);
|
||||
CPPUNIT_ASSERT(symbols[1].text == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("$")));
|
||||
CPPUNIT_ASSERT(symbols[2].text == cr);
|
||||
|
||||
symbols = getSymbols(source5);
|
||||
CPPUNIT_ASSERT(symbols.size() == 3);
|
||||
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);
|
||||
CPPUNIT_ASSERT(symbols[1].text == cr);
|
||||
}
|
||||
|
||||
void ScannerTest::testNumbers()
|
||||
{
|
||||
const rtl::OUString source1(RTL_CONSTASCII_USTRINGPARAM("12345"));
|
||||
const rtl::OUString source2(RTL_CONSTASCII_USTRINGPARAM("1.2.3"));
|
||||
const rtl::OUString source3(RTL_CONSTASCII_USTRINGPARAM("123.4"));
|
||||
const rtl::OUString source4(RTL_CONSTASCII_USTRINGPARAM("0.5"));
|
||||
const rtl::OUString source5(RTL_CONSTASCII_USTRINGPARAM("5.0"));
|
||||
const rtl::OUString source6(RTL_CONSTASCII_USTRINGPARAM("0.0"));
|
||||
const rtl::OUString source7(RTL_CONSTASCII_USTRINGPARAM("-3"));
|
||||
const rtl::OUString source8(RTL_CONSTASCII_USTRINGPARAM("-0.0"));
|
||||
const rtl::OUString source9(RTL_CONSTASCII_USTRINGPARAM("12dE3"));
|
||||
const rtl::OUString source10(RTL_CONSTASCII_USTRINGPARAM("12e3"));
|
||||
|
||||
std::vector<Symbol> symbols;
|
||||
|
||||
symbols = getSymbols(source1);
|
||||
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);
|
||||
CPPUNIT_ASSERT(symbols[1].text == cr);
|
||||
|
||||
symbols = getSymbols(source4);
|
||||
CPPUNIT_ASSERT(symbols.size() == 2);
|
||||
CPPUNIT_ASSERT(symbols[0].number == .5);
|
||||
CPPUNIT_ASSERT(symbols[1].text == cr);
|
||||
|
||||
symbols = getSymbols(source5);
|
||||
CPPUNIT_ASSERT(symbols.size() == 2);
|
||||
CPPUNIT_ASSERT(symbols[0].number == 5);
|
||||
CPPUNIT_ASSERT(symbols[1].text == cr);
|
||||
|
||||
symbols = getSymbols(source6);
|
||||
CPPUNIT_ASSERT(symbols.size() == 2);
|
||||
CPPUNIT_ASSERT(symbols[0].number == 0);
|
||||
CPPUNIT_ASSERT(symbols[1].text == cr);
|
||||
|
||||
symbols = getSymbols(source7);
|
||||
CPPUNIT_ASSERT(symbols.size() == 3);
|
||||
CPPUNIT_ASSERT(symbols[0].text == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-")));
|
||||
CPPUNIT_ASSERT(symbols[1].number == 3);
|
||||
CPPUNIT_ASSERT(symbols[2].text == cr);
|
||||
|
||||
symbols = getSymbols(source8);
|
||||
CPPUNIT_ASSERT(symbols.size() == 3);
|
||||
CPPUNIT_ASSERT(symbols[0].text == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-")));
|
||||
CPPUNIT_ASSERT(symbols[1].number == 0);
|
||||
CPPUNIT_ASSERT(symbols[2].text == cr);
|
||||
|
||||
symbols = getSymbols(source9);
|
||||
CPPUNIT_ASSERT(symbols.size() == 2);
|
||||
CPPUNIT_ASSERT(symbols[0].number == 12000);
|
||||
CPPUNIT_ASSERT(symbols[1].text == cr);
|
||||
|
||||
symbols = getSymbols(source10);
|
||||
CPPUNIT_ASSERT(symbols.size() == 2);
|
||||
CPPUNIT_ASSERT(symbols[0].number == 12000);
|
||||
CPPUNIT_ASSERT(symbols[1].text == cr);
|
||||
}
|
||||
|
||||
// Put the test suite in the registry
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(ScannerTest);
|
||||
} // namespace
|
||||
CPPUNIT_PLUGIN_IMPLEMENT();
|
||||
@@ -676,7 +676,7 @@ void SbiParser::DefXXX()
|
||||
while( !bAbort )
|
||||
{
|
||||
if( Next() != SYMBOL ) break;
|
||||
ch1 = aSym.ToUpperAscii().GetBuffer()[0];
|
||||
ch1 = aSym.toAsciiUpperCase()[0];
|
||||
ch2 = 0;
|
||||
if( Peek() == MINUS )
|
||||
{
|
||||
@@ -684,7 +684,7 @@ void SbiParser::DefXXX()
|
||||
if( Next() != SYMBOL ) Error( SbERR_SYMBOL_EXPECTED );
|
||||
else
|
||||
{
|
||||
ch2 = aSym.ToUpperAscii().GetBuffer()[0];
|
||||
ch2 = aSym.toAsciiUpperCase()[0];
|
||||
if( ch2 < ch1 ) Error( SbERR_SYNTAX ), ch2 = 0;
|
||||
}
|
||||
}
|
||||
@@ -784,7 +784,7 @@ void SbiParser::Option()
|
||||
SbiToken eTok = Next();
|
||||
if( eTok == BINARY )
|
||||
bText = sal_False;
|
||||
else if( eTok == SYMBOL && GetSym().EqualsIgnoreCaseAscii("text") )
|
||||
else if( eTok == SYMBOL && GetSym().equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("text")) )
|
||||
bText = sal_True;
|
||||
else
|
||||
Error( SbERR_EXPECTED, "Text/Binary" );
|
||||
|
||||
@@ -173,7 +173,7 @@ sal_Bool SbiScanner::NextSym()
|
||||
bHash = sal_False;
|
||||
|
||||
eScanType = SbxVARIANT;
|
||||
aSym.Erase();
|
||||
aSym = ::rtl::OUString();
|
||||
bSymbol =
|
||||
bNumber = bSpaces = sal_False;
|
||||
|
||||
@@ -241,7 +241,7 @@ sal_Bool SbiScanner::NextSym()
|
||||
aSym = aLine.copy( n, nCol - n );
|
||||
|
||||
// Special handling for "go to"
|
||||
if( bCompatible && *pLine && aSym.EqualsIgnoreCaseAscii( "go" ) )
|
||||
if( bCompatible && *pLine && aSym.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM("go") ) )
|
||||
{
|
||||
const sal_Unicode* pTestLine = pLine;
|
||||
short nTestCol = nCol;
|
||||
@@ -267,8 +267,15 @@ sal_Bool SbiScanner::NextSym()
|
||||
// (wrong line continuation otherwise)
|
||||
if( !bUsedForHilite && !*pLine && *(pLine-1) == '_' )
|
||||
{
|
||||
aSym.GetBufferAccess(); // #109693 force copy if necessary
|
||||
*((sal_Unicode*)(pLine-1)) = ' '; // cast because of const
|
||||
|
||||
::rtl::OUStringBuffer aLineBuf(aLine);
|
||||
aLineBuf[nCol - 1] = ' '; // just to keep pLine and aLine in sync
|
||||
aLine = aLineBuf.makeStringAndClear();
|
||||
|
||||
::rtl::OUStringBuffer aSymBuf(aSym);
|
||||
aSymBuf[aSymBuf.getLength() - 1] = '_'; // to match behavior from back when GetBufferAccess was used
|
||||
aSym = aSymBuf.makeStringAndClear();
|
||||
}
|
||||
// type recognition?
|
||||
// don't test the exclamation mark
|
||||
@@ -384,7 +391,9 @@ sal_Bool SbiScanner::NextSym()
|
||||
break;
|
||||
default :
|
||||
// treated as an operator
|
||||
pLine--; nCol--; nCol1 = nCol-1; aSym = '&'; return SYMBOL;
|
||||
pLine--; nCol--; nCol1 = nCol-1;
|
||||
aSym = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("&"));
|
||||
return SYMBOL;
|
||||
}
|
||||
bNumber = sal_True;
|
||||
long l = 0;
|
||||
@@ -453,10 +462,12 @@ sal_Bool SbiScanner::NextSym()
|
||||
sal_uInt16 nIdx = 0;
|
||||
do
|
||||
{
|
||||
nIdx = aSym.Search( s, nIdx );
|
||||
nIdx = aSym.indexOf( s, nIdx );
|
||||
if( nIdx == STRING_NOTFOUND )
|
||||
break;
|
||||
aSym.Erase( nIdx, 1 );
|
||||
::rtl::OUStringBuffer aSymBuf(aSym);
|
||||
aSymBuf.remove(nIdx, 1);
|
||||
aSym = aSymBuf.makeStringAndClear();
|
||||
nIdx++;
|
||||
}
|
||||
while( true );
|
||||
@@ -487,10 +498,10 @@ sal_Bool SbiScanner::NextSym()
|
||||
PrevLineCommentLbl:
|
||||
|
||||
if( bPrevLineExtentsComment || (eScanType != SbxSTRING &&
|
||||
( aSym.GetBuffer()[0] == '\'' || aSym.EqualsIgnoreCaseAscii( "REM" ) ) ) )
|
||||
( aSym[0] == '\'' || aSym.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM("REM") ) ) ) )
|
||||
{
|
||||
bPrevLineExtentsComment = sal_False;
|
||||
aSym = String::CreateFromAscii( "REM" );
|
||||
aSym = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("REM"));
|
||||
sal_uInt16 nLen = String( pLine ).Len();
|
||||
if( bCompatible && pLine[ nLen - 1 ] == '_' && pLine[ nLen - 2 ] == ' ' )
|
||||
bPrevLineExtentsComment = sal_True;
|
||||
@@ -505,7 +516,7 @@ eoln:
|
||||
{
|
||||
pLine = NULL;
|
||||
bool bRes = NextSym();
|
||||
if( bVBASupportOn && aSym.GetBuffer()[0] == '.' )
|
||||
if( bVBASupportOn && aSym[0] == '.' )
|
||||
{
|
||||
// object _
|
||||
// .Method
|
||||
@@ -521,7 +532,7 @@ eoln:
|
||||
nLine = nOldLine;
|
||||
nCol1 = nOldCol1;
|
||||
nCol2 = nOldCol2;
|
||||
aSym = '\n';
|
||||
aSym = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\n"));
|
||||
nColLock = 0;
|
||||
return sal_True;
|
||||
}
|
||||
|
||||
+23
-17
@@ -281,19 +281,25 @@ SbiToken SbiTokenizer::Peek()
|
||||
|
||||
// For decompilation. Numbers and symbols return an empty string.
|
||||
|
||||
const String& SbiTokenizer::Symbol( SbiToken t )
|
||||
const ::rtl::OUString& SbiTokenizer::Symbol( SbiToken t )
|
||||
{
|
||||
// character token?
|
||||
if( t < FIRSTKWD )
|
||||
{
|
||||
aSym = (char) t;
|
||||
aSym = ::rtl::OUString::valueOf(sal::static_int_cast<sal_Unicode>(t));
|
||||
return aSym;
|
||||
}
|
||||
switch( t )
|
||||
{
|
||||
case NEG : aSym = '-'; return aSym;
|
||||
case EOS : aSym = String::CreateFromAscii( ":/CRLF" ); return aSym;
|
||||
case EOLN : aSym = String::CreateFromAscii( "CRLF" ); return aSym;
|
||||
case NEG :
|
||||
aSym = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-"));
|
||||
return aSym;
|
||||
case EOS :
|
||||
aSym = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(":/CRLF"));
|
||||
return aSym;
|
||||
case EOLN :
|
||||
aSym = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CRLF"));
|
||||
return aSym;
|
||||
default: break;
|
||||
}
|
||||
TokenTable* tp = pTokTable;
|
||||
@@ -301,12 +307,13 @@ const String& SbiTokenizer::Symbol( SbiToken t )
|
||||
{
|
||||
if( tp->t == t )
|
||||
{
|
||||
aSym = String::CreateFromAscii( tp->s );
|
||||
aSym = ::rtl::OStringToOUString(tp->s, RTL_TEXTENCODING_ASCII_US);
|
||||
return aSym;
|
||||
}
|
||||
}
|
||||
const sal_Unicode *p = aSym.GetBuffer();
|
||||
if (*p <= ' ') aSym = String::CreateFromAscii( "???" );
|
||||
const sal_Unicode *p = aSym.getStr();
|
||||
if (*p <= ' ')
|
||||
aSym = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("???"));
|
||||
return aSym;
|
||||
}
|
||||
|
||||
@@ -337,7 +344,7 @@ SbiToken SbiTokenizer::Next()
|
||||
return eCurTok = EOLN;
|
||||
}
|
||||
|
||||
if( aSym.GetBuffer()[0] == '\n' )
|
||||
if( aSym[0] == '\n' )
|
||||
{
|
||||
bEos = sal_True; return eCurTok = EOLN;
|
||||
}
|
||||
@@ -350,9 +357,9 @@ SbiToken SbiTokenizer::Next()
|
||||
return eCurTok = FIXSTRING;
|
||||
// Special cases of characters that are between "Z" and "a". ICompare()
|
||||
// evaluates the position of these characters in different ways.
|
||||
else if( aSym.GetBuffer()[0] == '^' )
|
||||
else if( aSym[0] == '^' )
|
||||
return eCurTok = EXPON;
|
||||
else if( aSym.GetBuffer()[0] == '\\' )
|
||||
else if( aSym[0] == '\\' )
|
||||
return eCurTok = IDIV;
|
||||
else
|
||||
{
|
||||
@@ -367,17 +374,16 @@ SbiToken SbiTokenizer::Next()
|
||||
{
|
||||
delta = (ub - lb) >> 1;
|
||||
tp = &pTokTable[ lb + delta ];
|
||||
StringCompare res = aSym.CompareIgnoreCaseToAscii( tp->s );
|
||||
sal_Int32 res = aSym.compareToIgnoreAsciiCaseAscii( tp->s );
|
||||
|
||||
if( res == COMPARE_EQUAL )
|
||||
if( res == 0 )
|
||||
goto special;
|
||||
|
||||
if( res == COMPARE_LESS )
|
||||
if( res < 0 )
|
||||
{
|
||||
if ((ub - lb) == 2) ub = lb;
|
||||
else ub = ub - delta;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if ((ub -lb) == 2) lb = ub;
|
||||
@@ -385,7 +391,7 @@ SbiToken SbiTokenizer::Next()
|
||||
}
|
||||
} while( delta );
|
||||
// Symbol? if not >= token
|
||||
sal_Unicode ch = aSym.GetBuffer()[0];
|
||||
sal_Unicode ch = aSym[0];
|
||||
if( !BasicSimpleCharClass::isAlpha( ch, bCompatible ) && !bSymbol )
|
||||
return eCurTok = (SbiToken) (ch & 0x00FF);
|
||||
return eCurTok = SYMBOL;
|
||||
@@ -457,7 +463,7 @@ special:
|
||||
if( bCompatible )
|
||||
{
|
||||
// #129904 Suppress system
|
||||
if( eTok == STOP && aSym.CompareIgnoreCaseToAscii( "system" ) == COMPARE_EQUAL )
|
||||
if( eTok == STOP && aSym.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("system")) )
|
||||
eCurTok = SYMBOL;
|
||||
|
||||
if( eTok == GET && bStartOfLine )
|
||||
|
||||
@@ -55,7 +55,7 @@ struct SbVar {
|
||||
|
||||
struct KeywordSymbolInfo
|
||||
{
|
||||
String m_aKeywordSymbol;
|
||||
::rtl::OUString m_aKeywordSymbol;
|
||||
SbxDataType m_eSbxDataType;
|
||||
SbiToken m_eTok;
|
||||
};
|
||||
|
||||
@@ -46,7 +46,7 @@ class SbiScanner
|
||||
const sal_Unicode* pLine;
|
||||
const sal_Unicode* pSaveLine;
|
||||
protected:
|
||||
String aSym;
|
||||
::rtl::OUString aSym;
|
||||
String aError;
|
||||
SbxDataType eScanType;
|
||||
StarBASIC* pBasic; // instance for error callbacks
|
||||
@@ -96,7 +96,7 @@ public:
|
||||
sal_Bool DoesColonFollow();
|
||||
|
||||
sal_Bool NextSym();
|
||||
const String& GetSym() { return aSym; }
|
||||
const ::rtl::OUString& GetSym() { return aSym; }
|
||||
SbxDataType GetType() { return eScanType; }
|
||||
double GetDbl() { return nVal; }
|
||||
};
|
||||
|
||||
@@ -155,7 +155,7 @@ public:
|
||||
inline sal_Bool IsEos() { return bEos; }
|
||||
|
||||
void Push( SbiToken );
|
||||
const String& Symbol( SbiToken ); // reconversion
|
||||
const ::rtl::OUString& Symbol( SbiToken ); // reconversion
|
||||
|
||||
SbiToken Peek(); // read the next token
|
||||
SbiToken Next(); // read a token
|
||||
|
||||
@@ -413,7 +413,7 @@ public:
|
||||
str.pData->buffer, str.pData->length ) == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
Match against a substring appearing in this string.
|
||||
|
||||
The result is true if and only if the second string appears as a substring
|
||||
@@ -598,6 +598,11 @@ public:
|
||||
return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr ) == 0;
|
||||
}
|
||||
|
||||
sal_Int32 compareToIgnoreAsciiCaseAscii( const sal_Char * asciiStr ) const SAL_THROW(())
|
||||
{
|
||||
return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr );
|
||||
}
|
||||
|
||||
/**
|
||||
Perform a ASCII lowercase comparison of two strings.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user