Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/sqlite/src/src/utf.c |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | static const unsigned char sqlite3Utf8Trans1[] = { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
2 | 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
3 | 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
4 | 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
5 | 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
6 | 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
7 | 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
8 | 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
9 | 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x00, 0x00, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
10 | }; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
11 | u32 sqlite3Utf8Read( | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
12 | const unsigned char **pz | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
13 | ){ | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
14 | unsigned int c; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
15 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
16 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
17 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
18 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
19 | c = *((*pz)++); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
20 | if( c>=0xc0
| 1741-1126423 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
21 | c = sqlite3Utf8Trans1[c-0xc0]; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
22 | while( (*(*
| 1126423-3306782 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
23 | c = (c<<6) + (0x3f & *((*pz)++)); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
24 | } executed 3306782 times by 1 test: end of block Executed by:
| 3306782 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
25 | if( c<0x80
| 52-1126371 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
26 | || (
| 2048-1124323 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
27 | || (
executed 2106 times by 1 test: end of block Executed by:
| 6-1124317 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
28 | } executed 1126423 times by 1 test: end of block Executed by:
| 1126423 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
29 | return executed 1128164 times by 1 test: c;return c; Executed by:
executed 1128164 times by 1 test: return c; Executed by:
| 1128164 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
30 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
31 | __attribute__((noinline)) int sqlite3VdbeMemTranslate(Mem *pMem, u8 desiredEnc){ | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
32 | int len; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
33 | unsigned char *zOut; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
34 | unsigned char *zIn; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
35 | unsigned char *zTerm; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
36 | unsigned char *z; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
37 | unsigned int c; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
38 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
39 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
40 | ((void) (0)) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
41 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
42 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
43 | ((void) (0)) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
44 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
45 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
46 | ((void) (0)) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
47 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
48 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
49 | ((void) (0)) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
50 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
51 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
52 | ((void) (0)) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
53 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
54 | if( pMem->enc!=1
| 228-2895 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
55 | u8 temp; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
56 | int rc; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
57 | rc = sqlite3VdbeMemMakeWriteable(pMem); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
58 | if( rc!=0
| 0-228 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
59 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
60 | ((void) (0)) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
61 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
62 | return never executed: 7;return 7; never executed: return 7; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
63 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
64 | zIn = (u8*)pMem->z; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
65 | zTerm = &zIn[pMem->n&~1]; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
66 | while( zIn<zTerm
| 228-5803 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
67 | temp = *zIn; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
68 | *zIn = *(zIn+1); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
69 | zIn++; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
70 | *zIn++ = temp; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
71 | } executed 5803 times by 1 test: end of block Executed by:
| 5803 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
72 | pMem->enc = desiredEnc; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
73 | goto executed 228 times by 1 test: translate_out;goto translate_out; Executed by:
executed 228 times by 1 test: goto translate_out; Executed by:
| 228 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
74 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
75 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
76 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
77 | if( desiredEnc==1
| 1225-2667 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
78 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
79 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
80 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
81 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
82 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
83 | pMem->n &= ~1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
84 | len = pMem->n * 2 + 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
85 | } executed 2667 times by 1 test: else{end of block Executed by:
| 2667 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
86 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
87 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
88 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
89 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
90 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
91 | len = pMem->n * 2 + 2; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
92 | } executed 1225 times by 1 test: end of block Executed by:
| 1225 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
93 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
94 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
95 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
96 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
97 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
98 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
99 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
100 | zIn = (u8*)pMem->z; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
101 | zTerm = &zIn[pMem->n]; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
102 | zOut = sqlite3DbMallocRaw(pMem->db, len); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
103 | if( !zOut
| 0-3892 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
104 | return never executed: 7;return 7; never executed: return 7; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
105 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
106 | z = zOut; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
107 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
108 | if( pMem->enc==1
| 1225-2667 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
109 | if( desiredEnc==2
| 368-857 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
110 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
111 | while( zIn<zTerm
| 857-8983 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
112 | c = *(zIn++); if( c>=0xc0
executed 1615 times by 1 test: if( c<0x80end of block Executed by:
never executed: }end of block executed 1110 times by 1 test: ;end of block Executed by:
| 0-7873 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
113 | { if( c<=0xFFFF
executed 8983 times by 1 test: else{ *z++ = (u8)(((c>>10)&0x003F) + (((c-0x10000)>>10)&0x00C0)); *z++ = (u8)(0x00D8 + (((c-0x10000)>>18)&0x03)); *z++ = (u8)(c&0x00FF); *z++ = (u8)(0x00DC + ((c>>8)&0x03)); }end of block Executed by:
never executed: };end of block | 0-8983 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
114 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
115 | } executed 857 times by 1 test: else{end of block Executed by:
| 857 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
116 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
117 | ((void) (0)) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
118 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
119 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
120 | while( zIn<zTerm
| 368-4629 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
121 | c = *(zIn++); if( c>=0xc0
executed 1732 times by 1 test: if( c<0x80end of block Executed by:
executed 7 times by 1 test: }end of block Executed by:
executed 1125 times by 1 test: ;end of block Executed by:
| 0-3504 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
122 | { if( c<=0xFFFF
executed 4629 times by 1 test: else{ *z++ = (u8)(0x00D8 + (((c-0x10000)>>18)&0x03)); *z++ = (u8)(((c>>10)&0x003F) + (((c-0x10000)>>10)&0x00C0)); *z++ = (u8)(0x00DC + ((c>>8)&0x03)); *z++ = (u8)(c&0x00FF); }end of block Executed by:
never executed: };end of block | 0-4629 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
123 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
124 | } executed 368 times by 1 test: end of block Executed by:
| 368 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
125 | pMem->n = (int)(z - zOut); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
126 | *z++ = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
127 | } executed 1225 times by 1 test: else{end of block Executed by:
| 1225 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
128 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
129 | ((void) (0)) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
130 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
131 | if( pMem->enc==2
| 201-2466 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
132 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
133 | while( zIn<zTerm
| 2466-98974 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
134 | { c = (*zIn++); c += ((*zIn++)<<8); if( c>=0xD800
never executed: };end of block | 0-98372 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
135 | { if( c<0x00080
executed 96755 times by 1 test: else if( c<0x00800end of block Executed by:
executed 1207 times by 1 test: else if( c<0x10000end of block Executed by:
executed 1012 times by 1 test: else{ *z++ = 0xF0 + (u8)((c>>18) & 0x07); *z++ = 0x80 + (u8)((c>>12) & 0x3F); *z++ = 0x80 + (u8)((c>>6) & 0x3F); *z++ = 0x80 + (u8)(c & 0x3F); }end of block Executed by:
never executed: };end of block | 0-96755 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
136 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
137 | } executed 2466 times by 1 test: else{end of block Executed by:
| 2466 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
138 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
139 | while( zIn<zTerm
| 201-3303 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
140 | { c = ((*zIn++)<<8); c += (*zIn++); if( c>=0xD800
never executed: };end of block | 0-3001 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
141 | { if( c<0x00080
executed 2187 times by 1 test: else if( c<0x00800end of block Executed by:
executed 607 times by 1 test: else if( c<0x10000end of block Executed by:
executed 509 times by 1 test: else{ *z++ = 0xF0 + (u8)((c>>18) & 0x07); *z++ = 0x80 + (u8)((c>>12) & 0x3F); *z++ = 0x80 + (u8)((c>>6) & 0x3F); *z++ = 0x80 + (u8)(c & 0x3F); }end of block Executed by:
never executed: };end of block | 0-2187 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
142 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
143 | } executed 201 times by 1 test: end of block Executed by:
| 201 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
144 | pMem->n = (int)(z - zOut); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
145 | } executed 2667 times by 1 test: end of block Executed by:
| 2667 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
146 | *z = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
147 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
148 | ((void) (0)) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
149 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
150 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
151 | c = pMem->flags; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
152 | sqlite3VdbeMemRelease(pMem); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
153 | pMem->flags = 0x0002|0x0200|(c&(0x001f|0x8000)); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
154 | pMem->enc = desiredEnc; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
155 | pMem->z = (char*)zOut; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
156 | pMem->zMalloc = pMem->z; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
157 | pMem->szMalloc = sqlite3DbMallocSize(pMem->db, pMem->z); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
158 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
159 | translate_out: code before this statement executed 3892 times by 1 test: translate_out: Executed by:
| 3892 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
160 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
161 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
162 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
163 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
164 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
165 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
166 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
167 | return executed 4120 times by 1 test: 0;return 0; Executed by:
executed 4120 times by 1 test: return 0; Executed by:
| 4120 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
168 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
169 | int sqlite3VdbeMemHandleBom(Mem *pMem){ | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
170 | int rc = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
171 | u8 bom = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
172 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
173 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
174 | ((void) (0)) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
175 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
176 | if( pMem->n>1
| 2-2509 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
177 | u8 b1 = *(u8 *)pMem->z; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
178 | u8 b2 = *(((u8 *)pMem->z) + 1); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
179 | if( b1==0xFE
| 1-2475 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
180 | bom = 3; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
181 | } executed 33 times by 1 test: end of block Executed by:
| 33 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
182 | if( b1==0xFF
| 2-2474 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
183 | bom = 2; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
184 | } executed 33 times by 1 test: end of block Executed by:
| 33 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
185 | } executed 2509 times by 1 test: end of block Executed by:
| 2509 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
186 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
187 | if( bom
| 66-2445 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
188 | rc = sqlite3VdbeMemMakeWriteable(pMem); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
189 | if( rc==0
| 0-66 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
190 | pMem->n -= 2; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
191 | memmove(pMem->z, &pMem->z[2], pMem->n); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
192 | pMem->z[pMem->n] = '\0'; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
193 | pMem->z[pMem->n+1] = '\0'; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
194 | pMem->flags |= 0x0200; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
195 | pMem->enc = bom; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
196 | } executed 66 times by 1 test: end of block Executed by:
| 66 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
197 | } executed 66 times by 1 test: end of block Executed by:
| 66 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
198 | return executed 2511 times by 1 test: rc;return rc; Executed by:
executed 2511 times by 1 test: return rc; Executed by:
| 2511 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
199 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
200 | int sqlite3Utf8CharLen(const char *zIn, int nByte){ | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
201 | int r = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
202 | const u8 *z = (const u8*)zIn; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
203 | const u8 *zTerm; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
204 | if( nByte>=0
| 881-77156 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
205 | zTerm = &z[nByte]; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
206 | } executed 77156 times by 436 tests: else{end of block Executed by:
| 77156 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
207 | zTerm = (const u8*)(-1); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
208 | } executed 881 times by 1 test: end of block Executed by:
| 881 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
209 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
210 | ((void) (0)) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
211 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
212 | while( *
| 2606-3433298 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
213 | { if( (*(
executed 104 times by 1 test: }end of block Executed by:
executed 78 times by 1 test: };end of block Executed by:
| 78-3357789 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
214 | r++; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
215 | } executed 3357867 times by 436 tests: end of block Executed by:
| 3357867 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
216 | return executed 78037 times by 436 tests: r;return r; Executed by:
executed 78037 times by 436 tests: return r; Executed by:
| 78037 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
217 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
218 | char *sqlite3Utf16to8(sqlite3 *db, const void *z, int nByte, u8 enc){ | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
219 | Mem m; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
220 | memset(&m, 0, sizeof(m)); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
221 | m.db = db; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
222 | sqlite3VdbeMemSetStr(&m, z, nByte, enc, ((sqlite3_destructor_type)0)); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
223 | sqlite3VdbeChangeEncoding(&m, 1); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
224 | if( db->mallocFailed
| 0-1751 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
225 | sqlite3VdbeMemRelease(&m); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
226 | m.z = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
227 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
228 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
229 | ((void) (0)) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
230 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
231 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
232 | ((void) (0)) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
233 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
234 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
235 | ((void) (0)) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
236 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
237 | return executed 1751 times by 1 test: m.z;return m.z; Executed by:
executed 1751 times by 1 test: return m.z; Executed by:
| 1751 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
238 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
239 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
240 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
241 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
242 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
243 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
244 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
245 | int sqlite3Utf16ByteLen(const void *zIn, int nChar){ | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
246 | int c; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
247 | unsigned char const *z = zIn; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
248 | int n = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
249 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
250 | if( 2==3
| 0-1727 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
251 | while( n<nChar
| 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
252 | { c = ((*z++)<<8); c += (*z++); if( c>=0xD800
never executed: };end of block | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
253 | n++; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
254 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
255 | } never executed: else{end of block | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
256 | while( n<nChar
| 1727-87352 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
257 | { c = (*z++); c += ((*z++)<<8); if( c>=0xD800
never executed: };end of block | 0-87352 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
258 | n++; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
259 | } executed 87352 times by 1 test: end of block Executed by:
| 87352 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
260 | } executed 1727 times by 1 test: end of block Executed by:
| 1727 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
261 | return executed 1727 times by 1 test: (int)(z-(unsigned char const *)zIn);return (int)(z-(unsigned char const *)zIn); Executed by:
executed 1727 times by 1 test: return (int)(z-(unsigned char const *)zIn); Executed by:
| 1727 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
262 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
263 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
264 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
265 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
266 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
267 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
268 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
269 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
270 | void sqlite3UtfSelfTest(void){ | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
271 | unsigned int i, t; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
272 | unsigned char zBuf[20]; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
273 | unsigned char *z; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
274 | int n; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
275 | unsigned int c; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
276 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
277 | for(i=0; i<0x00110000
| 1-1114112 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
278 | z = zBuf; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
279 | { if( i<0x00080
executed 128 times by 1 test: else if( i<0x00800end of block Executed by:
executed 1920 times by 1 test: else if( i<0x10000end of block Executed by:
executed 63488 times by 1 test: else{ *z++ = 0xF0 + (u8)((i>>18) & 0x07); *z++ = 0x80 + (u8)((i>>12) & 0x3F); *z++ = 0x80 + (u8)((i>>6) & 0x3F); *z++ = 0x80 + (u8)(i & 0x3F); }end of block Executed by:
executed 1048576 times by 1 test: };end of block Executed by:
| 128-1113984 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
280 | n = (int)(z-zBuf); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
281 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
282 | ((void) (0)) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
283 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
284 | z[0] = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
285 | z = zBuf; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
286 | c = sqlite3Utf8Read((const u8**)&z); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
287 | t = i; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
288 | if( i>=0xD800
executed 2048 times by 1 test: t = 0xFFFD; Executed by:
| 2048-1058816 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
289 | if( (
executed 2 times by 1 test: t = 0xFFFD; Executed by:
| 2-1114110 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
290 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
291 | ((void) (0)) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
292 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
293 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
294 | ((void) (0)) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
295 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
296 | } executed 1114112 times by 1 test: end of block Executed by:
| 1114112 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
297 | for(i=0; i<0x00110000
| 1-1114112 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
298 | if( i>=0xD800
executed 2048 times by 1 test: continue; Executed by:
| 2048-1058816 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
299 | z = zBuf; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
300 | { if( i<=0xFFFF
executed 63488 times by 1 test: else{ *z++ = (u8)(((i>>10)&0x003F) + (((i-0x10000)>>10)&0x00C0)); *z++ = (u8)(0x00D8 + (((i-0x10000)>>18)&0x03)); *z++ = (u8)(i&0x00FF); *z++ = (u8)(0x00DC + ((i>>8)&0x03)); }end of block Executed by:
executed 1048576 times by 1 test: };end of block Executed by:
| 63488-1048576 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
301 | n = (int)(z-zBuf); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
302 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
303 | ((void) (0)) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
304 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
305 | z[0] = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
306 | z = zBuf; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
307 | { c = (*z++); c += ((*z++)<<8); if( c>=0xD800
executed 1048576 times by 1 test: };end of block Executed by:
| 8192-1056768 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
308 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
309 | ((void) (0)) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
310 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
311 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
312 | ((void) (0)) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
313 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
314 | } executed 1112064 times by 1 test: end of block Executed by:
| 1112064 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
315 | for(i=0; i<0x00110000
| 1-1114112 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
316 | if( i>=0xD800
executed 2048 times by 1 test: continue; Executed by:
| 2048-1058816 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
317 | z = zBuf; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
318 | { if( i<=0xFFFF
executed 63488 times by 1 test: else{ *z++ = (u8)(0x00D8 + (((i-0x10000)>>18)&0x03)); *z++ = (u8)(((i>>10)&0x003F) + (((i-0x10000)>>10)&0x00C0)); *z++ = (u8)(0x00DC + ((i>>8)&0x03)); *z++ = (u8)(i&0x00FF); }end of block Executed by:
executed 1048576 times by 1 test: };end of block Executed by:
| 63488-1048576 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
319 | n = (int)(z-zBuf); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
320 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
321 | ((void) (0)) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
322 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
323 | z[0] = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
324 | z = zBuf; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
325 | { c = ((*z++)<<8); c += (*z++); if( c>=0xD800
executed 1048576 times by 1 test: };end of block Executed by:
| 8192-1056768 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
326 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
327 | ((void) (0)) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
328 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
329 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
330 | ((void) (0)) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
331 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
332 | } executed 1112064 times by 1 test: end of block Executed by:
| 1112064 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
333 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
Switch to Source code | Preprocessed file |