sal/rtl/bootstrap.cxx | 61 +++++++++++++++++++++++--------------------------- 1 file changed, 29 insertions(+), 32 deletions(-)
New commits: commit 88375fd36899d21d3309cf8333712e02a87d3a91 Author: Emanuel Schorsch <emschor...@google.com> AuthorDate: Sun Oct 3 17:43:39 2021 -0700 Commit: Stephan Bergmann <sberg...@redhat.com> CommitDate: Fri Oct 15 09:59:16 2021 +0200 NoOp refactor to make elif clearer Change-Id: I05be42fde3f2b66d20c337583d8f8f92143bcb58 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123032 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sberg...@redhat.com> diff --git a/sal/rtl/bootstrap.cxx b/sal/rtl/bootstrap.cxx index 4f7a827fd77b..fc551c8ce933 100644 --- a/sal/rtl/bootstrap.cxx +++ b/sal/rtl/bootstrap.cxx @@ -905,10 +905,26 @@ OUString expandMacros( seg[j] = expandMacros(file, seg[j], mode, requestStack); } + if (n == 3 && seg[0] != ".override" && seg[1].isEmpty()) + { + // For backward compatibility, treat ${file::key} the + // same as just ${file:key}: + seg[1] = seg[2]; + n = 2; + } + if (n == 1) { buf.append(lookup(file, mode, false, seg[0], requestStack)); } + else if (n == 2) + { + buf.append( + lookup( + static_cast< Bootstrap_Impl * >( + rtl::Bootstrap(seg[0]).getHandle()), + mode, false, seg[1], requestStack)); + } else if (n == 3 && seg[0] == ".override") { rtl::Bootstrap b(seg[1]); @@ -917,38 +933,19 @@ OUString expandMacros( } else { - if (n == 3 && seg[1].isEmpty()) - { - // For backward compatibility, treat ${file::key} the - // same as just ${file:key}: - seg[1] = seg[2]; - n = 2; - } - - if (n == 2) - { - buf.append( - lookup( - static_cast< Bootstrap_Impl * >( - rtl::Bootstrap(seg[0]).getHandle()), - mode, false, seg[1], requestStack)); - } - else - { - // Going through osl::Profile, this code erroneously - // does not recursively expand macros in the resulting - // replacement text (and if it did, it would fail to - // detect cycles that pass through here): - buf.append( - OStringToOUString( - osl::Profile(seg[0]).readString( - OUStringToOString( - seg[1], RTL_TEXTENCODING_UTF8), - OUStringToOString( - seg[2], RTL_TEXTENCODING_UTF8), - OString()), - RTL_TEXTENCODING_UTF8)); - } + // Going through osl::Profile, this code erroneously + // does not recursively expand macros in the resulting + // replacement text (and if it did, it would fail to + // detect cycles that pass through here): + buf.append( + OStringToOUString( + osl::Profile(seg[0]).readString( + OUStringToOString( + seg[1], RTL_TEXTENCODING_UTF8), + OUStringToOString( + seg[2], RTL_TEXTENCODING_UTF8), + OString()), + RTL_TEXTENCODING_UTF8)); } } else