Coverage Report

Created: 2024-01-20 12:26

/src/harfbuzz/src/hb-buffer-deserialize-text-unicode.hh
Line
Count
Source (jump to first uncovered line)
1
2
#line 1 "hb-buffer-deserialize-text-unicode.rl"
3
/*
4
 * Copyright © 2013  Google, Inc.
5
 *
6
 *  This is part of HarfBuzz, a text shaping library.
7
 *
8
 * Permission is hereby granted, without written agreement and without
9
 * license or royalty fees, to use, copy, modify, and distribute this
10
 * software and its documentation for any purpose, provided that the
11
 * above copyright notice and the following two paragraphs appear in
12
 * all copies of this software.
13
 *
14
 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
15
 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
16
 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
17
 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
18
 * DAMAGE.
19
 *
20
 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
21
 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
22
 * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
23
 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
24
 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
25
 *
26
 * Google Author(s): Behdad Esfahbod
27
 */
28
29
#ifndef HB_BUFFER_DESERIALIZE_TEXT_UNICODE_HH
30
#define HB_BUFFER_DESERIALIZE_TEXT_UNICODE_HH
31
32
#include "hb.hh"
33
34
35
#line 33 "hb-buffer-deserialize-text-unicode.hh"
36
static const unsigned char _deserialize_text_unicode_trans_keys[] = {
37
  0u, 0u, 9u, 117u, 43u, 102u, 48u, 102u, 48u, 57u, 9u, 124u, 9u, 124u, 9u, 124u, 
38
  9u, 124u, 0
39
};
40
41
static const char _deserialize_text_unicode_key_spans[] = {
42
  0, 109, 60, 55, 10, 116, 116, 116, 
43
  116
44
};
45
46
static const short _deserialize_text_unicode_index_offsets[] = {
47
  0, 0, 110, 171, 227, 238, 355, 472, 
48
  589
49
};
50
51
static const char _deserialize_text_unicode_indicies[] = {
52
  0, 0, 0, 0, 0, 1, 1, 
53
  1, 1, 1, 1, 1, 1, 1, 1, 
54
  1, 1, 1, 1, 1, 1, 1, 1, 
55
  0, 1, 1, 1, 1, 1, 1, 1, 
56
  1, 1, 1, 1, 1, 1, 1, 1, 
57
  1, 1, 1, 1, 1, 1, 1, 1, 
58
  1, 1, 1, 1, 1, 1, 1, 1, 
59
  1, 1, 1, 1, 1, 1, 1, 1, 
60
  1, 1, 1, 1, 1, 1, 1, 1, 
61
  1, 1, 1, 1, 1, 2, 1, 1, 
62
  1, 1, 1, 1, 1, 1, 1, 1, 
63
  1, 1, 1, 1, 1, 1, 1, 1, 
64
  1, 1, 1, 1, 1, 1, 1, 1, 
65
  1, 1, 1, 1, 1, 2, 1, 3, 
66
  1, 1, 1, 1, 4, 4, 4, 4, 
67
  4, 4, 4, 4, 4, 4, 1, 1, 
68
  1, 1, 1, 1, 1, 4, 4, 4, 
69
  4, 4, 4, 1, 1, 1, 1, 1, 
70
  1, 1, 1, 1, 1, 1, 1, 1, 
71
  1, 1, 1, 1, 1, 1, 1, 1, 
72
  1, 1, 1, 1, 1, 4, 4, 4, 
73
  4, 4, 4, 1, 4, 4, 4, 4, 
74
  4, 4, 4, 4, 4, 4, 1, 1, 
75
  1, 1, 1, 1, 1, 4, 4, 4, 
76
  4, 4, 4, 1, 1, 1, 1, 1, 
77
  1, 1, 1, 1, 1, 1, 1, 1, 
78
  1, 1, 1, 1, 1, 1, 1, 1, 
79
  1, 1, 1, 1, 1, 4, 4, 4, 
80
  4, 4, 4, 1, 5, 6, 6, 6, 
81
  6, 6, 6, 6, 6, 6, 1, 7, 
82
  7, 7, 7, 7, 1, 1, 1, 1, 
83
  1, 1, 1, 1, 1, 1, 1, 1, 
84
  1, 1, 1, 1, 1, 1, 7, 1, 
85
  1, 1, 1, 1, 1, 1, 1, 1, 
86
  1, 1, 1, 1, 1, 1, 8, 8, 
87
  8, 8, 8, 8, 8, 8, 8, 8, 
88
  1, 1, 1, 9, 1, 1, 1, 8, 
89
  8, 8, 8, 8, 8, 1, 1, 1, 
90
  1, 1, 1, 1, 1, 1, 1, 1, 
91
  1, 1, 1, 1, 1, 1, 1, 1, 
92
  1, 1, 1, 1, 1, 1, 1, 8, 
93
  8, 8, 8, 8, 8, 1, 1, 1, 
94
  1, 1, 1, 1, 1, 1, 1, 1, 
95
  1, 1, 1, 1, 1, 1, 1, 1, 
96
  1, 1, 10, 1, 11, 11, 11, 11, 
97
  11, 1, 1, 1, 1, 1, 1, 1, 
98
  1, 1, 1, 1, 1, 1, 1, 1, 
99
  1, 1, 1, 11, 1, 1, 1, 1, 
100
  1, 1, 1, 1, 1, 1, 1, 1, 
101
  1, 1, 1, 1, 1, 1, 1, 1, 
102
  1, 1, 1, 1, 1, 1, 1, 1, 
103
  1, 1, 1, 1, 1, 1, 1, 1, 
104
  1, 1, 1, 1, 1, 1, 1, 1, 
105
  1, 1, 1, 1, 1, 1, 1, 1, 
106
  1, 1, 1, 1, 1, 1, 1, 1, 
107
  1, 1, 1, 1, 1, 1, 1, 1, 
108
  1, 1, 1, 1, 1, 1, 1, 1, 
109
  1, 1, 1, 1, 1, 1, 1, 1, 
110
  1, 1, 1, 1, 1, 1, 1, 0, 
111
  1, 12, 12, 12, 12, 12, 1, 1, 
112
  1, 1, 1, 1, 1, 1, 1, 1, 
113
  1, 1, 1, 1, 1, 1, 1, 1, 
114
  12, 1, 1, 1, 1, 1, 1, 1, 
115
  1, 1, 1, 1, 1, 1, 1, 1, 
116
  1, 1, 1, 1, 1, 1, 1, 1, 
117
  1, 1, 1, 1, 1, 1, 1, 1, 
118
  1, 1, 1, 1, 1, 1, 1, 1, 
119
  1, 1, 1, 1, 1, 1, 1, 1, 
120
  1, 1, 1, 1, 1, 1, 1, 1, 
121
  1, 1, 1, 1, 1, 1, 1, 1, 
122
  1, 1, 1, 1, 1, 1, 1, 1, 
123
  1, 1, 1, 1, 1, 1, 1, 1, 
124
  1, 1, 1, 1, 1, 1, 1, 1, 
125
  1, 1, 1, 1, 13, 1, 12, 12, 
126
  12, 12, 12, 1, 1, 1, 1, 1, 
127
  1, 1, 1, 1, 1, 1, 1, 1, 
128
  1, 1, 1, 1, 1, 12, 1, 1, 
129
  1, 1, 1, 1, 1, 1, 1, 1, 
130
  1, 1, 1, 1, 1, 14, 14, 14, 
131
  14, 14, 14, 14, 14, 14, 14, 1, 
132
  1, 1, 1, 1, 1, 1, 1, 1, 
133
  1, 1, 1, 1, 1, 1, 1, 1, 
134
  1, 1, 1, 1, 1, 1, 1, 1, 
135
  1, 1, 1, 1, 1, 1, 1, 1, 
136
  1, 1, 1, 1, 1, 1, 1, 1, 
137
  1, 1, 1, 1, 1, 1, 1, 1, 
138
  1, 1, 1, 1, 1, 1, 1, 1, 
139
  1, 1, 1, 1, 1, 1, 1, 1, 
140
  1, 13, 1, 0
141
};
142
143
static const char _deserialize_text_unicode_trans_targs[] = {
144
  1, 0, 2, 3, 5, 7, 8, 6, 
145
  5, 4, 1, 6, 6, 1, 8
146
};
147
148
static const char _deserialize_text_unicode_trans_actions[] = {
149
  0, 0, 1, 0, 2, 2, 2, 3, 
150
  0, 4, 3, 0, 5, 5, 0
151
};
152
153
static const char _deserialize_text_unicode_eof_actions[] = {
154
  0, 0, 0, 0, 0, 3, 0, 5, 
155
  5
156
};
157
158
static const int deserialize_text_unicode_start = 1;
159
static const int deserialize_text_unicode_first_final = 5;
160
static const int deserialize_text_unicode_error = 0;
161
162
static const int deserialize_text_unicode_en_main = 1;
163
164
165
#line 79 "hb-buffer-deserialize-text-unicode.rl"
166
167
168
static hb_bool_t
169
_hb_buffer_deserialize_text_unicode (hb_buffer_t *buffer,
170
             const char *buf,
171
             unsigned int buf_len,
172
             const char **end_ptr,
173
             hb_font_t *font)
