Fix a misuse of two-argument std string_view rfind
...introduced in 655b6c2f46
"loplugin:stringviewparam". Unlike its O[U]String lastIndexOf(x, n)
counterpart (which looks for the last x whose end position, exclusive, is <= n),
string_view rfind(x, n) looks for the last x whose start position, inclusive, is
<= n. (So here would have left slash unchanged.) (And the seemingly simpler
jvm_dll.rfind('\\', slash - 1)
would fail when slash is zero, as in that case it would call rfind with a second
argument of npos, i.e., search for the last '\\' in the complete jvm_dll.)
Change-Id: I148a5db860d4b9e9d58a4a8847880a7a7020c5a5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140486
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
This commit is contained in:
@@ -486,7 +486,7 @@ static void load_msvcr(std::u16string_view jvm_dll, std::u16string_view msvcr)
|
||||
// Then check if msvcr71.dll is in the parent folder of where
|
||||
// jvm.dll is. That is currently (1.6.0_22) as far as I know the
|
||||
// normal case.
|
||||
slash = jvm_dll.rfind('\\', slash);
|
||||
slash = jvm_dll.substr(0, slash).rfind('\\');
|
||||
|
||||
if (slash == std::u16string_view::npos)
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user