diff options
Diffstat (limited to 'l10ntools')
-rw-r--r-- | l10ntools/source/merge.cxx | 13 | ||||
-rw-r--r-- | l10ntools/source/po.cxx | 5 |
2 files changed, 13 insertions, 5 deletions
diff --git a/l10ntools/source/merge.cxx b/l10ntools/source/merge.cxx index 8a6964c61fa4..588cb73d8614 100644 --- a/l10ntools/source/merge.cxx +++ b/l10ntools/source/merge.cxx @@ -34,10 +34,15 @@ namespace { OString lcl_NormalizeFilename(std::string_view rFilename) { - return OString(rFilename.substr( - std::max( - rFilename.rfind( '\\' ), - rFilename.rfind( '/' ))+1)); + size_t idx1 = rFilename.rfind( '\\' ); + size_t idx2 = rFilename.rfind( '/' ); + if (idx1 == std::string_view::npos && idx2 == std::string_view::npos) + 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( diff --git a/l10ntools/source/po.cxx b/l10ntools/source/po.cxx index b93126838c99..62d09e1e7407 100644 --- a/l10ntools/source/po.cxx +++ b/l10ntools/source/po.cxx @@ -257,7 +257,10 @@ PoEntry::PoEntry( throw WRONGHELPTEXT; 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); OString sMsgCtxt = |