174
0
{
175
0
  const char *p = buf, *pe = buf + buf_len, *eof = pe, *orig_pe = pe;
176
177
0
  while (p < pe && ISSPACE (*p))
178
0
    p++;
179
0
  if (p < pe && *p == (buffer->len ? '|' : '<'))
180
0
    *end_ptr = ++p;
181
182
0
  const char *end = strchr ((char *) p, '>');
183
0
  if (end)
184
0
    pe = eof = end;
185
0
  else
186
0
  {
187
0
    end = strrchr ((char *) p, '|');
188
0
    if (end)
189
0
      pe = eof = end;
190
0
    else
191
0
      pe = eof = p;
192
0
  }
193
194
195
0
  const char *tok = nullptr;
196
0
  int cs;
197
0
  hb_glyph_info_t info = {0};
198
0
  const hb_glyph_position_t pos = {0};
199
  
200
0
#line 194 "hb-buffer-deserialize-text-unicode.hh"
201
0
  {
202
0
  cs = deserialize_text_unicode_start;
203
0
  }
204
205
0
#line 197 "hb-buffer-deserialize-text-unicode.hh"
206
0
  {
207
0
  int _slen;
208
0
  int _trans;
209
0
  const unsigned char *_keys;
210
0
  const char *_inds;
211
0
  if ( p == pe )
212
0
    goto _test_eof;
213
0
  if ( cs == 0 )
214
0
    goto _out;
215
0
_resume:
216
0
  _keys = _deserialize_text_unicode_trans_keys + (cs<<1);
217
0
  _inds = _deserialize_text_unicode_indicies + _deserialize_text_unicode_index_offsets[cs];
218
219
0
  _slen = _deserialize_text_unicode_key_spans[cs];
220
0
  _trans = _inds[ _slen > 0 && _keys[0] <=(*p) &&
221
0
    (*p) <= _keys[1] ?
222
0
    (*p) - _keys[0] : _slen ];
223
224
0
  cs = _deserialize_text_unicode_trans_targs[_trans];
225
226
0
  if ( _deserialize_text_unicode_trans_actions[_trans] == 0 )
227
0
    goto _again;
228
229
0
  switch ( _deserialize_text_unicode_trans_actions[_trans] ) {
230
0
  case 1:
231
0
#line 38 "hb-buffer-deserialize-text-unicode.rl"
232
0
  {
233
0
  hb_memset (&info, 0, sizeof (info));
234
0
}
235
0
  break;
236
0
  case 2:
237
0
#line 51 "hb-buffer-deserialize-text-unicode.rl"
238
0
  {
239
0
  tok = p;
240
0
}
241
0
  break;
242
0
  case 4:
243
0
#line 55 "hb-buffer-deserialize-text-unicode.rl"
244
0
  {if (!parse_hex (tok, p, &info.codepoint )) return false; }
245
0
  break;
246
0
  case 3:
247
0
#line 55 "hb-buffer-deserialize-text-unicode.rl"
248
0
  {if (!parse_hex (tok, p, &info.codepoint )) return false; }
249
0
#line 42 "hb-buffer-deserialize-text-unicode.rl"
250
0
  {
251
0
  buffer->add_info (info);
252
0
  if (unlikely (!buffer->successful))
253
0
    return false;
254
0
  if (buffer->have_positions)
255
0
    buffer->pos[buffer->len - 1] = pos;
256
0
  *end_ptr = p;
257
0
}
258
0
  break;
259
0
  case 5:
260
0
#line 57 "hb-buffer-deserialize-text-unicode.rl"
261
0
  { if (!parse_uint (tok, p, &info.cluster )) return false; }
262
0
#line 42 "hb-buffer-deserialize-text-unicode.rl"
263
0
  {
264
0
  buffer->add_info (info);
265
0
  if (unlikely (!buffer->successful))
266
0
    return false;
267
0
  if (buffer->have_positions)
268
0
    buffer->pos[buffer->len - 1] = pos;
269
0
  *end_ptr = p;
270
0
}
271
0
  break;
272
0
#line 256 "hb-buffer-deserialize-text-unicode.hh"
273
0
  }
274
275
0
_again:
276
0
  if ( cs == 0 )
277
0
    goto _out;
278
0
  if ( ++p != pe )
279
0
    goto _resume;
280
0
  _test_eof: {}
281
0
  if ( p == eof )
282
0
  {
283
0
  switch ( _deserialize_text_unicode_eof_actions[cs] ) {
284
0
  case 3:
285
0
#line 55 "hb-buffer-deserialize-text-unicode.rl"
286
0
  {if (!parse_hex (tok, p, &info.codepoint )) return false; }
287
0
#line 42 "hb-buffer-deserialize-text-unicode.rl"
288
0
  {
289
0
  buffer->add_info (info);
290
0
  if (unlikely (!buffer->successful))
291
0
    return false;
292
0
  if (buffer->have_positions)
293
0
    buffer->pos[buffer->len - 1] = pos;
294
0
  *end_ptr = p;
295
0
}
296
0
  break;
297
0
  case 5:
298
0
#line 57 "hb-buffer-deserialize-text-unicode.rl"
299
0
  { if (!parse_uint (tok, p, &info.cluster )) return false; }
300
0
#line 42 "hb-buffer-deserialize-text-unicode.rl"
301
0
  {
302
0
  buffer->add_info (info);
303
0
  if (unlikely (!buffer->successful))
304
0
    return false;
305
0
  if (buffer->have_positions)
306
0
    buffer->pos[buffer->len - 1] = pos;
307
0
  *end_ptr = p;
308
0
}
309
0
  break;
310
0
#line 289 "hb-buffer-deserialize-text-unicode.hh"
311
0
  }
312
0
  }
313
314
0
  _out: {}
315
0
  }
316
317
0
#line 115 "hb-buffer-deserialize-text-unicode.rl"
318
319
320
0
  if (pe < orig_pe && *pe == '>')
321
0
  {
322
0
    pe++;
323
0
    if (p == pe)
324
0
      p++;
325
0
  }
326
327
0
  *end_ptr = p;
328
329
0
  return p == pe;
330
0
}
331
332
#endif /* HB_BUFFER_DESERIALIZE_TEXT_UNICODE_HH */