summaryrefslogtreecommitdiffstats
path: root/third_party/sqlite/src/shell_icu_linux.c
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/sqlite/src/shell_icu_linux.c')
-rwxr-xr-xthird_party/sqlite/src/shell_icu_linux.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/third_party/sqlite/src/shell_icu_linux.c b/third_party/sqlite/src/shell_icu_linux.c
new file mode 100755
index 0000000..8194db5
--- /dev/null
+++ b/third_party/sqlite/src/shell_icu_linux.c
@@ -0,0 +1,26 @@
+/* Copyright 2007 Google Inc. All Rights Reserved.
+**/
+
+#include <limits.h>
+#include <unistd.h>
+#include "unicode/udata.h"
+
+/*
+** This function attempts to load the ICU data tables from a data file.
+** Returns 0 on failure, nonzero on success.
+** This a hack job of icu_utils.cc:Initialize(). It's Chrome-specific code.
+*/
+int sqlite_shell_init_icu() {
+ char bin_dir[PATH_MAX + 1];
+ int bin_dir_size = readlink("/proc/self/exe", bin_dir, PATH_MAX);
+ if (bin_dir_size < 0 || bin_dir_size > PATH_MAX)
+ return 0;
+ bin_dir[bin_dir_size] = 0;;
+
+ u_setDataDirectory(bin_dir);
+ // Only look for the packaged data file;
+ // the default behavior is to look for individual files.
+ UErrorCode err = U_ZERO_ERROR;
+ udata_setFileAccess(UDATA_ONLY_PACKAGES, &err);
+ return err == U_ZERO_ERROR;
+}