summaryrefslogtreecommitdiff
path: root/ios
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2014-04-12 20:29:47 +0300
committerTor Lillqvist <tml@collabora.com>2014-04-12 20:34:50 +0300
commiteb6bf90a87b50c60efb3df0f0659e7de3e250ba0 (patch)
tree6169c05c2ebef256c6b9fdc257dcbad0bbc9aa0e /ios
parent11842c66432ffda87e7326d6f0d8342d484bfcbb (diff)
Mmap in the ICU data file and pass it to udata_setCommonData()
Now done in TiledLibreOffice's lo_initialize(), but should probably be done in common LO code instead. Change-Id: I398a703943d13c6d715e4c88ead2a629955fb7c9
Diffstat (limited to 'ios')
-rw-r--r--ios/experimental/TiledLibreOffice/TiledLibreOffice/lo.mm35
1 files changed, 35 insertions, 0 deletions
diff --git a/ios/experimental/TiledLibreOffice/TiledLibreOffice/lo.mm b/ios/experimental/TiledLibreOffice/TiledLibreOffice/lo.mm
index 4f60d05e5c88..8a55107636a0 100644
--- a/ios/experimental/TiledLibreOffice/TiledLibreOffice/lo.mm
+++ b/ios/experimental/TiledLibreOffice/TiledLibreOffice/lo.mm
@@ -7,6 +7,8 @@
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#include <stdlib.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
#include <premac.h>
#import <UIKit/UIKit.h>
@@ -15,6 +17,9 @@
#include <osl/process.h>
#include <touch/touch.h>
+#include <unicode/udata.h>
+#include <unicode/ucnv.h>
+
// generated by solenv/bin/native-code.py:
#include "native-code.mm"
@@ -45,6 +50,36 @@ extern "C" void lo_initialize(NSString *documentPath)
NSString *uno_types = createPaths(@"-env:UNO_TYPES=", app_root_escaped, @[@"offapi.rdb", @"oovbaapi.rdb", @"types.rdb"]);
NSString *uno_services = createPaths(@"-env:UNO_SERVICES=", app_root_escaped, @[@"ure/services.rdb", @"services.rdb"]);
+ int fd = open([[bundlePath stringByAppendingPathComponent:@U_ICUDATA_NAME".dat"] UTF8String], O_RDONLY);
+ if (fd != -1) {
+ struct stat st;
+ if (fstat(fd, &st) != -1
+ && st.st_size < (size_t)-1) {
+ void *icudata = mmap(0, (size_t) st.st_size, PROT_READ, MAP_FILE|MAP_PRIVATE, fd, 0);
+ if (icudata == MAP_FAILED) {
+#if OSL_DEBUG_LEVEL > 0
+ NSLog(@"mmap failed:%s", strerror(errno));
+#endif
+ } else {
+ UErrorCode icuStatus = U_ZERO_ERROR;
+ udata_setCommonData(icudata, &icuStatus);
+ if (U_FAILURE(icuStatus))
+ NSLog(@"udata_setCommonData failed");
+ else {
+#if OSL_DEBUG_LEVEL > 0
+ // Test that ICU works...
+ UConverter *cnv = ucnv_open("iso-8859-3", &icuStatus);
+ NSLog(@"ucnv_open(iso-8859-3)-> %p, err = %s, name=%s",
+ (void *)cnv, u_errorName(icuStatus), (!cnv)?"?":ucnv_getName(cnv,&icuStatus));
+ if (U_SUCCESS(icuStatus))
+ ucnv_close(cnv);
+#endif
+ }
+ }
+ }
+ close(fd);
+ }
+
const char *argv[] = {
[[[NSBundle mainBundle] executablePath] UTF8String],
"-env:URE_INTERNAL_LIB_DIR=file:///",