address potential find/rfind failures
in the conversion in
commit 74957c7d2f
Author: Noel Grandin <noel.grandin@collabora.co.uk>
Date: Wed Apr 13 13:54:22 2022 +0200
use more string_view in l10ntools
where the prior code might have been relying on the -1 returned by
indexOf and lastIndexOd
Change-Id: Ief5dedccbaf4e14e5f59aa3c2f7481ff0bb7e2e8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133027
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
This commit is contained in:
committed by
Stephan Bergmann
parent
6fd447aaf2
commit
b9c806b9e3
@@ -34,10 +34,15 @@ namespace
|
|||||||
{
|
{
|
||||||
OString lcl_NormalizeFilename(std::string_view rFilename)
|
OString lcl_NormalizeFilename(std::string_view rFilename)
|
||||||
{
|
{
|
||||||
return OString(rFilename.substr(
|
size_t idx1 = rFilename.rfind( '\\' );
|
||||||
std::max(
|
size_t idx2 = rFilename.rfind( '/' );
|
||||||
rFilename.rfind( '\\' ),
|
if (idx1 == std::string_view::npos && idx2 == std::string_view::npos)
|
||||||
rFilename.rfind( '/' ))+1));
|
return OString(rFilename);
|
||||||
|
if (idx1 == std::string_view::npos)
|
||||||
|
idx1 = 0;
|
||||||
|
if (idx2 == std::string_view::npos)
|
||||||
|
idx2 = 0;
|
||||||
|
return OString(rFilename.substr(std::max(idx1, idx2)+1));
|
||||||
};
|
};
|
||||||
|
|
||||||
bool lcl_ReadPoChecked(
|
bool lcl_ReadPoChecked(
|
||||||
|
@@ -257,7 +257,10 @@ PoEntry::PoEntry(
|
|||||||
throw WRONGHELPTEXT;
|
throw WRONGHELPTEXT;
|
||||||
|
|
||||||
m_pGenPo.reset( new GenPoEntry() );
|
m_pGenPo.reset( new GenPoEntry() );
|
||||||
OString sReference(rSourceFile.substr(rSourceFile.rfind('/')+1));
|
size_t idx = rSourceFile.rfind('/');
|
||||||
|
if (idx == std::string_view::npos)
|
||||||
|
idx = 0;
|
||||||
|
OString sReference(rSourceFile.substr(idx+1));
|
||||||
m_pGenPo->setReference(sReference);
|
m_pGenPo->setReference(sReference);
|
||||||
|
|
||||||
OString sMsgCtxt =
|
OString sMsgCtxt =
|
||||||
|
Reference in New Issue
Block a user