| Index: third_party/sqlite/patches/0009-Custom-shell.c-helpers-to-load-Chromium-s-ICU-data.patch
|
| diff --git a/third_party/sqlite/patches/0009-Custom-shell.c-helpers-to-load-Chromium-s-ICU-data.patch b/third_party/sqlite/patches/0009-Custom-shell.c-helpers-to-load-Chromium-s-ICU-data.patch
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..a8d2ad0d8cf27ceead97cfce4254a9b3cd9a70c6
|
| --- /dev/null
|
| +++ b/third_party/sqlite/patches/0009-Custom-shell.c-helpers-to-load-Chromium-s-ICU-data.patch
|
| @@ -0,0 +1,145 @@
|
| +From 787cbd4344a6ab9c5915b77dfd02f91697f60b01 Mon Sep 17 00:00:00 2001
|
| +From: "tc@google.com" <tc@google.com>
|
| +Date: Tue, 6 Jan 2009 22:39:41 +0000
|
| +Subject: [PATCH 09/23] Custom shell.c helpers to load Chromium's ICU data.
|
| +
|
| +History uses fts3 with an icu-based segmenter. These changes allow building a
|
| +sqlite3 binary for Linux or Windows which can read those files.
|
| +
|
| +Original review URL: https://codereview.chromium.org/42250
|
| +---
|
| + third_party/sqlite/src/Makefile.linux-gcc | 7 ++++++
|
| + third_party/sqlite/src/main.mk | 2 +-
|
| + third_party/sqlite/src/src/shell.c | 10 +++++++++
|
| + third_party/sqlite/src/src/shell_icu_linux.c | 27 +++++++++++++++++++++++
|
| + third_party/sqlite/src/src/shell_icu_win.c | 32 ++++++++++++++++++++++++++++
|
| + 5 files changed, 77 insertions(+), 1 deletion(-)
|
| + create mode 100644 third_party/sqlite/src/src/shell_icu_linux.c
|
| + create mode 100644 third_party/sqlite/src/src/shell_icu_win.c
|
| +
|
| +diff --git a/third_party/sqlite/src/Makefile.linux-gcc b/third_party/sqlite/src/Makefile.linux-gcc
|
| +index e631816..f60f1a1 100644
|
| +--- a/third_party/sqlite/src/Makefile.linux-gcc
|
| ++++ b/third_party/sqlite/src/Makefile.linux-gcc
|
| +@@ -86,6 +86,13 @@ OPTS += -DOS_UNIX=1
|
| + # purposes.
|
| + OPTS += -DDEFAULT_ENABLE_RECOVER=1
|
| +
|
| ++# Support for loading Chromium ICU data in sqlite3.
|
| ++ifeq ($(shell uname -s),Darwin)
|
| ++SHELL_ICU =
|
| ++else
|
| ++SHELL_ICU = $(TOP)/src/shell_icu_linux.c -licuuc
|
| ++endif
|
| ++
|
| + #### The suffix to add to executable files. ".exe" for windows.
|
| + # Nothing for unix.
|
| + #
|
| +diff --git a/third_party/sqlite/src/main.mk b/third_party/sqlite/src/main.mk
|
| +index 65dd690..d20103f 100644
|
| +--- a/third_party/sqlite/src/main.mk
|
| ++++ b/third_party/sqlite/src/main.mk
|
| +@@ -358,7 +358,7 @@ libsqlite3.a: $(LIBOBJ)
|
| +
|
| + sqlite3$(EXE): $(TOP)/src/shell.c libsqlite3.a sqlite3.h
|
| + $(TCCX) $(READLINE_FLAGS) -o sqlite3$(EXE) \
|
| +- $(TOP)/src/shell.c \
|
| ++ $(TOP)/src/shell.c $(SHELL_ICU) \
|
| + libsqlite3.a $(LIBREADLINE) $(TLIBS) $(THREADLIB)
|
| +
|
| + # This target creates a directory named "tsrc" and fills it with
|
| +diff --git a/third_party/sqlite/src/src/shell.c b/third_party/sqlite/src/src/shell.c
|
| +index aab70b2..ffb4698 100644
|
| +--- a/third_party/sqlite/src/src/shell.c
|
| ++++ b/third_party/sqlite/src/src/shell.c
|
| +@@ -2663,6 +2663,16 @@ int main(int argc, char **argv){
|
| + int i;
|
| + int rc = 0;
|
| +
|
| ++ /* Begin evanm patch. */
|
| ++#if !defined(__APPLE__)
|
| ++ 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]);
|
| ++ }
|
| ++#endif /* !defined(__APPLE__) */
|
| ++ /* End evanm patch. */
|
| ++
|
| + Argv0 = argv[0];
|
| + main_init(&data);
|
| + stdin_is_interactive = isatty(0);
|
| +diff --git a/third_party/sqlite/src/src/shell_icu_linux.c b/third_party/sqlite/src/src/shell_icu_linux.c
|
| +new file mode 100644
|
| +index 0000000..4ad0e42
|
| +--- /dev/null
|
| ++++ b/third_party/sqlite/src/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;
|
| ++}
|
| +diff --git a/third_party/sqlite/src/src/shell_icu_win.c b/third_party/sqlite/src/src/shell_icu_win.c
|
| +new file mode 100644
|
| +index 0000000..67ebbf4
|
| +--- /dev/null
|
| ++++ b/third_party/sqlite/src/src/shell_icu_win.c
|
| +@@ -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;
|
| ++}
|
| +--
|
| +2.2.1
|
| +
|
|
|