diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2014-06-26 17:54:05 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2014-06-26 17:54:05 +0200 |
commit | f899ce3db7d5b9127ca95ad0675d1e5b6147e70b (patch) | |
tree | 8ccfb8889b279448abbbb90c0636e1488c49471e | |
parent | 0ac652bbc01ab7c9304b5e230695f4193dfadd09 (diff) |
ICU's RuleBasedCollator::cloneRuleData is deprecated
Change-Id: Ifc4a74bca5cfe58e420824a8dd85e8c246bbfac3
-rw-r--r-- | i18npool/source/collator/gencoll_rule.cxx | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/i18npool/source/collator/gencoll_rule.cxx b/i18npool/source/collator/gencoll_rule.cxx index 5ba9f5d31c10..8c4abb3b0f15 100644 --- a/i18npool/source/collator/gencoll_rule.cxx +++ b/i18npool/source/collator/gencoll_rule.cxx @@ -17,7 +17,9 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/config.h> +#include <vector> #include <stdio.h> #include <string.h> #include <stdlib.h> @@ -28,8 +30,6 @@ #include <unicode/tblcoll.h> -U_CAPI void U_EXPORT2 uprv_free(void *mem); - using namespace ::rtl; /* Main Procedure */ @@ -117,17 +117,18 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) RuleBasedCollator *coll = new RuleBasedCollator(reinterpret_cast<const UChar *>(Obuf.getStr()), status); // UChar != sal_Unicode in MinGW if (U_SUCCESS(status)) { - - int32_t len = 0; - uint8_t *data = coll->cloneRuleData(len, status); - - if (U_SUCCESS(status) && data != NULL) - data_write(argv[2], argv[3], data, len); + std::vector<uint8_t> data; + int32_t len = coll->cloneBinary(0, 0, status); + if (status == U_BUFFER_OVERFLOW_ERROR) { + data.resize(len); + status = U_ZERO_ERROR; + len = coll->cloneBinary(data.empty() ? 0 : &data[0], len, status); + } + if (U_SUCCESS(status)) + data_write(argv[2], argv[3], data.empty() ? 0 : &data[0], len); else { printf("Could not get rule data from collator\n"); } - - if (data) uprv_free(data); } else { printf("\nRule parsering error\n"); } |