1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
History uses fts3 with an icu-based segmenter. These changes allow
building a sqlite3 binary which can read those files.
Index: src/shell.c
===================================================================
--- src/shell.c 2009-09-04 13:37:43.000000000 -0700
+++ src/shell.c 2009-09-15 11:32:08.000000000 -0700
@@ -3007,6 +3007,14 @@
int i;
int rc = 0;
+ /* Begin evanm patch. */
+ extern int sqlite_shell_init_icu();
+ if( !sqlite_shell_init_icu() ){
+ fprintf(stderr, "%s: warning: couldn't find icudt38.dll; "
+ "queries against ICU FTS tables will fail.\n", argv[0]);
+ }
+ /* End evanm patch. */
+
Argv0 = argv[0];
main_init(&data);
stdin_is_interactive = isatty(0);
diff --git src/shell_icu_linux.c src/shell_icu_linux.c
new file mode 100644
index 0000000..4ad0e42
--- /dev/null
+++ src/shell_icu_linux.c
@@ -0,0 +1,27 @@
+/* Copyright 2007 Google Inc. All Rights Reserved.
+**/
+
+#include <limits.h>
+#include <unistd.h>
+#include "unicode/putil.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;
+}
Index: src/shell_icu_win.c
===================================================================
--- src/shell_icu_win.c 1969-12-31 16:00:00.000000000 -0800
+++ src/shell_icu_win.c 2011-03-03 14:29:11.000000000 -0700
@@ -0,0 +1,32 @@
+/* Copyright 2011 Google Inc. All Rights Reserved.
+**/
+
+#include <windows.h>
+#include "unicode/udata.h"
+
+/*
+** This function attempts to load the ICU data tables from a DLL.
+** Returns 0 on failure, nonzero on success.
+** This a hack job of icu_utils.cc:Initialize(). It's Chrome-specific code.
+*/
+
+#define ICU_DATA_SYMBOL "icudt" U_ICU_VERSION_SHORT "_dat"
+int sqlite_shell_init_icu() {
+ HMODULE module;
+ FARPROC addr;
+ UErrorCode err;
+
+ // Chrome dropped U_ICU_VERSION_SHORT from the icu data dll name.
+ module = LoadLibrary(L"icudt.dll");
+ if (!module)
+ return 0;
+
+ addr = GetProcAddress(module, ICU_DATA_SYMBOL);
+ if (!addr)
+ return 0;
+
+ err = U_ZERO_ERROR;
+ udata_setCommonData(addr, &err);
+
+ return 1;
+}
|