[Libreoffice-commits] core.git: i18npool/source
Stephan Bergmann
sbergman at redhat.com
Thu Jun 26 08:54:44 PDT 2014
i18npool/source/collator/gencoll_rule.cxx | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
New commits:
commit f899ce3db7d5b9127ca95ad0675d1e5b6147e70b
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Jun 26 17:54:05 2014 +0200
ICU's RuleBasedCollator::cloneRuleData is deprecated
Change-Id: Ifc4a74bca5cfe58e420824a8dd85e8c246bbfac3
diff --git a/i18npool/source/collator/gencoll_rule.cxx b/i18npool/source/collator/gencoll_rule.cxx
index 5ba9f5d..8c4abb3 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");
}
More information about the Libreoffice-commits
mailing list