diff options
Diffstat (limited to 'third_party/sqlite/icu-shell.patch')
-rw-r--r-- | third_party/sqlite/icu-shell.patch | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/third_party/sqlite/icu-shell.patch b/third_party/sqlite/icu-shell.patch new file mode 100644 index 0000000..04a6329 --- /dev/null +++ b/third_party/sqlite/icu-shell.patch @@ -0,0 +1,90 @@ +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); +Index: src/shell_icu_linux.c +=================================================================== +--- src/shell_icu_linux.c 1969-12-31 16:00:00.000000000 -0800 ++++ src/shell_icu_linux.c 2009-09-17 13:48:49.000000000 -0700 +@@ -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; ++} +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; ++} |