summaryrefslogtreecommitdiffstats
path: root/third_party/sqlite/safe-tolower.patch
blob: c42bb065b7302ad1897be7c50dab59a3eb10c54e (plain)
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
93
94
95
96
97
This patch removes the usage of tolower() in fts code, which is not locale
neutral and causes problem in some locales such as Turkish.
See http://crbug.com/15261 for details.
An upstream ticket was also created for this issue:
http://www.sqlite.org/src/tktview/991789d9f3136a0460dc83a33e815c1aa9757c26

Index: ext/fts3/fts3.c
===================================================================
--- ext/fts3/fts3.c	2009-09-04 13:37:41.000000000 -0700
+++ ext/fts3/fts3.c	2009-09-14 18:17:45.000000000 -0700
@@ -326,7 +326,7 @@
   return (c&0x80)==0 ? isspace(c) : 0;
 }
 static int safe_tolower(char c){
-  return (c&0x80)==0 ? tolower(c) : c;
+  return (c>='A' && c<='Z') ? (c-'A'+'a') : c;
 }
 static int safe_isalnum(char c){
   return (c&0x80)==0 ? isalnum(c) : 0;
Index: ext/fts3/fts3_tokenizer1.c
===================================================================
--- ext/fts3/fts3_tokenizer1.c	2009-09-03 13:32:06.000000000 -0700
+++ ext/fts3/fts3_tokenizer1.c	2009-09-02 11:40:21.000000000 -0700
@@ -191,7 +191,7 @@
         ** case-insensitivity.
         */
         unsigned char ch = p[iStartOffset+i];
-        c->pToken[i] = ch<0x80 ? tolower(ch) : ch;
+        c->pToken[i] = (ch>='A' && ch<='Z') ? (ch-'A'+'a') : ch;
       }
       *ppToken = c->pToken;
       *pnBytes = n;
Index: ext/fts1/simple_tokenizer.c
===================================================================
--- ext/fts1/simple_tokenizer.c	2009-09-03 13:32:06.000000000 -0700
+++ ext/fts1/simple_tokenizer.c	2009-09-02 11:40:21.000000000 -0700
@@ -138,7 +138,7 @@
         ** case-insensitivity.
         */
         char ch = c->pCurrent[ii];
-        c->zToken[ii] = (unsigned char)ch<0x80 ? tolower(ch) : ch;
+        c->zToken[ii] = ((ch>='A' && ch<='Z') ? (ch-'A'+'a') : ch);
       }
       c->zToken[n] = '\0';
       *ppToken = c->zToken;
Index: ext/fts1/fts1_tokenizer1.c
===================================================================
--- ext/fts1/fts1_tokenizer1.c	2009-09-03 13:32:06.000000000 -0700
+++ ext/fts1/fts1_tokenizer1.c	2009-09-02 11:40:21.000000000 -0700
@@ -182,7 +182,7 @@
         ** case-insensitivity.
         */
         unsigned char ch = p[iStartOffset+i];
-        c->pToken[i] = ch<0x80 ? tolower(ch) : ch;
+        c->pToken[i] = (ch>='A' && ch<='Z') ? (ch-'A'+'a') : ch;
       }
       *ppToken = c->pToken;
       *pnBytes = n;
Index: ext/fts1/fts1.c
===================================================================
--- ext/fts1/fts1.c	2009-09-04 13:37:41.000000000 -0700
+++ ext/fts1/fts1.c	2009-09-14 18:16:55.000000000 -0700
@@ -208,7 +208,7 @@
   return (c&0x80)==0 ? isspace(c) : 0;
 }
 static int safe_tolower(char c){
-  return (c&0x80)==0 ? tolower(c) : c;
+  return (c>='A' && c<='Z') ? (c-'A'+'a') : c;
 }
 static int safe_isalnum(char c){
   return (c&0x80)==0 ? isalnum(c) : 0;
Index: ext/fts2/fts2.c
===================================================================
--- ext/fts2/fts2.c	2009-09-04 13:37:41.000000000 -0700
+++ ext/fts2/fts2.c	2009-09-14 18:17:02.000000000 -0700
@@ -372,7 +372,7 @@
   return (c&0x80)==0 ? isspace(c) : 0;
 }
 static int safe_tolower(char c){
-  return (c&0x80)==0 ? tolower(c) : c;
+  return (c>='A' && c<='Z') ? (c-'A'+'a') : c;
 }
 static int safe_isalnum(char c){
   return (c&0x80)==0 ? isalnum(c) : 0;
Index: ext/fts2/fts2_tokenizer1.c
===================================================================
--- ext/fts2/fts2_tokenizer1.c	2009-09-03 13:32:06.000000000 -0700
+++ ext/fts2/fts2_tokenizer1.c	2009-09-02 11:40:21.000000000 -0700
@@ -191,7 +191,7 @@
         ** case-insensitivity.
         */
         unsigned char ch = p[iStartOffset+i];
-        c->pToken[i] = ch<0x80 ? tolower(ch) : ch;
+        c->pToken[i] = (ch>='A' && ch<='Z') ? (ch-'A'+'a') : ch;
       }
       *ppToken = c->pToken;
       *pnBytes = n;