summaryrefslogtreecommitdiff
path: root/i18npool
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2016-01-05 15:41:52 +0100
committerMichael Stahl <mstahl@redhat.com>2016-01-06 13:24:15 +0000
commit0f082936e2f891ea20e6bda063b61ef0842ada8a (patch)
tree847fa4f847e2647440a9c8520f77573cc8225f87 /i18npool
parent2c6e8e4142493dd135003aff16a1709d6e3a29d0 (diff)
Use OUString::replaceAll
...instead of a local function using a static (!) buffer, which just cannot work in a multi-threaded environment. Change-Id: Id28e1c55c32aa2e35cd3c1756f5d392241092a30 (cherry picked from commit c83b55564dab042e3fc1889920cbb4db8fe40117) Reviewed-on: https://gerrit.libreoffice.org/21131 Reviewed-by: Michael Stahl <mstahl@redhat.com> Tested-by: Michael Stahl <mstahl@redhat.com>
Diffstat (limited to 'i18npool')
-rw-r--r--i18npool/source/localedata/localedata.cxx36
1 files changed, 1 insertions, 35 deletions
diff --git a/i18npool/source/localedata/localedata.cxx b/i18npool/source/localedata/localedata.cxx
index d685dd5aa3b8..e91ac3f346fe 100644
--- a/i18npool/source/localedata/localedata.cxx
+++ b/i18npool/source/localedata/localedata.cxx
@@ -816,40 +816,6 @@ LocaleDataImpl::getAllCurrencies( const Locale& rLocale ) throw(RuntimeException
}
-// return a static (!) string resulting from replacing all occurrences of
-// 'oldStr' string in 'formatCode' string with 'newStr' string
-static const sal_Unicode * replace( sal_Unicode const * const formatCode, sal_Unicode const * const oldStr, sal_Unicode const * const newStr)
-{
- // make reasonable assumption of maximum length of formatCode.
-#define MAX_FORMATCODE_LENTH 512
- static sal_Unicode str[MAX_FORMATCODE_LENTH];
-
- if (oldStr[0] == 0) // no replacement requires
- return formatCode;
-
- sal_Int32 i = 0, k = 0;
- while (formatCode[i] > 0 && k < MAX_FORMATCODE_LENTH) {
- sal_Int32 j = 0, last = k;
- // search oldStr in formatCode
- while (formatCode[i] > 0 && oldStr[j] > 0 && k < MAX_FORMATCODE_LENTH) {
- str[k++] = formatCode[i];
- if (formatCode[i++] != oldStr[j++])
- break;
- }
- if (oldStr[j] == 0) {
- // matched string found, do replacement
- k = last; j = 0;
- while (newStr[j] > 0 && k < MAX_FORMATCODE_LENTH)
- str[k++] = newStr[j++];
- }
- }
- if (k >= MAX_FORMATCODE_LENTH) // could not complete replacement, return original formatCode
- return formatCode;
-
- str[k] = 0;
- return str;
-}
-
Sequence< FormatElement > SAL_CALL
LocaleDataImpl::getAllFormats( const Locale& rLocale ) throw(RuntimeException, std::exception)
{
@@ -886,7 +852,7 @@ LocaleDataImpl::getAllFormats( const Locale& rLocale ) throw(RuntimeException, s
for (int i = 0, nOff = 0; i < section[s].formatCount; ++i, nOff += 7, ++f)
{
FormatElement elem(
- replace( formatArray[nOff], section[s].from, section[s].to),
+ OUString(formatArray[nOff]).replaceAll(section[s].from, section[s].to),
formatArray[nOff + 1],
formatArray[nOff + 2],
formatArray[nOff + 3],