Debian Codegraph @

c/enc/static_dict.c

raw symbols SCIP
1 /* Copyright 2013 Google Inc. All Rights Reserved.
2
3 Distributed under MIT license.
4 See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
5 */
6
7 #include "static_dict.h"cxx . . $ `<file>/c/enc/static_dict.h`/
8
9 #include "../common/dictionary.h"cxx . . $ `<file>/c/common/dictionary.h`/
10 #include "../common/platform.h"cxx . . $ `<file>/c/common/platform.h`/
11 #include "../common/transform.h"cxx . . $ `<file>/c/common/transform.h`/
12 #include "encoder_dict.h"cxx . . $ `<file>/c/enc/encoder_dict.h`/
13 #include "find_match_length.h"cxx . . $ `<file>/c/enc/find_match_length.h`/
14 #include "hash_base.h"cxx . . $ `<file>/c/enc/hash_base.h`/
15
16 #if defined(__cplusplus) || defined(c_plusplus)
17 extern "C" {
18 #endif
19
20 static BROTLI_INLINEcxx . . $ `c/common/platform.h:119:9`! void AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(size_t distance, size_t len, size_t len_code,
21 uint32_tcxx . . $ uint32_t#* matches) {
22 uint32_tcxx . . $ uint32_t# match = (uint32_tcxx . . $ uint32_t#)((distance << 5) + len_code);
23 matches[len] = BROTLI_MINcxx . . $ `c/common/platform.h:522:9`!(uint32_t, matches[len], match);
24 }
25
26 static BROTLI_INLINEcxx . . $ `c/common/platform.h:119:9`! size_t DictMatchLengthcxx . . $ DictMatchLength(bd5e25feb71f877).(const BrotliDictionarycxx . . $ BrotliDictionary#* dictionary,
27 const uint8_tcxx . . $ uint8_t#* data,
28 size_t id,
29 size_t len,
30 size_t maxlen) {
31 const size_t offset = dictionary->offsets_by_lengthcxx . . $ BrotliDictionary#offsets_by_length.[len] + len * id;
32 return FindMatchLengthWithLimitcxx . . $ FindMatchLengthWithLimit(c2ccccc71581acc8).(&dictionary->datacxx . . $ BrotliDictionary#data.[offset], data,
33 BROTLI_MINcxx . . $ `c/common/platform.h:522:9`!(size_t, len, maxlen));
34 }
35
36 static BROTLI_INLINEcxx . . $ `c/common/platform.h:119:9`! BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! IsMatchcxx . . $ IsMatch(351e5cbdc905f5c7).(const BrotliDictionarycxx . . $ BrotliDictionary#* dictionary,
37 DictWordcxx . . $ DictWord# w, const uint8_tcxx . . $ uint8_t#* data, size_t max_length) {
38 if (w.lencxx . . $ DictWord#len. > max_length) {
39 return BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!;
40 } else {
41 const size_t offset = dictionary->offsets_by_lengthcxx . . $ BrotliDictionary#offsets_by_length.[w.lencxx . . $ DictWord#len.] +
42 (size_t)w.lencxx . . $ DictWord#len. * (size_t)w.idxcxx . . $ DictWord#idx.;
43 const uint8_tcxx . . $ uint8_t#* dict = &dictionary->datacxx . . $ BrotliDictionary#data.[offset];
44 if (w.transformcxx . . $ DictWord#transform. == 0) {
45 /* Match against base dictionary word. */
46 return
47 TO_BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:55:9`!(FindMatchLengthWithLimit(dict, data, w.len) == w.len);
48 } else if (w.transformcxx . . $ DictWord#transform. == 10) {
49 /* Match against uppercase first transform.
50 Note that there are only ASCII uppercase words in the lookup table. */
51 return TO_BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:55:9`!(dict[0] >= 'a' && dict[0] <= 'z' &&
52 (dict[0] ^ 32) == data[0] &&
53 FindMatchLengthWithLimit(&dict[1], &data[1], w.len - 1u) ==
54 w.len - 1u);
55 } else {
56 /* Match against uppercase all transform.
57 Note that there are only ASCII uppercase words in the lookup table. */
58 size_t i;
59 for (i = 0; i < w.lencxx . . $ DictWord#len.; ++i) {
60 if (dict[i] >= 'a' && dict[i] <= 'z') {
61 if ((dict[i] ^ 32) != data[i]) return BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!;
62 } else {
63 if (dict[i] != data[i]) return BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!;
64 }
65 }
66 return BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!;
67 }
68 }
69 }
70
71 /* Finds matches for a single static dictionary */
72 static BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! BrotliFindAllStaticDictionaryMatchesForcxx . . $ BrotliFindAllStaticDictionaryMatchesFor(2925cb88ea9b8402).(
73 const BrotliEncoderDictionarycxx . . $ BrotliEncoderDictionary#* dictionary, const uint8_tcxx . . $ uint8_t#* data,
74 size_t min_length, size_t max_length, uint32_tcxx . . $ uint32_t#* matches) {
75 BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! has_found_match = BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!;
76 #if defined(BROTLI_EXPERIMENTAL)
77 if (dictionary->has_words_heavy) {
78 const BrotliTrieNode* node = &dictionary->trie.root;
79 size_t l = 0;
80 while (node && l < max_length) {
81 uint8_t c;
82 if (l >= min_length && node->len_) {
83 AddMatch(node->idx_, l, node->len_, matches);
84 has_found_match = BROTLI_TRUE;
85 }
86 c = data[l++];
87 node = BrotliTrieSub(&dictionary->trie, node, c);
88 }
89 return has_found_match;
90 }
91 #endif /* BROTLI_EXPERIMENTAL */
92 {
93 size_t offset = dictionary->bucketscxx . . $ BrotliEncoderDictionary#buckets.[Hash15cxx . . $ Hash15(ca1608e2c87725e2).(data)];
94 BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! end = !offset;
95 while (!end) {
96 DictWordcxx . . $ DictWord# w = dictionary->dict_wordscxx . . $ BrotliEncoderDictionary#dict_words.[offset++];
97 const size_t l = w.lencxx . . $ DictWord#len. & 0x1F;
98 const size_t n = (size_t)1 << dictionary->wordscxx . . $ BrotliEncoderDictionary#words.->size_bits_by_lengthcxx . . $ BrotliDictionary#size_bits_by_length.[l];
99 const size_t id = w.idxcxx . . $ DictWord#idx.;
100 end = !!(w.lencxx . . $ DictWord#len. & 0x80);
101 w.lencxx . . $ DictWord#len. = (uint8_tcxx . . $ uint8_t#)l;
102 if (w.transformcxx . . $ DictWord#transform. == 0) {
103 const size_t matchlen =
104 DictMatchLengthcxx . . $ DictMatchLength(bd5e25feb71f877).(dictionary->wordscxx . . $ BrotliEncoderDictionary#words., data, id, l, max_length);
105 const uint8_tcxx . . $ uint8_t#* s;
106 size_t minlen;
107 size_t maxlen;
108 size_t len;
109 /* Transform "" + BROTLI_TRANSFORM_IDENTITY + "" */
110 if (matchlen == l) {
111 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id, l, l, matches);
112 has_found_match = BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!;
113 }
114 /* Transforms "" + BROTLI_TRANSFORM_OMIT_LAST_1 + "" and
115 "" + BROTLI_TRANSFORM_OMIT_LAST_1 + "ing " */
116 if (matchlen >= l - 1) {
117 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + 12 * n, l - 1, l, matches);
118 if (l + 2 < max_length &&
119 data[l - 1] == 'i' && data[l] == 'n' && data[l + 1] == 'g' &&
120 data[l + 2] == ' ') {
121 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + 49 * n, l + 3, l, matches);
122 }
123 has_found_match = BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!;
124 }
125 /* Transform "" + BROTLI_TRANSFORM_OMIT_LAST_# + "" (# = 2 .. 9) */
126 minlen = min_length;
127 if (l > 9) minlen = BROTLI_MAXcxx . . $ `c/common/platform.h:523:9`!(size_t, minlen, l - 9);
128 maxlen = BROTLI_MINcxx . . $ `c/common/platform.h:522:9`!(size_t, matchlen, l - 2);
129 for (len = minlen; len <= maxlen; ++len) {
130 size_t cut = l - len;
131 size_t transform_id = (cut << 2) +
132 (size_t)((dictionary->cutoffTransformscxx . . $ BrotliEncoderDictionary#cutoffTransforms. >> (cut * 6)) & 0x3F);
133 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + transform_id * n, len, l, matches);
134 has_found_match = BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!;
135 }
136 if (matchlen < l || l + 6 >= max_length) {
137 continue;
138 }
139 s = &data[l];
140 /* Transforms "" + BROTLI_TRANSFORM_IDENTITY + <suffix> */
141 if (s[0] == ' ') {
142 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + n, l + 1, l, matches);
143 if (s[1] == 'a') {
144 if (s[2] == ' ') {
145 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + 28 * n, l + 3, l, matches);
146 } else if (s[2] == 's') {
147 if (s[3] == ' ') AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + 46 * n, l + 4, l, matches);
148 } else if (s[2] == 't') {
149 if (s[3] == ' ') AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + 60 * n, l + 4, l, matches);
150 } else if (s[2] == 'n') {
151 if (s[3] == 'd' && s[4] == ' ') {
152 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + 10 * n, l + 5, l, matches);
153 }
154 }
155 } else if (s[1] == 'b') {
156 if (s[2] == 'y' && s[3] == ' ') {
157 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + 38 * n, l + 4, l, matches);
158 }
159 } else if (s[1] == 'i') {
160 if (s[2] == 'n') {
161 if (s[3] == ' ') AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + 16 * n, l + 4, l, matches);
162 } else if (s[2] == 's') {
163 if (s[3] == ' ') AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + 47 * n, l + 4, l, matches);
164 }
165 } else if (s[1] == 'f') {
166 if (s[2] == 'o') {
167 if (s[3] == 'r' && s[4] == ' ') {
168 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + 25 * n, l + 5, l, matches);
169 }
170 } else if (s[2] == 'r') {
171 if (s[3] == 'o' && s[4] == 'm' && s[5] == ' ') {
172 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + 37 * n, l + 6, l, matches);
173 }
174 }
175 } else if (s[1] == 'o') {
176 if (s[2] == 'f') {
177 if (s[3] == ' ') AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + 8 * n, l + 4, l, matches);
178 } else if (s[2] == 'n') {
179 if (s[3] == ' ') AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + 45 * n, l + 4, l, matches);
180 }
181 } else if (s[1] == 'n') {
182 if (s[2] == 'o' && s[3] == 't' && s[4] == ' ') {
183 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + 80 * n, l + 5, l, matches);
184 }
185 } else if (s[1] == 't') {
186 if (s[2] == 'h') {
187 if (s[3] == 'e') {
188 if (s[4] == ' ') AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + 5 * n, l + 5, l, matches);
189 } else if (s[3] == 'a') {
190 if (s[4] == 't' && s[5] == ' ') {
191 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + 29 * n, l + 6, l, matches);
192 }
193 }
194 } else if (s[2] == 'o') {
195 if (s[3] == ' ') AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + 17 * n, l + 4, l, matches);
196 }
197 } else if (s[1] == 'w') {
198 if (s[2] == 'i' && s[3] == 't' && s[4] == 'h' && s[5] == ' ') {
199 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + 35 * n, l + 6, l, matches);
200 }
201 }
202 } else if (s[0] == '"') {
203 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + 19 * n, l + 1, l, matches);
204 if (s[1] == '>') {
205 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + 21 * n, l + 2, l, matches);
206 }
207 } else if (s[0] == '.') {
208 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + 20 * n, l + 1, l, matches);
209 if (s[1] == ' ') {
210 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + 31 * n, l + 2, l, matches);
211 if (s[2] == 'T' && s[3] == 'h') {
212 if (s[4] == 'e') {
213 if (s[5] == ' ') AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + 43 * n, l + 6, l, matches);
214 } else if (s[4] == 'i') {
215 if (s[5] == 's' && s[6] == ' ') {
216 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + 75 * n, l + 7, l, matches);
217 }
218 }
219 }
220 }
221 } else if (s[0] == ',') {
222 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + 76 * n, l + 1, l, matches);
223 if (s[1] == ' ') {
224 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + 14 * n, l + 2, l, matches);
225 }
226 } else if (s[0] == '\n') {
227 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + 22 * n, l + 1, l, matches);
228 if (s[1] == '\t') {
229 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + 50 * n, l + 2, l, matches);
230 }
231 } else if (s[0] == ']') {
232 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + 24 * n, l + 1, l, matches);
233 } else if (s[0] == '\'') {
234 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + 36 * n, l + 1, l, matches);
235 } else if (s[0] == ':') {
236 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + 51 * n, l + 1, l, matches);
237 } else if (s[0] == '(') {
238 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + 57 * n, l + 1, l, matches);
239 } else if (s[0] == '=') {
240 if (s[1] == '"') {
241 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + 70 * n, l + 2, l, matches);
242 } else if (s[1] == '\'') {
243 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + 86 * n, l + 2, l, matches);
244 }
245 } else if (s[0] == 'a') {
246 if (s[1] == 'l' && s[2] == ' ') {
247 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + 84 * n, l + 3, l, matches);
248 }
249 } else if (s[0] == 'e') {
250 if (s[1] == 'd') {
251 if (s[2] == ' ') AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + 53 * n, l + 3, l, matches);
252 } else if (s[1] == 'r') {
253 if (s[2] == ' ') AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + 82 * n, l + 3, l, matches);
254 } else if (s[1] == 's') {
255 if (s[2] == 't' && s[3] == ' ') {
256 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + 95 * n, l + 4, l, matches);
257 }
258 }
259 } else if (s[0] == 'f') {
260 if (s[1] == 'u' && s[2] == 'l' && s[3] == ' ') {
261 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + 90 * n, l + 4, l, matches);
262 }
263 } else if (s[0] == 'i') {
264 if (s[1] == 'v') {
265 if (s[2] == 'e' && s[3] == ' ') {
266 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + 92 * n, l + 4, l, matches);
267 }
268 } else if (s[1] == 'z') {
269 if (s[2] == 'e' && s[3] == ' ') {
270 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + 100 * n, l + 4, l, matches);
271 }
272 }
273 } else if (s[0] == 'l') {
274 if (s[1] == 'e') {
275 if (s[2] == 's' && s[3] == 's' && s[4] == ' ') {
276 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + 93 * n, l + 5, l, matches);
277 }
278 } else if (s[1] == 'y') {
279 if (s[2] == ' ') AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + 61 * n, l + 3, l, matches);
280 }
281 } else if (s[0] == 'o') {
282 if (s[1] == 'u' && s[2] == 's' && s[3] == ' ') {
283 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + 106 * n, l + 4, l, matches);
284 }
285 }
286 } else {
287 /* Set is_all_caps=0 for BROTLI_TRANSFORM_UPPERCASE_FIRST and
288 is_all_caps=1 otherwise (BROTLI_TRANSFORM_UPPERCASE_ALL)
289 transform. */
290 const BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! is_all_caps =
291 TO_BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:55:9`!(w.transform != BROTLI_TRANSFORM_UPPERCASE_FIRST);
292 const uint8_tcxx . . $ uint8_t#* s;
293 if (!IsMatchcxx . . $ IsMatch(351e5cbdc905f5c7).(dictionary->wordscxx . . $ BrotliEncoderDictionary#words., w, data, max_length)) {
294 continue;
295 }
296 /* Transform "" + kUppercase{First,All} + "" */
297 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + (is_all_caps ? 44 : 9) * n, l, l, matches);
298 has_found_match = BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!;
299 if (l + 1 >= max_length) {
300 continue;
301 }
302 /* Transforms "" + kUppercase{First,All} + <suffix> */
303 s = &data[l];
304 if (s[0] == ' ') {
305 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + (is_all_caps ? 68 : 4) * n, l + 1, l, matches);
306 } else if (s[0] == '"') {
307 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + (is_all_caps ? 87 : 66) * n, l + 1, l, matches);
308 if (s[1] == '>') {
309 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + (is_all_caps ? 97 : 69) * n, l + 2, l, matches);
310 }
311 } else if (s[0] == '.') {
312 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + (is_all_caps ? 101 : 79) * n, l + 1, l, matches);
313 if (s[1] == ' ') {
314 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + (is_all_caps ? 114 : 88) * n, l + 2, l, matches);
315 }
316 } else if (s[0] == ',') {
317 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + (is_all_caps ? 112 : 99) * n, l + 1, l, matches);
318 if (s[1] == ' ') {
319 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + (is_all_caps ? 107 : 58) * n, l + 2, l, matches);
320 }
321 } else if (s[0] == '\'') {
322 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + (is_all_caps ? 94 : 74) * n, l + 1, l, matches);
323 } else if (s[0] == '(') {
324 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + (is_all_caps ? 113 : 78) * n, l + 1, l, matches);
325 } else if (s[0] == '=') {
326 if (s[1] == '"') {
327 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + (is_all_caps ? 105 : 104) * n, l + 2, l, matches);
328 } else if (s[1] == '\'') {
329 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + (is_all_caps ? 116 : 108) * n, l + 2, l, matches);
330 }
331 }
332 }
333 }
334 }
335 /* Transforms with prefixes " " and "." */
336 if (max_length >= 5 && (data[0] == ' ' || data[0] == '.')) {
337 BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! is_space = TO_BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:55:9`!(data[0] == ' ');
338 size_t offset = dictionary->bucketscxx . . $ BrotliEncoderDictionary#buckets.[Hash15cxx . . $ Hash15(ca1608e2c87725e2).(&data[1])];
339 BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! end = !offset;
340 while (!end) {
341 DictWordcxx . . $ DictWord# w = dictionary->dict_wordscxx . . $ BrotliEncoderDictionary#dict_words.[offset++];
342 const size_t l = w.lencxx . . $ DictWord#len. & 0x1F;
343 const size_t n = (size_t)1 << dictionary->wordscxx . . $ BrotliEncoderDictionary#words.->size_bits_by_lengthcxx . . $ BrotliDictionary#size_bits_by_length.[l];
344 const size_t id = w.idxcxx . . $ DictWord#idx.;
345 end = !!(w.lencxx . . $ DictWord#len. & 0x80);
346 w.lencxx . . $ DictWord#len. = (uint8_tcxx . . $ uint8_t#)l;
347 if (w.transformcxx . . $ DictWord#transform. == 0) {
348 const uint8_tcxx . . $ uint8_t#* s;
349 if (!IsMatchcxx . . $ IsMatch(351e5cbdc905f5c7).(dictionary->wordscxx . . $ BrotliEncoderDictionary#words., w, &data[1], max_length - 1)) {
350 continue;
351 }
352 /* Transforms " " + BROTLI_TRANSFORM_IDENTITY + "" and
353 "." + BROTLI_TRANSFORM_IDENTITY + "" */
354 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + (is_space ? 6 : 32) * n, l + 1, l, matches);
355 has_found_match = BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!;
356 if (l + 2 >= max_length) {
357 continue;
358 }
359 /* Transforms " " + BROTLI_TRANSFORM_IDENTITY + <suffix> and
360 "." + BROTLI_TRANSFORM_IDENTITY + <suffix>
361 */
362 s = &data[l + 1];
363 if (s[0] == ' ') {
364 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + (is_space ? 2 : 77) * n, l + 2, l, matches);
365 } else if (s[0] == '(') {
366 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + (is_space ? 89 : 67) * n, l + 2, l, matches);
367 } else if (is_space) {
368 if (s[0] == ',') {
369 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + 103 * n, l + 2, l, matches);
370 if (s[1] == ' ') {
371 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + 33 * n, l + 3, l, matches);
372 }
373 } else if (s[0] == '.') {
374 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + 71 * n, l + 2, l, matches);
375 if (s[1] == ' ') {
376 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + 52 * n, l + 3, l, matches);
377 }
378 } else if (s[0] == '=') {
379 if (s[1] == '"') {
380 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + 81 * n, l + 3, l, matches);
381 } else if (s[1] == '\'') {
382 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + 98 * n, l + 3, l, matches);
383 }
384 }
385 }
386 } else if (is_space) {
387 /* Set is_all_caps=0 for BROTLI_TRANSFORM_UPPERCASE_FIRST and
388 is_all_caps=1 otherwise (BROTLI_TRANSFORM_UPPERCASE_ALL)
389 transform. */
390 const BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! is_all_caps =
391 TO_BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:55:9`!(w.transform != BROTLI_TRANSFORM_UPPERCASE_FIRST);
392 const uint8_tcxx . . $ uint8_t#* s;
393 if (!IsMatchcxx . . $ IsMatch(351e5cbdc905f5c7).(dictionary->wordscxx . . $ BrotliEncoderDictionary#words., w, &data[1], max_length - 1)) {
394 continue;
395 }
396 /* Transforms " " + kUppercase{First,All} + "" */
397 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + (is_all_caps ? 85 : 30) * n, l + 1, l, matches);
398 has_found_match = BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!;
399 if (l + 2 >= max_length) {
400 continue;
401 }
402 /* Transforms " " + kUppercase{First,All} + <suffix> */
403 s = &data[l + 1];
404 if (s[0] == ' ') {
405 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + (is_all_caps ? 83 : 15) * n, l + 2, l, matches);
406 } else if (s[0] == ',') {
407 if (!is_all_caps) {
408 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + 109 * n, l + 2, l, matches);
409 }
410 if (s[1] == ' ') {
411 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + (is_all_caps ? 111 : 65) * n, l + 3, l, matches);
412 }
413 } else if (s[0] == '.') {
414 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + (is_all_caps ? 115 : 96) * n, l + 2, l, matches);
415 if (s[1] == ' ') {
416 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + (is_all_caps ? 117 : 91) * n, l + 3, l, matches);
417 }
418 } else if (s[0] == '=') {
419 if (s[1] == '"') {
420 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + (is_all_caps ? 110 : 118) * n, l + 3, l, matches);
421 } else if (s[1] == '\'') {
422 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + (is_all_caps ? 119 : 120) * n, l + 3, l, matches);
423 }
424 }
425 }
426 }
427 }
428 if (max_length >= 6) {
429 /* Transforms with prefixes "e ", "s ", ", " and "\xC2\xA0" */
430 if ((data[1] == ' ' &&
431 (data[0] == 'e' || data[0] == 's' || data[0] == ',')) ||
432 (data[0] == 0xC2 && data[1] == 0xA0)) {
433 size_t offset = dictionary->bucketscxx . . $ BrotliEncoderDictionary#buckets.[Hash15cxx . . $ Hash15(ca1608e2c87725e2).(&data[2])];
434 BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! end = !offset;
435 while (!end) {
436 DictWordcxx . . $ DictWord# w = dictionary->dict_wordscxx . . $ BrotliEncoderDictionary#dict_words.[offset++];
437 const size_t l = w.lencxx . . $ DictWord#len. & 0x1F;
438 const size_t n = (size_t)1 << dictionary->wordscxx . . $ BrotliEncoderDictionary#words.->size_bits_by_lengthcxx . . $ BrotliDictionary#size_bits_by_length.[l];
439 const size_t id = w.idxcxx . . $ DictWord#idx.;
440 end = !!(w.lencxx . . $ DictWord#len. & 0x80);
441 w.lencxx . . $ DictWord#len. = (uint8_tcxx . . $ uint8_t#)l;
442 if (w.transformcxx . . $ DictWord#transform. == 0 &&
443 IsMatchcxx . . $ IsMatch(351e5cbdc905f5c7).(dictionary->wordscxx . . $ BrotliEncoderDictionary#words., w, &data[2], max_length - 2)) {
444 if (data[0] == 0xC2) {
445 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + 102 * n, l + 2, l, matches);
446 has_found_match = BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!;
447 } else if (l + 2 < max_length && data[l + 2] == ' ') {
448 size_t t = data[0] == 'e' ? 18 : (data[0] == 's' ? 7 : 13);
449 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + t * n, l + 3, l, matches);
450 has_found_match = BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!;
451 }
452 }
453 }
454 }
455 }
456 if (max_length >= 9) {
457 /* Transforms with prefixes " the " and ".com/" */
458 if ((data[0] == ' ' && data[1] == 't' && data[2] == 'h' &&
459 data[3] == 'e' && data[4] == ' ') ||
460 (data[0] == '.' && data[1] == 'c' && data[2] == 'o' &&
461 data[3] == 'm' && data[4] == '/')) {
462 size_t offset = dictionary->bucketscxx . . $ BrotliEncoderDictionary#buckets.[Hash15cxx . . $ Hash15(ca1608e2c87725e2).(&data[5])];
463 BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! end = !offset;
464 while (!end) {
465 DictWordcxx . . $ DictWord# w = dictionary->dict_wordscxx . . $ BrotliEncoderDictionary#dict_words.[offset++];
466 const size_t l = w.lencxx . . $ DictWord#len. & 0x1F;
467 const size_t n = (size_t)1 << dictionary->wordscxx . . $ BrotliEncoderDictionary#words.->size_bits_by_lengthcxx . . $ BrotliDictionary#size_bits_by_length.[l];
468 const size_t id = w.idxcxx . . $ DictWord#idx.;
469 end = !!(w.lencxx . . $ DictWord#len. & 0x80);
470 w.lencxx . . $ DictWord#len. = (uint8_tcxx . . $ uint8_t#)l;
471 if (w.transformcxx . . $ DictWord#transform. == 0 &&
472 IsMatchcxx . . $ IsMatch(351e5cbdc905f5c7).(dictionary->wordscxx . . $ BrotliEncoderDictionary#words., w, &data[5], max_length - 5)) {
473 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + (data[0] == ' ' ? 41 : 72) * n, l + 5, l, matches);
474 has_found_match = BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!;
475 if (l + 5 < max_length) {
476 const uint8_tcxx . . $ uint8_t#* s = &data[l + 5];
477 if (data[0] == ' ') {
478 if (l + 8 < max_length &&
479 s[0] == ' ' && s[1] == 'o' && s[2] == 'f' && s[3] == ' ') {
480 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + 62 * n, l + 9, l, matches);
481 if (l + 12 < max_length &&
482 s[4] == 't' && s[5] == 'h' && s[6] == 'e' && s[7] == ' ') {
483 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(id + 73 * n, l + 13, l, matches);
484 }
485 }
486 }
487 }
488 }
489 }
490 }
491 }
492 return has_found_match;
493 }
494
495 /* Finds matches for one or more dictionaries, if multiple are present
496 in the contextual dictionary */
497 BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! BrotliFindAllStaticDictionaryMatchescxx . . $ BrotliFindAllStaticDictionaryMatches(2925cb88ea9b8402).(
498 const BrotliEncoderDictionarycxx . . $ BrotliEncoderDictionary#* dictionary, const uint8_tcxx . . $ uint8_t#* data,
499 size_t min_length, size_t max_length, uint32_tcxx . . $ uint32_t#* matches) {
500 BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! has_found_match =
501 BrotliFindAllStaticDictionaryMatchesForcxx . . $ BrotliFindAllStaticDictionaryMatchesFor(2925cb88ea9b8402).(
502 dictionary, data, min_length, max_length, matches);
503
504 if (!!dictionary->parentcxx . . $ BrotliEncoderDictionary#parent. && dictionary->parentcxx . . $ BrotliEncoderDictionary#parent.->num_dictionariescxx . . $ ContextualEncoderDictionary#num_dictionaries. > 1) {
505 uint32_tcxx . . $ uint32_t# matches2[BROTLI_MAX_STATIC_DICTIONARY_MATCH_LENcxx . . $ `c/enc/static_dict.h:20:9`! + 1];
506 int l;
507 const BrotliEncoderDictionarycxx . . $ BrotliEncoderDictionary#* dictionary2 = dictionary->parentcxx . . $ BrotliEncoderDictionary#parent.->dictcxx . . $ ContextualEncoderDictionary#dict.[0];
508 if (dictionary2 == dictionary) {
509 dictionary2 = dictionary->parentcxx . . $ BrotliEncoderDictionary#parent.->dictcxx . . $ ContextualEncoderDictionary#dict.[1];
510 }
511
512 for (l = 0; l < BROTLI_MAX_STATIC_DICTIONARY_MATCH_LENcxx . . $ `c/enc/static_dict.h:20:9`! + 1; l++) {
513 matches2[l] = kInvalidMatchcxx . . $ kInvalidMatch.;
514 }
515
516 has_found_match |= BrotliFindAllStaticDictionaryMatchesForcxx . . $ BrotliFindAllStaticDictionaryMatchesFor(2925cb88ea9b8402).(
517 dictionary2, data, min_length, max_length, matches2);
518
519 for (l = 0; l < BROTLI_MAX_STATIC_DICTIONARY_MATCH_LENcxx . . $ `c/enc/static_dict.h:20:9`! + 1; l++) {
520 if (matches2[l] != kInvalidMatchcxx . . $ kInvalidMatch.) {
521 uint32_tcxx . . $ uint32_t# dist = (uint32_tcxx . . $ uint32_t#)(matches2[l] >> 5);
522 uint32_tcxx . . $ uint32_t# len_code = matches2[l] & 31;
523 uint32_tcxx . . $ uint32_t# skipdist = (uint32_tcxx . . $ uint32_t#)((uint32_tcxx . . $ uint32_t#)(1 << dictionary->wordscxx . . $ BrotliEncoderDictionary#words.->
524 size_bits_by_lengthcxx . . $ BrotliDictionary#size_bits_by_length.[len_code]) & ~1u) *
525 (uint32_tcxx . . $ uint32_t#)dictionary->num_transformscxx . . $ BrotliEncoderDictionary#num_transforms.;
526 /* TODO(lode): check for dist overflow */
527 dist += skipdist;
528 AddMatchcxx . . $ AddMatch(4cad50c92005ffa7).(dist, (size_t)l, len_code, matches);
529 }
530 }
531 }
532 return has_found_match;
533 }
534 #if defined(__cplusplus) || defined(c_plusplus)
535 } /* extern "C" */
536 #endif