From 743e6aa211ccd631c811fb57e2050a5b4e8ffbba Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Wed, 22 Sep 2021 17:16:30 +0200 Subject: Extend loplugin:stringviewparam to starts/endsWith: unodevtools Change-Id: I89e559d3956bb0b4b59314d55a3ca57d087b8146 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122471 Tested-by: Jenkins Reviewed-by: Stephan Bergmann --- unodevtools/inc/options.hxx | 4 +++- unodevtools/source/unodevtools/options.cxx | 7 ++++--- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'unodevtools') diff --git a/unodevtools/inc/options.hxx b/unodevtools/inc/options.hxx index d9b557d06a28..5094a11ef5e1 100644 --- a/unodevtools/inc/options.hxx +++ b/unodevtools/inc/options.hxx @@ -21,6 +21,8 @@ #include +#include + #include namespace unodevtools { @@ -32,7 +34,7 @@ bool readOption( OUString * pValue, const char * pOpt, bool readOption( const char * pOpt, - sal_uInt32 * pnIndex, const OUString & aArg); + sal_uInt32 * pnIndex, std::u16string_view aArg); } // end of namespace unodevtools diff --git a/unodevtools/source/unodevtools/options.cxx b/unodevtools/source/unodevtools/options.cxx index eb34e723c38a..8cd2b652f8b0 100644 --- a/unodevtools/source/unodevtools/options.cxx +++ b/unodevtools/source/unodevtools/options.cxx @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -66,12 +67,12 @@ bool readOption( OUString * pValue, const char * pOpt, bool readOption( const char * pOpt, - sal_uInt32 * pnIndex, const OUString & aArg) + sal_uInt32 * pnIndex, std::u16string_view aArg) { OUString aOpt = OUString::createFromAscii(pOpt); - if((aArg.startsWith("-") && aOpt.equalsIgnoreAsciiCase(aArg.subView(1))) || - (aArg.startsWith("--") && aOpt.equalsIgnoreAsciiCase(aArg.subView(2))) ) + if((o3tl::starts_with(aArg, u"-") && aOpt.equalsIgnoreAsciiCase(aArg.substr(1))) || + (o3tl::starts_with(aArg, u"--") && aOpt.equalsIgnoreAsciiCase(aArg.substr(2))) ) { ++(*pnIndex); SAL_INFO("unodevtools", "identified option --" << pOpt); -- cgit