1use crate::api::{
2 yaml_free, yaml_malloc, yaml_queue_extend, yaml_stack_extend, yaml_string_extend,
3 yaml_string_join,
4};
5use crate::externs::{memcpy, memmove, memset, strcmp, strlen};
6use crate::ops::{ForceAdd as _, ForceMul as _};
7use crate::reader::yaml_parser_update_buffer;
8use crate::success::{Success, FAIL, OK};
9use crate::yaml::{ptrdiff_t, size_t, yaml_char_t, yaml_string_t, NULL_STRING};
10use crate::{
11 libc, yaml_mark_t, yaml_parser_t, yaml_simple_key_t, yaml_token_t, yaml_token_type_t,
12 PointerExt, YAML_ALIAS_TOKEN, YAML_ANCHOR_TOKEN, YAML_BLOCK_END_TOKEN, YAML_BLOCK_ENTRY_TOKEN,
13 YAML_BLOCK_MAPPING_START_TOKEN, YAML_BLOCK_SEQUENCE_START_TOKEN, YAML_DOCUMENT_END_TOKEN,
14 YAML_DOCUMENT_START_TOKEN, YAML_DOUBLE_QUOTED_SCALAR_STYLE, YAML_FLOW_ENTRY_TOKEN,
15 YAML_FLOW_MAPPING_END_TOKEN, YAML_FLOW_MAPPING_START_TOKEN, YAML_FLOW_SEQUENCE_END_TOKEN,
16 YAML_FLOW_SEQUENCE_START_TOKEN, YAML_FOLDED_SCALAR_STYLE, YAML_KEY_TOKEN,
17 YAML_LITERAL_SCALAR_STYLE, YAML_MEMORY_ERROR, YAML_NO_ERROR, YAML_PLAIN_SCALAR_STYLE,
18 YAML_SCALAR_TOKEN, YAML_SCANNER_ERROR, YAML_SINGLE_QUOTED_SCALAR_STYLE, YAML_STREAM_END_TOKEN,
19 YAML_STREAM_START_TOKEN, YAML_TAG_DIRECTIVE_TOKEN, YAML_TAG_TOKEN, YAML_VALUE_TOKEN,
20 YAML_VERSION_DIRECTIVE_TOKEN,
21};
22use core::mem::{size_of, MaybeUninit};
23use core::ptr::{self, addr_of_mut};
24
25unsafe fn CACHE(parser: *mut yaml_parser_t, length: size_t) -> Success {
26 if (*parser).unread >= length {
27 OK
28 } else {
29 yaml_parser_update_buffer(parser, length)
30 }
31}
32
33unsafe fn SKIP(parser: *mut yaml_parser_t) {
34 let width = WIDTH!((*parser).buffer);
35 (*parser).mark.index = (*parser).mark.index.force_add(width as u64);
36 (*parser).mark.column = (*parser).mark.column.force_add(1);
37 (*parser).unread = (*parser).unread.wrapping_sub(1);
38 (*parser).buffer.pointer = (*parser).buffer.pointer.wrapping_offset(width as isize);
39}
40
41unsafe fn SKIP_LINE(parser: *mut yaml_parser_t) {
42 if IS_CRLF!((*parser).buffer) {
43 (*parser).mark.index = (*parser).mark.index.force_add(2);
44 (*parser).mark.column = 0;
45 (*parser).mark.line = (*parser).mark.line.force_add(1);
46 (*parser).unread = (*parser).unread.wrapping_sub(2);
47 (*parser).buffer.pointer = (*parser).buffer.pointer.wrapping_offset(2);
48 } else if IS_BREAK!((*parser).buffer) {
49 let width = WIDTH!((*parser).buffer);
50 (*parser).mark.index = (*parser).mark.index.force_add(width as u64);
51 (*parser).mark.column = 0;
52 (*parser).mark.line = (*parser).mark.line.force_add(1);
53 (*parser).unread = (*parser).unread.wrapping_sub(1);
54 (*parser).buffer.pointer = (*parser).buffer.pointer.wrapping_offset(width as isize);
55 };
56}
57
58unsafe fn READ(parser: *mut yaml_parser_t, string: *mut yaml_string_t) {
59 STRING_EXTEND!(*string);
60 let width = WIDTH!((*parser).buffer);
61 COPY!(*string, (*parser).buffer);
62 (*parser).mark.index = (*parser).mark.index.force_add(width as u64);
63 (*parser).mark.column = (*parser).mark.column.force_add(1);
64 (*parser).unread = (*parser).unread.wrapping_sub(1);
65}
66
67unsafe fn READ_LINE(parser: *mut yaml_parser_t, string: *mut yaml_string_t) {
68 STRING_EXTEND!(*string);
69 if CHECK_AT!((*parser).buffer, b'\r', 0) && CHECK_AT!((*parser).buffer, b'\n', 1) {
70 *(*string).pointer = b'\n';
71 (*string).pointer = (*string).pointer.wrapping_offset(1);
72 (*parser).buffer.pointer = (*parser).buffer.pointer.wrapping_offset(2);
73 (*parser).mark.index = (*parser).mark.index.force_add(2);
74 (*parser).mark.column = 0;
75 (*parser).mark.line = (*parser).mark.line.force_add(1);
76 (*parser).unread = (*parser).unread.wrapping_sub(2);
77 } else if CHECK_AT!((*parser).buffer, b'\r', 0) || CHECK_AT!((*parser).buffer, b'\n', 0) {
78 *(*string).pointer = b'\n';
79 (*string).pointer = (*string).pointer.wrapping_offset(1);
80 (*parser).buffer.pointer = (*parser).buffer.pointer.wrapping_offset(1);
81 (*parser).mark.index = (*parser).mark.index.force_add(1);
82 (*parser).mark.column = 0;
83 (*parser).mark.line = (*parser).mark.line.force_add(1);
84 (*parser).unread = (*parser).unread.wrapping_sub(1);
85 } else if CHECK_AT!((*parser).buffer, b'\xC2', 0) && CHECK_AT!((*parser).buffer, b'\x85', 1) {
86 *(*string).pointer = b'\n';
87 (*string).pointer = (*string).pointer.wrapping_offset(1);
88 (*parser).buffer.pointer = (*parser).buffer.pointer.wrapping_offset(2);
89 (*parser).mark.index = (*parser).mark.index.force_add(2);
90 (*parser).mark.column = 0;
91 (*parser).mark.line = (*parser).mark.line.force_add(1);
92 (*parser).unread = (*parser).unread.wrapping_sub(1);
93 } else if CHECK_AT!((*parser).buffer, b'\xE2', 0)
94 && CHECK_AT!((*parser).buffer, b'\x80', 1)
95 && (CHECK_AT!((*parser).buffer, b'\xA8', 2) || CHECK_AT!((*parser).buffer, b'\xA9', 2))
96 {
97 *(*string).pointer = *(*parser).buffer.pointer;
98 (*string).pointer = (*string).pointer.wrapping_offset(1);
99 (*parser).buffer.pointer = (*parser).buffer.pointer.wrapping_offset(1);
100 *(*string).pointer = *(*parser).buffer.pointer;
101 (*string).pointer = (*string).pointer.wrapping_offset(1);
102 (*parser).buffer.pointer = (*parser).buffer.pointer.wrapping_offset(1);
103 *(*string).pointer = *(*parser).buffer.pointer;
104 (*string).pointer = (*string).pointer.wrapping_offset(1);
105 (*parser).buffer.pointer = (*parser).buffer.pointer.wrapping_offset(1);
106 (*parser).mark.index = (*parser).mark.index.force_add(3);
107 (*parser).mark.column = 0;
108 (*parser).mark.line = (*parser).mark.line.force_add(1);
109 (*parser).unread = (*parser).unread.wrapping_sub(1);
110 };
111}
112
113macro_rules! READ {
114 ($parser:expr, $string:expr) => {
115 READ($parser, addr_of_mut!($string))
116 };
117}
118
119macro_rules! READ_LINE {
120 ($parser:expr, $string:expr) => {
121 READ_LINE($parser, addr_of_mut!($string))
122 };
123}
124
125pub unsafe fn yaml_parser_scan(parser: *mut yaml_parser_t, token: *mut yaml_token_t) -> Success {
138 __assert!(!parser.is_null());
139 __assert!(!token.is_null());
140 memset(
141 token as *mut libc::c_void,
142 0,
143 size_of::<yaml_token_t>() as libc::c_ulong,
144 );
145 if (*parser).stream_end_produced || (*parser).error != YAML_NO_ERROR {
146 return OK;
147 }
148 if !(*parser).token_available {
149 if yaml_parser_fetch_more_tokens(parser).fail {
150 return FAIL;
151 }
152 }
153 *token = DEQUEUE!((*parser).tokens);
154 (*parser).token_available = false;
155 let fresh2 = addr_of_mut!((*parser).tokens_parsed);
156 *fresh2 = (*fresh2).force_add(1);
157 if (*token).type_ == YAML_STREAM_END_TOKEN {
158 (*parser).stream_end_produced = true;
159 }
160 OK
161}
162
163unsafe fn yaml_parser_set_scanner_error(
164 parser: *mut yaml_parser_t,
165 context: *const libc::c_char,
166 context_mark: yaml_mark_t,
167 problem: *const libc::c_char,
168) {
169 (*parser).error = YAML_SCANNER_ERROR;
170 let fresh3 = addr_of_mut!((*parser).context);
171 *fresh3 = context;
172 (*parser).context_mark = context_mark;
173 let fresh4 = addr_of_mut!((*parser).problem);
174 *fresh4 = problem;
175 (*parser).problem_mark = (*parser).mark;
176}
177
178pub(crate) unsafe fn yaml_parser_fetch_more_tokens(parser: *mut yaml_parser_t) -> Success {
179 let mut need_more_tokens;
180 loop {
181 need_more_tokens = false;
182 if (*parser).tokens.head == (*parser).tokens.tail {
183 need_more_tokens = true;
184 } else {
185 let mut simple_key: *mut yaml_simple_key_t;
186 if yaml_parser_stale_simple_keys(parser).fail {
187 return FAIL;
188 }
189 simple_key = (*parser)
190 .simple_keys
191 .start
192 .add((*parser).not_simple_keys as usize);
193 while simple_key != (*parser).simple_keys.top {
194 if (*simple_key).possible && (*simple_key).token_number == (*parser).tokens_parsed {
195 need_more_tokens = true;
196 break;
197 } else {
198 simple_key = simple_key.wrapping_offset(1);
199 }
200 }
201 }
202 if !need_more_tokens {
203 break;
204 }
205 if yaml_parser_fetch_next_token(parser).fail {
206 return FAIL;
207 }
208 }
209 (*parser).token_available = true;
210 OK
211}
212
213unsafe fn yaml_parser_fetch_next_token(parser: *mut yaml_parser_t) -> Success {
214 if CACHE(parser, 1_u64).fail {
215 return FAIL;
216 }
217 if !(*parser).stream_start_produced {
218 yaml_parser_fetch_stream_start(parser);
219 return OK;
220 }
221 if yaml_parser_scan_to_next_token(parser).fail {
222 return FAIL;
223 }
224 if yaml_parser_stale_simple_keys(parser).fail {
225 return FAIL;
226 }
227 yaml_parser_unroll_indent(parser, (*parser).mark.column as ptrdiff_t);
228 if CACHE(parser, 4_u64).fail {
229 return FAIL;
230 }
231 if IS_Z!((*parser).buffer) {
232 return yaml_parser_fetch_stream_end(parser);
233 }
234 if (*parser).mark.column == 0_u64 && CHECK!((*parser).buffer, b'%') {
235 return yaml_parser_fetch_directive(parser);
236 }
237 if (*parser).mark.column == 0_u64
238 && CHECK_AT!((*parser).buffer, b'-', 0)
239 && CHECK_AT!((*parser).buffer, b'-', 1)
240 && CHECK_AT!((*parser).buffer, b'-', 2)
241 && IS_BLANKZ_AT!((*parser).buffer, 3)
242 {
243 return yaml_parser_fetch_document_indicator(parser, YAML_DOCUMENT_START_TOKEN);
244 }
245 if (*parser).mark.column == 0_u64
246 && CHECK_AT!((*parser).buffer, b'.', 0)
247 && CHECK_AT!((*parser).buffer, b'.', 1)
248 && CHECK_AT!((*parser).buffer, b'.', 2)
249 && IS_BLANKZ_AT!((*parser).buffer, 3)
250 {
251 return yaml_parser_fetch_document_indicator(parser, YAML_DOCUMENT_END_TOKEN);
252 }
253 if CHECK!((*parser).buffer, b'[') {
254 return yaml_parser_fetch_flow_collection_start(parser, YAML_FLOW_SEQUENCE_START_TOKEN);
255 }
256 if CHECK!((*parser).buffer, b'{') {
257 return yaml_parser_fetch_flow_collection_start(parser, YAML_FLOW_MAPPING_START_TOKEN);
258 }
259 if CHECK!((*parser).buffer, b']') {
260 return yaml_parser_fetch_flow_collection_end(parser, YAML_FLOW_SEQUENCE_END_TOKEN);
261 }
262 if CHECK!((*parser).buffer, b'}') {
263 return yaml_parser_fetch_flow_collection_end(parser, YAML_FLOW_MAPPING_END_TOKEN);
264 }
265 if CHECK!((*parser).buffer, b',') {
266 return yaml_parser_fetch_flow_entry(parser);
267 }
268 if CHECK!((*parser).buffer, b'-') && IS_BLANKZ_AT!((*parser).buffer, 1) {
269 return yaml_parser_fetch_block_entry(parser);
270 }
271 if CHECK!((*parser).buffer, b'?')
272 && ((*parser).flow_level != 0 || IS_BLANKZ_AT!((*parser).buffer, 1))
273 {
274 return yaml_parser_fetch_key(parser);
275 }
276 if CHECK!((*parser).buffer, b':')
277 && ((*parser).flow_level != 0 || IS_BLANKZ_AT!((*parser).buffer, 1))
278 {
279 return yaml_parser_fetch_value(parser);
280 }
281 if CHECK!((*parser).buffer, b'*') {
282 return yaml_parser_fetch_anchor(parser, YAML_ALIAS_TOKEN);
283 }
284 if CHECK!((*parser).buffer, b'&') {
285 return yaml_parser_fetch_anchor(parser, YAML_ANCHOR_TOKEN);
286 }
287 if CHECK!((*parser).buffer, b'!') {
288 return yaml_parser_fetch_tag(parser);
289 }
290 if CHECK!((*parser).buffer, b'|') && (*parser).flow_level == 0 {
291 return yaml_parser_fetch_block_scalar(parser, true);
292 }
293 if CHECK!((*parser).buffer, b'>') && (*parser).flow_level == 0 {
294 return yaml_parser_fetch_block_scalar(parser, false);
295 }
296 if CHECK!((*parser).buffer, b'\'') {
297 return yaml_parser_fetch_flow_scalar(parser, true);
298 }
299 if CHECK!((*parser).buffer, b'"') {
300 return yaml_parser_fetch_flow_scalar(parser, false);
301 }
302 if !(IS_BLANKZ!((*parser).buffer)
303 || CHECK!((*parser).buffer, b'-')
304 || CHECK!((*parser).buffer, b'?')
305 || CHECK!((*parser).buffer, b':')
306 || CHECK!((*parser).buffer, b',')
307 || CHECK!((*parser).buffer, b'[')
308 || CHECK!((*parser).buffer, b']')
309 || CHECK!((*parser).buffer, b'{')
310 || CHECK!((*parser).buffer, b'}')
311 || CHECK!((*parser).buffer, b'#')
312 || CHECK!((*parser).buffer, b'&')
313 || CHECK!((*parser).buffer, b'*')
314 || CHECK!((*parser).buffer, b'!')
315 || CHECK!((*parser).buffer, b'|')
316 || CHECK!((*parser).buffer, b'>')
317 || CHECK!((*parser).buffer, b'\'')
318 || CHECK!((*parser).buffer, b'"')
319 || CHECK!((*parser).buffer, b'%')
320 || CHECK!((*parser).buffer, b'@')
321 || CHECK!((*parser).buffer, b'`'))
322 || CHECK!((*parser).buffer, b'-') && !IS_BLANK_AT!((*parser).buffer, 1)
323 || (*parser).flow_level == 0
324 && (CHECK!((*parser).buffer, b'?') || CHECK!((*parser).buffer, b':'))
325 && !IS_BLANKZ_AT!((*parser).buffer, 1)
326 {
327 return yaml_parser_fetch_plain_scalar(parser);
328 }
329 yaml_parser_set_scanner_error(
330 parser,
331 b"while scanning for the next token\0" as *const u8 as *const libc::c_char,
332 (*parser).mark,
333 b"found character that cannot start any token\0" as *const u8 as *const libc::c_char,
334 );
335 FAIL
336}
337
338unsafe fn yaml_parser_stale_simple_keys(parser: *mut yaml_parser_t) -> Success {
339 let mut simple_key: *mut yaml_simple_key_t;
340 simple_key = (*parser)
341 .simple_keys
342 .start
343 .add((*parser).not_simple_keys as usize);
344 while simple_key != (*parser).simple_keys.top {
345 if (*simple_key).possible
346 && ((*simple_key).mark.line < (*parser).mark.line
347 || (*simple_key).mark.index.force_add(1024_u64) < (*parser).mark.index)
348 {
349 if (*simple_key).required {
350 yaml_parser_set_scanner_error(
351 parser,
352 b"while scanning a simple key\0" as *const u8 as *const libc::c_char,
353 (*simple_key).mark,
354 b"could not find expected ':'\0" as *const u8 as *const libc::c_char,
355 );
356 return FAIL;
357 }
358 (*simple_key).possible = false;
359 if (*parser)
360 .simple_keys
361 .start
362 .add((*parser).not_simple_keys as usize)
363 == simple_key
364 {
365 (*parser).not_simple_keys += 1;
366 }
367 }
368 simple_key = simple_key.wrapping_offset(1);
369 }
370 OK
371}
372
373unsafe fn yaml_parser_save_simple_key(parser: *mut yaml_parser_t) -> Success {
374 let required = (*parser).flow_level == 0
375 && (*parser).indent as libc::c_long == (*parser).mark.column as ptrdiff_t;
376 if (*parser).simple_key_allowed {
377 let simple_key = yaml_simple_key_t {
378 possible: true,
379 required,
380 token_number: (*parser).tokens_parsed.force_add(
381 (*parser).tokens.tail.c_offset_from((*parser).tokens.head) as libc::c_ulong,
382 ),
383 mark: (*parser).mark,
384 };
385 if yaml_parser_remove_simple_key(parser).fail {
386 return FAIL;
387 }
388 *(*parser).simple_keys.top.wrapping_offset(-1_isize) = simple_key;
389 if (*parser)
390 .simple_keys
391 .start
392 .add((*parser).not_simple_keys as usize)
393 == (*parser).simple_keys.top
394 {
395 (*parser).not_simple_keys -= 1;
396 }
397 }
398 OK
399}
400
401unsafe fn yaml_parser_remove_simple_key(parser: *mut yaml_parser_t) -> Success {
402 let simple_key: *mut yaml_simple_key_t = (*parser).simple_keys.top.wrapping_offset(-1_isize);
403 if (*simple_key).possible {
404 if (*simple_key).required {
405 yaml_parser_set_scanner_error(
406 parser,
407 b"while scanning a simple key\0" as *const u8 as *const libc::c_char,
408 (*simple_key).mark,
409 b"could not find expected ':'\0" as *const u8 as *const libc::c_char,
410 );
411 return FAIL;
412 }
413 }
414 (*simple_key).possible = false;
415 OK
416}
417
418unsafe fn yaml_parser_increase_flow_level(parser: *mut yaml_parser_t) -> Success {
419 let empty_simple_key = yaml_simple_key_t {
420 possible: false,
421 required: false,
422 token_number: 0_u64,
423 mark: yaml_mark_t {
424 index: 0_u64,
425 line: 0_u64,
426 column: 0_u64,
427 },
428 };
429 PUSH!((*parser).simple_keys, empty_simple_key);
430 if (*parser).flow_level == libc::c_int::MAX {
431 (*parser).error = YAML_MEMORY_ERROR;
432 return FAIL;
433 }
434 let fresh7 = addr_of_mut!((*parser).flow_level);
435 *fresh7 += 1;
436 OK
437}
438
439unsafe fn yaml_parser_decrease_flow_level(parser: *mut yaml_parser_t) {
440 if (*parser).flow_level != 0 {
441 let fresh8 = addr_of_mut!((*parser).flow_level);
442 *fresh8 -= 1;
443 if (*parser)
444 .simple_keys
445 .start
446 .add((*parser).not_simple_keys as usize)
447 == (*parser).simple_keys.top
448 {
449 (*parser).not_simple_keys -= 1;
450 }
451 let _ = POP!((*parser).simple_keys);
452 }
453}
454
455unsafe fn yaml_parser_roll_indent(
456 parser: *mut yaml_parser_t,
457 column: ptrdiff_t,
458 number: ptrdiff_t,
459 type_: yaml_token_type_t,
460 mark: yaml_mark_t,
461) -> Success {
462 let mut token = MaybeUninit::<yaml_token_t>::uninit();
463 let token = token.as_mut_ptr();
464 if (*parser).flow_level != 0 {
465 return OK;
466 }
467 if ((*parser).indent as libc::c_long) < column {
468 PUSH!((*parser).indents, (*parser).indent);
469 if column > ptrdiff_t::from(libc::c_int::MAX) {
470 (*parser).error = YAML_MEMORY_ERROR;
471 return FAIL;
472 }
473 (*parser).indent = column as libc::c_int;
474 memset(
475 token as *mut libc::c_void,
476 0,
477 size_of::<yaml_token_t>() as libc::c_ulong,
478 );
479 (*token).type_ = type_;
480 (*token).start_mark = mark;
481 (*token).end_mark = mark;
482 if number == -1_i64 {
483 ENQUEUE!((*parser).tokens, *token);
484 } else {
485 QUEUE_INSERT!(
486 (*parser).tokens,
487 (number as libc::c_ulong).wrapping_sub((*parser).tokens_parsed),
488 *token
489 );
490 }
491 }
492 OK
493}
494
495unsafe fn yaml_parser_unroll_indent(parser: *mut yaml_parser_t, column: ptrdiff_t) {
496 let mut token = MaybeUninit::<yaml_token_t>::uninit();
497 let token = token.as_mut_ptr();
498 if (*parser).flow_level != 0 {
499 return;
500 }
501 while (*parser).indent as libc::c_long > column {
502 memset(
503 token as *mut libc::c_void,
504 0,
505 size_of::<yaml_token_t>() as libc::c_ulong,
506 );
507 (*token).type_ = YAML_BLOCK_END_TOKEN;
508 (*token).start_mark = (*parser).mark;
509 (*token).end_mark = (*parser).mark;
510 ENQUEUE!((*parser).tokens, *token);
511 (*parser).indent = POP!((*parser).indents);
512 }
513}
514
515unsafe fn yaml_parser_fetch_stream_start(parser: *mut yaml_parser_t) {
516 let simple_key = yaml_simple_key_t {
517 possible: false,
518 required: false,
519 token_number: 0_u64,
520 mark: yaml_mark_t {
521 index: 0_u64,
522 line: 0_u64,
523 column: 0_u64,
524 },
525 };
526 let mut token = MaybeUninit::<yaml_token_t>::uninit();
527 let token = token.as_mut_ptr();
528 (*parser).indent = -1;
529 PUSH!((*parser).simple_keys, simple_key);
530 (*parser).not_simple_keys = 1;
531 (*parser).simple_key_allowed = true;
532 (*parser).stream_start_produced = true;
533 memset(
534 token as *mut libc::c_void,
535 0,
536 size_of::<yaml_token_t>() as libc::c_ulong,
537 );
538 (*token).type_ = YAML_STREAM_START_TOKEN;
539 (*token).start_mark = (*parser).mark;
540 (*token).end_mark = (*parser).mark;
541 (*token).data.stream_start.encoding = (*parser).encoding;
542 ENQUEUE!((*parser).tokens, *token);
543}
544
545unsafe fn yaml_parser_fetch_stream_end(parser: *mut yaml_parser_t) -> Success {
546 let mut token = MaybeUninit::<yaml_token_t>::uninit();
547 let token = token.as_mut_ptr();
548 if (*parser).mark.column != 0_u64 {
549 (*parser).mark.column = 0_u64;
550 let fresh22 = addr_of_mut!((*parser).mark.line);
551 *fresh22 = (*fresh22).force_add(1);
552 }
553 yaml_parser_unroll_indent(parser, -1_i64);
554 if yaml_parser_remove_simple_key(parser).fail {
555 return FAIL;
556 }
557 (*parser).simple_key_allowed = false;
558 memset(
559 token as *mut libc::c_void,
560 0,
561 size_of::<yaml_token_t>() as libc::c_ulong,
562 );
563 (*token).type_ = YAML_STREAM_END_TOKEN;
564 (*token).start_mark = (*parser).mark;
565 (*token).end_mark = (*parser).mark;
566 ENQUEUE!((*parser).tokens, *token);
567 OK
568}
569
570unsafe fn yaml_parser_fetch_directive(parser: *mut yaml_parser_t) -> Success {
571 let mut token = MaybeUninit::<yaml_token_t>::uninit();
572 let token = token.as_mut_ptr();
573 yaml_parser_unroll_indent(parser, -1_i64);
574 if yaml_parser_remove_simple_key(parser).fail {
575 return FAIL;
576 }
577 (*parser).simple_key_allowed = false;
578 if yaml_parser_scan_directive(parser, token).fail {
579 return FAIL;
580 }
581 ENQUEUE!((*parser).tokens, *token);
582 OK
583}
584
585unsafe fn yaml_parser_fetch_document_indicator(
586 parser: *mut yaml_parser_t,
587 type_: yaml_token_type_t,
588) -> Success {
589 let mut token = MaybeUninit::<yaml_token_t>::uninit();
590 let token = token.as_mut_ptr();
591 yaml_parser_unroll_indent(parser, -1_i64);
592 if yaml_parser_remove_simple_key(parser).fail {
593 return FAIL;
594 }
595 (*parser).simple_key_allowed = false;
596 let start_mark: yaml_mark_t = (*parser).mark;
597 SKIP(parser);
598 SKIP(parser);
599 SKIP(parser);
600 let end_mark: yaml_mark_t = (*parser).mark;
601 memset(
602 token as *mut libc::c_void,
603 0,
604 size_of::<yaml_token_t>() as libc::c_ulong,
605 );
606 (*token).type_ = type_;
607 (*token).start_mark = start_mark;
608 (*token).end_mark = end_mark;
609 ENQUEUE!((*parser).tokens, *token);
610 OK
611}
612
613unsafe fn yaml_parser_fetch_flow_collection_start(
614 parser: *mut yaml_parser_t,
615 type_: yaml_token_type_t,
616) -> Success {
617 let mut token = MaybeUninit::<yaml_token_t>::uninit();
618 let token = token.as_mut_ptr();
619 if yaml_parser_save_simple_key(parser).fail {
620 return FAIL;
621 }
622 if yaml_parser_increase_flow_level(parser).fail {
623 return FAIL;
624 }
625 (*parser).simple_key_allowed = true;
626 let start_mark: yaml_mark_t = (*parser).mark;
627 SKIP(parser);
628 let end_mark: yaml_mark_t = (*parser).mark;
629 memset(
630 token as *mut libc::c_void,
631 0,
632 size_of::<yaml_token_t>() as libc::c_ulong,
633 );
634 (*token).type_ = type_;
635 (*token).start_mark = start_mark;
636 (*token).end_mark = end_mark;
637 ENQUEUE!((*parser).tokens, *token);
638 OK
639}
640
641unsafe fn yaml_parser_fetch_flow_collection_end(
642 parser: *mut yaml_parser_t,
643 type_: yaml_token_type_t,
644) -> Success {
645 let mut token = MaybeUninit::<yaml_token_t>::uninit();
646 let token = token.as_mut_ptr();
647 if yaml_parser_remove_simple_key(parser).fail {
648 return FAIL;
649 }
650 yaml_parser_decrease_flow_level(parser);
651 (*parser).simple_key_allowed = false;
652 let start_mark: yaml_mark_t = (*parser).mark;
653 SKIP(parser);
654 let end_mark: yaml_mark_t = (*parser).mark;
655 memset(
656 token as *mut libc::c_void,
657 0,
658 size_of::<yaml_token_t>() as libc::c_ulong,
659 );
660 (*token).type_ = type_;
661 (*token).start_mark = start_mark;
662 (*token).end_mark = end_mark;
663 ENQUEUE!((*parser).tokens, *token);
664 OK
665}
666
667unsafe fn yaml_parser_fetch_flow_entry(parser: *mut yaml_parser_t) -> Success {
668 let mut token = MaybeUninit::<yaml_token_t>::uninit();
669 let token = token.as_mut_ptr();
670 if yaml_parser_remove_simple_key(parser).fail {
671 return FAIL;
672 }
673 (*parser).simple_key_allowed = true;
674 let start_mark: yaml_mark_t = (*parser).mark;
675 SKIP(parser);
676 let end_mark: yaml_mark_t = (*parser).mark;
677 memset(
678 token as *mut libc::c_void,
679 0,
680 size_of::<yaml_token_t>() as libc::c_ulong,
681 );
682 (*token).type_ = YAML_FLOW_ENTRY_TOKEN;
683 (*token).start_mark = start_mark;
684 (*token).end_mark = end_mark;
685 ENQUEUE!((*parser).tokens, *token);
686 OK
687}
688
689unsafe fn yaml_parser_fetch_block_entry(parser: *mut yaml_parser_t) -> Success {
690 let mut token = MaybeUninit::<yaml_token_t>::uninit();
691 let token = token.as_mut_ptr();
692 if (*parser).flow_level == 0 {
693 if !(*parser).simple_key_allowed {
694 yaml_parser_set_scanner_error(
695 parser,
696 ptr::null::<libc::c_char>(),
697 (*parser).mark,
698 b"block sequence entries are not allowed in this context\0" as *const u8
699 as *const libc::c_char,
700 );
701 return FAIL;
702 }
703 if yaml_parser_roll_indent(
704 parser,
705 (*parser).mark.column as ptrdiff_t,
706 -1_i64,
707 YAML_BLOCK_SEQUENCE_START_TOKEN,
708 (*parser).mark,
709 )
710 .fail
711 {
712 return FAIL;
713 }
714 }
715 if yaml_parser_remove_simple_key(parser).fail {
716 return FAIL;
717 }
718 (*parser).simple_key_allowed = true;
719 let start_mark: yaml_mark_t = (*parser).mark;
720 SKIP(parser);
721 let end_mark: yaml_mark_t = (*parser).mark;
722 memset(
723 token as *mut libc::c_void,
724 0,
725 size_of::<yaml_token_t>() as libc::c_ulong,
726 );
727 (*token).type_ = YAML_BLOCK_ENTRY_TOKEN;
728 (*token).start_mark = start_mark;
729 (*token).end_mark = end_mark;
730 ENQUEUE!((*parser).tokens, *token);
731 OK
732}
733
734unsafe fn yaml_parser_fetch_key(parser: *mut yaml_parser_t) -> Success {
735 let mut token = MaybeUninit::<yaml_token_t>::uninit();
736 let token = token.as_mut_ptr();
737 if (*parser).flow_level == 0 {
738 if !(*parser).simple_key_allowed {
739 yaml_parser_set_scanner_error(
740 parser,
741 ptr::null::<libc::c_char>(),
742 (*parser).mark,
743 b"mapping keys are not allowed in this context\0" as *const u8
744 as *const libc::c_char,
745 );
746 return FAIL;
747 }
748 if yaml_parser_roll_indent(
749 parser,
750 (*parser).mark.column as ptrdiff_t,
751 -1_i64,
752 YAML_BLOCK_MAPPING_START_TOKEN,
753 (*parser).mark,
754 )
755 .fail
756 {
757 return FAIL;
758 }
759 }
760 if yaml_parser_remove_simple_key(parser).fail {
761 return FAIL;
762 }
763 (*parser).simple_key_allowed = (*parser).flow_level == 0;
764 let start_mark: yaml_mark_t = (*parser).mark;
765 SKIP(parser);
766 let end_mark: yaml_mark_t = (*parser).mark;
767 memset(
768 token as *mut libc::c_void,
769 0,
770 size_of::<yaml_token_t>() as libc::c_ulong,
771 );
772 (*token).type_ = YAML_KEY_TOKEN;
773 (*token).start_mark = start_mark;
774 (*token).end_mark = end_mark;
775 ENQUEUE!((*parser).tokens, *token);
776 OK
777}
778
779unsafe fn yaml_parser_fetch_value(parser: *mut yaml_parser_t) -> Success {
780 let mut token = MaybeUninit::<yaml_token_t>::uninit();
781 let token = token.as_mut_ptr();
782 let simple_key: *mut yaml_simple_key_t = (*parser).simple_keys.top.wrapping_offset(-1_isize);
783 if (*simple_key).possible {
784 memset(
785 token as *mut libc::c_void,
786 0,
787 size_of::<yaml_token_t>() as libc::c_ulong,
788 );
789 (*token).type_ = YAML_KEY_TOKEN;
790 (*token).start_mark = (*simple_key).mark;
791 (*token).end_mark = (*simple_key).mark;
792 QUEUE_INSERT!(
793 (*parser).tokens,
794 ((*simple_key).token_number).wrapping_sub((*parser).tokens_parsed),
795 *token
796 );
797 if yaml_parser_roll_indent(
798 parser,
799 (*simple_key).mark.column as ptrdiff_t,
800 (*simple_key).token_number as ptrdiff_t,
801 YAML_BLOCK_MAPPING_START_TOKEN,
802 (*simple_key).mark,
803 )
804 .fail
805 {
806 return FAIL;
807 }
808 (*simple_key).possible = false;
809 (*parser).simple_key_allowed = false;
810 } else {
811 if (*parser).flow_level == 0 {
812 if !(*parser).simple_key_allowed {
813 yaml_parser_set_scanner_error(
814 parser,
815 ptr::null::<libc::c_char>(),
816 (*parser).mark,
817 b"mapping values are not allowed in this context\0" as *const u8
818 as *const libc::c_char,
819 );
820 return FAIL;
821 }
822 if yaml_parser_roll_indent(
823 parser,
824 (*parser).mark.column as ptrdiff_t,
825 -1_i64,
826 YAML_BLOCK_MAPPING_START_TOKEN,
827 (*parser).mark,
828 )
829 .fail
830 {
831 return FAIL;
832 }
833 }
834 (*parser).simple_key_allowed = (*parser).flow_level == 0;
835 }
836 let start_mark: yaml_mark_t = (*parser).mark;
837 SKIP(parser);
838 let end_mark: yaml_mark_t = (*parser).mark;
839 memset(
840 token as *mut libc::c_void,
841 0,
842 size_of::<yaml_token_t>() as libc::c_ulong,
843 );
844 (*token).type_ = YAML_VALUE_TOKEN;
845 (*token).start_mark = start_mark;
846 (*token).end_mark = end_mark;
847 ENQUEUE!((*parser).tokens, *token);
848 OK
849}
850
851unsafe fn yaml_parser_fetch_anchor(
852 parser: *mut yaml_parser_t,
853 type_: yaml_token_type_t,
854) -> Success {
855 let mut token = MaybeUninit::<yaml_token_t>::uninit();
856 let token = token.as_mut_ptr();
857 if yaml_parser_save_simple_key(parser).fail {
858 return FAIL;
859 }
860 (*parser).simple_key_allowed = false;
861 if yaml_parser_scan_anchor(parser, token, type_).fail {
862 return FAIL;
863 }
864 ENQUEUE!((*parser).tokens, *token);
865 OK
866}
867
868unsafe fn yaml_parser_fetch_tag(parser: *mut yaml_parser_t) -> Success {
869 let mut token = MaybeUninit::<yaml_token_t>::uninit();
870 let token = token.as_mut_ptr();
871 if yaml_parser_save_simple_key(parser).fail {
872 return FAIL;
873 }
874 (*parser).simple_key_allowed = false;
875 if yaml_parser_scan_tag(parser, token).fail {
876 return FAIL;
877 }
878 ENQUEUE!((*parser).tokens, *token);
879 OK
880}
881
882unsafe fn yaml_parser_fetch_block_scalar(parser: *mut yaml_parser_t, literal: bool) -> Success {
883 let mut token = MaybeUninit::<yaml_token_t>::uninit();
884 let token = token.as_mut_ptr();
885 if yaml_parser_remove_simple_key(parser).fail {
886 return FAIL;
887 }
888 (*parser).simple_key_allowed = true;
889 if yaml_parser_scan_block_scalar(parser, token, literal).fail {
890 return FAIL;
891 }
892 ENQUEUE!((*parser).tokens, *token);
893 OK
894}
895
896unsafe fn yaml_parser_fetch_flow_scalar(parser: *mut yaml_parser_t, single: bool) -> Success {
897 let mut token = MaybeUninit::<yaml_token_t>::uninit();
898 let token = token.as_mut_ptr();
899 if yaml_parser_save_simple_key(parser).fail {
900 return FAIL;
901 }
902 (*parser).simple_key_allowed = false;
903 if yaml_parser_scan_flow_scalar(parser, token, single).fail {
904 return FAIL;
905 }
906 ENQUEUE!((*parser).tokens, *token);
907 OK
908}
909
910unsafe fn yaml_parser_fetch_plain_scalar(parser: *mut yaml_parser_t) -> Success {
911 let mut token = MaybeUninit::<yaml_token_t>::uninit();
912 let token = token.as_mut_ptr();
913 if yaml_parser_save_simple_key(parser).fail {
914 return FAIL;
915 }
916 (*parser).simple_key_allowed = false;
917 if yaml_parser_scan_plain_scalar(parser, token).fail {
918 return FAIL;
919 }
920 ENQUEUE!((*parser).tokens, *token);
921 OK
922}
923
924unsafe fn yaml_parser_scan_to_next_token(parser: *mut yaml_parser_t) -> Success {
925 loop {
926 if CACHE(parser, 1_u64).fail {
927 return FAIL;
928 }
929 if (*parser).mark.column == 0_u64 && IS_BOM!((*parser).buffer) {
930 SKIP(parser);
931 }
932 if CACHE(parser, 1_u64).fail {
933 return FAIL;
934 }
935 while CHECK!((*parser).buffer, b' ')
936 || ((*parser).flow_level != 0 || !(*parser).simple_key_allowed)
937 && CHECK!((*parser).buffer, b'\t')
938 {
939 SKIP(parser);
940 if CACHE(parser, 1_u64).fail {
941 return FAIL;
942 }
943 }
944 if CHECK!((*parser).buffer, b'#') {
945 while !IS_BREAKZ!((*parser).buffer) {
946 SKIP(parser);
947 if CACHE(parser, 1_u64).fail {
948 return FAIL;
949 }
950 }
951 }
952 if !IS_BREAK!((*parser).buffer) {
953 break;
954 }
955 if CACHE(parser, 2_u64).fail {
956 return FAIL;
957 }
958 SKIP_LINE(parser);
959 if (*parser).flow_level == 0 {
960 (*parser).simple_key_allowed = true;
961 }
962 }
963 OK
964}
965
966unsafe fn yaml_parser_scan_directive(
967 parser: *mut yaml_parser_t,
968 token: *mut yaml_token_t,
969) -> Success {
970 let mut current_block: u64;
971 let end_mark: yaml_mark_t;
972 let mut name: *mut yaml_char_t = ptr::null_mut::<yaml_char_t>();
973 let mut major: libc::c_int = 0;
974 let mut minor: libc::c_int = 0;
975 let mut handle: *mut yaml_char_t = ptr::null_mut::<yaml_char_t>();
976 let mut prefix: *mut yaml_char_t = ptr::null_mut::<yaml_char_t>();
977 let start_mark: yaml_mark_t = (*parser).mark;
978 SKIP(parser);
979 if yaml_parser_scan_directive_name(parser, start_mark, addr_of_mut!(name)).ok {
980 if strcmp(
981 name as *mut libc::c_char,
982 b"YAML\0" as *const u8 as *const libc::c_char,
983 ) == 0
984 {
985 if yaml_parser_scan_version_directive_value(
986 parser,
987 start_mark,
988 addr_of_mut!(major),
989 addr_of_mut!(minor),
990 )
991 .fail
992 {
993 current_block = 11397968426844348457;
994 } else {
995 end_mark = (*parser).mark;
996 memset(
997 token as *mut libc::c_void,
998 0,
999 size_of::<yaml_token_t>() as libc::c_ulong,
1000 );
1001 (*token).type_ = YAML_VERSION_DIRECTIVE_TOKEN;
1002 (*token).start_mark = start_mark;
1003 (*token).end_mark = end_mark;
1004 (*token).data.version_directive.major = major;
1005 (*token).data.version_directive.minor = minor;
1006 current_block = 17407779659766490442;
1007 }
1008 } else if strcmp(
1009 name as *mut libc::c_char,
1010 b"TAG\0" as *const u8 as *const libc::c_char,
1011 ) == 0
1012 {
1013 if yaml_parser_scan_tag_directive_value(
1014 parser,
1015 start_mark,
1016 addr_of_mut!(handle),
1017 addr_of_mut!(prefix),
1018 )
1019 .fail
1020 {
1021 current_block = 11397968426844348457;
1022 } else {
1023 end_mark = (*parser).mark;
1024 memset(
1025 token as *mut libc::c_void,
1026 0,
1027 size_of::<yaml_token_t>() as libc::c_ulong,
1028 );
1029 (*token).type_ = YAML_TAG_DIRECTIVE_TOKEN;
1030 (*token).start_mark = start_mark;
1031 (*token).end_mark = end_mark;
1032 let fresh112 = addr_of_mut!((*token).data.tag_directive.handle);
1033 *fresh112 = handle;
1034 let fresh113 = addr_of_mut!((*token).data.tag_directive.prefix);
1035 *fresh113 = prefix;
1036 current_block = 17407779659766490442;
1037 }
1038 } else {
1039 yaml_parser_set_scanner_error(
1040 parser,
1041 b"while scanning a directive\0" as *const u8 as *const libc::c_char,
1042 start_mark,
1043 b"found unknown directive name\0" as *const u8 as *const libc::c_char,
1044 );
1045 current_block = 11397968426844348457;
1046 }
1047 if current_block != 11397968426844348457 {
1048 if CACHE(parser, 1_u64).ok {
1049 loop {
1050 if !IS_BLANK!((*parser).buffer) {
1051 current_block = 11584701595673473500;
1052 break;
1053 }
1054 SKIP(parser);
1055 if CACHE(parser, 1_u64).fail {
1056 current_block = 11397968426844348457;
1057 break;
1058 }
1059 }
1060 if current_block != 11397968426844348457 {
1061 if CHECK!((*parser).buffer, b'#') {
1062 loop {
1063 if IS_BREAKZ!((*parser).buffer) {
1064 current_block = 6669252993407410313;
1065 break;
1066 }
1067 SKIP(parser);
1068 if CACHE(parser, 1_u64).fail {
1069 current_block = 11397968426844348457;
1070 break;
1071 }
1072 }
1073 } else {
1074 current_block = 6669252993407410313;
1075 }
1076 if current_block != 11397968426844348457 {
1077 if !IS_BREAKZ!((*parser).buffer) {
1078 yaml_parser_set_scanner_error(
1079 parser,
1080 b"while scanning a directive\0" as *const u8 as *const libc::c_char,
1081 start_mark,
1082 b"did not find expected comment or line break\0" as *const u8
1083 as *const libc::c_char,
1084 );
1085 } else {
1086 if IS_BREAK!((*parser).buffer) {
1087 if CACHE(parser, 2_u64).fail {
1088 current_block = 11397968426844348457;
1089 } else {
1090 SKIP_LINE(parser);
1091 current_block = 652864300344834934;
1092 }
1093 } else {
1094 current_block = 652864300344834934;
1095 }
1096 if current_block != 11397968426844348457 {
1097 yaml_free(name as *mut libc::c_void);
1098 return OK;
1099 }
1100 }
1101 }
1102 }
1103 }
1104 }
1105 }
1106 yaml_free(prefix as *mut libc::c_void);
1107 yaml_free(handle as *mut libc::c_void);
1108 yaml_free(name as *mut libc::c_void);
1109 FAIL
1110}
1111
1112unsafe fn yaml_parser_scan_directive_name(
1113 parser: *mut yaml_parser_t,
1114 start_mark: yaml_mark_t,
1115 name: *mut *mut yaml_char_t,
1116) -> Success {
1117 let current_block: u64;
1118 let mut string = NULL_STRING;
1119 STRING_INIT!(string);
1120 if CACHE(parser, 1_u64).ok {
1121 loop {
1122 if !IS_ALPHA!((*parser).buffer) {
1123 current_block = 10879442775620481940;
1124 break;
1125 }
1126 READ!(parser, string);
1127 if CACHE(parser, 1_u64).fail {
1128 current_block = 8318012024179131575;
1129 break;
1130 }
1131 }
1132 if current_block != 8318012024179131575 {
1133 if string.start == string.pointer {
1134 yaml_parser_set_scanner_error(
1135 parser,
1136 b"while scanning a directive\0" as *const u8 as *const libc::c_char,
1137 start_mark,
1138 b"could not find expected directive name\0" as *const u8 as *const libc::c_char,
1139 );
1140 } else if !IS_BLANKZ!((*parser).buffer) {
1141 yaml_parser_set_scanner_error(
1142 parser,
1143 b"while scanning a directive\0" as *const u8 as *const libc::c_char,
1144 start_mark,
1145 b"found unexpected non-alphabetical character\0" as *const u8
1146 as *const libc::c_char,
1147 );
1148 } else {
1149 *name = string.start;
1150 return OK;
1151 }
1152 }
1153 }
1154 STRING_DEL!(string);
1155 FAIL
1156}
1157
1158unsafe fn yaml_parser_scan_version_directive_value(
1159 parser: *mut yaml_parser_t,
1160 start_mark: yaml_mark_t,
1161 major: *mut libc::c_int,
1162 minor: *mut libc::c_int,
1163) -> Success {
1164 if CACHE(parser, 1_u64).fail {
1165 return FAIL;
1166 }
1167 while IS_BLANK!((*parser).buffer) {
1168 SKIP(parser);
1169 if CACHE(parser, 1_u64).fail {
1170 return FAIL;
1171 }
1172 }
1173 if yaml_parser_scan_version_directive_number(parser, start_mark, major).fail {
1174 return FAIL;
1175 }
1176 if !CHECK!((*parser).buffer, b'.') {
1177 yaml_parser_set_scanner_error(
1178 parser,
1179 b"while scanning a %YAML directive\0" as *const u8 as *const libc::c_char,
1180 start_mark,
1181 b"did not find expected digit or '.' character\0" as *const u8 as *const libc::c_char,
1182 );
1183 return FAIL;
1184 }
1185 SKIP(parser);
1186 yaml_parser_scan_version_directive_number(parser, start_mark, minor)
1187}
1188
1189const MAX_NUMBER_LENGTH: u64 = 9_u64;
1190
1191unsafe fn yaml_parser_scan_version_directive_number(
1192 parser: *mut yaml_parser_t,
1193 start_mark: yaml_mark_t,
1194 number: *mut libc::c_int,
1195) -> Success {
1196 let mut value: libc::c_int = 0;
1197 let mut length: size_t = 0_u64;
1198 if CACHE(parser, 1_u64).fail {
1199 return FAIL;
1200 }
1201 while IS_DIGIT!((*parser).buffer) {
1202 length = length.force_add(1);
1203 if length > MAX_NUMBER_LENGTH {
1204 yaml_parser_set_scanner_error(
1205 parser,
1206 b"while scanning a %YAML directive\0" as *const u8 as *const libc::c_char,
1207 start_mark,
1208 b"found extremely long version number\0" as *const u8 as *const libc::c_char,
1209 );
1210 return FAIL;
1211 }
1212 value = value.force_mul(10).force_add(AS_DIGIT!((*parser).buffer));
1213 SKIP(parser);
1214 if CACHE(parser, 1_u64).fail {
1215 return FAIL;
1216 }
1217 }
1218 if length == 0 {
1219 yaml_parser_set_scanner_error(
1220 parser,
1221 b"while scanning a %YAML directive\0" as *const u8 as *const libc::c_char,
1222 start_mark,
1223 b"did not find expected version number\0" as *const u8 as *const libc::c_char,
1224 );
1225 return FAIL;
1226 }
1227 *number = value;
1228 OK
1229}
1230
1231unsafe fn yaml_parser_scan_tag_directive_value(
1232 parser: *mut yaml_parser_t,
1233 start_mark: yaml_mark_t,
1234 handle: *mut *mut yaml_char_t,
1235 prefix: *mut *mut yaml_char_t,
1236) -> Success {
1237 let mut current_block: u64;
1238 let mut handle_value: *mut yaml_char_t = ptr::null_mut::<yaml_char_t>();
1239 let mut prefix_value: *mut yaml_char_t = ptr::null_mut::<yaml_char_t>();
1240 if CACHE(parser, 1_u64).fail {
1241 current_block = 5231181710497607163;
1242 } else {
1243 current_block = 14916268686031723178;
1244 }
1245 'c_34337: loop {
1246 match current_block {
1247 5231181710497607163 => {
1248 yaml_free(handle_value as *mut libc::c_void);
1249 yaml_free(prefix_value as *mut libc::c_void);
1250 return FAIL;
1251 }
1252 _ => {
1253 if IS_BLANK!((*parser).buffer) {
1254 SKIP(parser);
1255 if CACHE(parser, 1_u64).fail {
1256 current_block = 5231181710497607163;
1257 } else {
1258 current_block = 14916268686031723178;
1259 }
1260 } else {
1261 if yaml_parser_scan_tag_handle(
1262 parser,
1263 true,
1264 start_mark,
1265 addr_of_mut!(handle_value),
1266 )
1267 .fail
1268 {
1269 current_block = 5231181710497607163;
1270 continue;
1271 }
1272 if CACHE(parser, 1_u64).fail {
1273 current_block = 5231181710497607163;
1274 continue;
1275 }
1276 if !IS_BLANK!((*parser).buffer) {
1277 yaml_parser_set_scanner_error(
1278 parser,
1279 b"while scanning a %TAG directive\0" as *const u8
1280 as *const libc::c_char,
1281 start_mark,
1282 b"did not find expected whitespace\0" as *const u8
1283 as *const libc::c_char,
1284 );
1285 current_block = 5231181710497607163;
1286 } else {
1287 while IS_BLANK!((*parser).buffer) {
1288 SKIP(parser);
1289 if CACHE(parser, 1_u64).fail {
1290 current_block = 5231181710497607163;
1291 continue 'c_34337;
1292 }
1293 }
1294 if yaml_parser_scan_tag_uri(
1295 parser,
1296 true,
1297 true,
1298 ptr::null_mut::<yaml_char_t>(),
1299 start_mark,
1300 addr_of_mut!(prefix_value),
1301 )
1302 .fail
1303 {
1304 current_block = 5231181710497607163;
1305 continue;
1306 }
1307 if CACHE(parser, 1_u64).fail {
1308 current_block = 5231181710497607163;
1309 continue;
1310 }
1311 if !IS_BLANKZ!((*parser).buffer) {
1312 yaml_parser_set_scanner_error(
1313 parser,
1314 b"while scanning a %TAG directive\0" as *const u8
1315 as *const libc::c_char,
1316 start_mark,
1317 b"did not find expected whitespace or line break\0" as *const u8
1318 as *const libc::c_char,
1319 );
1320 current_block = 5231181710497607163;
1321 } else {
1322 *handle = handle_value;
1323 *prefix = prefix_value;
1324 return OK;
1325 }
1326 }
1327 }
1328 }
1329 }
1330 }
1331}
1332
1333unsafe fn yaml_parser_scan_anchor(
1334 parser: *mut yaml_parser_t,
1335 token: *mut yaml_token_t,
1336 type_: yaml_token_type_t,
1337) -> Success {
1338 let current_block: u64;
1339 let mut length: libc::c_int = 0;
1340 let end_mark: yaml_mark_t;
1341 let mut string = NULL_STRING;
1342 STRING_INIT!(string);
1343 let start_mark: yaml_mark_t = (*parser).mark;
1344 SKIP(parser);
1345 if CACHE(parser, 1_u64).ok {
1346 loop {
1347 if !IS_ALPHA!((*parser).buffer) {
1348 current_block = 2868539653012386629;
1349 break;
1350 }
1351 READ!(parser, string);
1352 if CACHE(parser, 1_u64).fail {
1353 current_block = 5883759901342942623;
1354 break;
1355 }
1356 length += 1;
1357 }
1358 if current_block != 5883759901342942623 {
1359 end_mark = (*parser).mark;
1360 if length == 0
1361 || !(IS_BLANKZ!((*parser).buffer)
1362 || CHECK!((*parser).buffer, b'?')
1363 || CHECK!((*parser).buffer, b':')
1364 || CHECK!((*parser).buffer, b',')
1365 || CHECK!((*parser).buffer, b']')
1366 || CHECK!((*parser).buffer, b'}')
1367 || CHECK!((*parser).buffer, b'%')
1368 || CHECK!((*parser).buffer, b'@')
1369 || CHECK!((*parser).buffer, b'`'))
1370 {
1371 yaml_parser_set_scanner_error(
1372 parser,
1373 if type_ == YAML_ANCHOR_TOKEN {
1374 b"while scanning an anchor\0" as *const u8 as *const libc::c_char
1375 } else {
1376 b"while scanning an alias\0" as *const u8 as *const libc::c_char
1377 },
1378 start_mark,
1379 b"did not find expected alphabetic or numeric character\0" as *const u8
1380 as *const libc::c_char,
1381 );
1382 } else {
1383 if type_ == YAML_ANCHOR_TOKEN {
1384 memset(
1385 token as *mut libc::c_void,
1386 0,
1387 size_of::<yaml_token_t>() as libc::c_ulong,
1388 );
1389 (*token).type_ = YAML_ANCHOR_TOKEN;
1390 (*token).start_mark = start_mark;
1391 (*token).end_mark = end_mark;
1392 let fresh220 = addr_of_mut!((*token).data.anchor.value);
1393 *fresh220 = string.start;
1394 } else {
1395 memset(
1396 token as *mut libc::c_void,
1397 0,
1398 size_of::<yaml_token_t>() as libc::c_ulong,
1399 );
1400 (*token).type_ = YAML_ALIAS_TOKEN;
1401 (*token).start_mark = start_mark;
1402 (*token).end_mark = end_mark;
1403 let fresh221 = addr_of_mut!((*token).data.alias.value);
1404 *fresh221 = string.start;
1405 }
1406 return OK;
1407 }
1408 }
1409 }
1410 STRING_DEL!(string);
1411 FAIL
1412}
1413
1414unsafe fn yaml_parser_scan_tag(parser: *mut yaml_parser_t, token: *mut yaml_token_t) -> Success {
1415 let mut current_block: u64;
1416 let mut handle: *mut yaml_char_t = ptr::null_mut::<yaml_char_t>();
1417 let mut suffix: *mut yaml_char_t = ptr::null_mut::<yaml_char_t>();
1418 let end_mark: yaml_mark_t;
1419 let start_mark: yaml_mark_t = (*parser).mark;
1420 if CACHE(parser, 2_u64).ok {
1421 if CHECK_AT!((*parser).buffer, b'<', 1) {
1422 handle = yaml_malloc(1_u64) as *mut yaml_char_t;
1423 *handle = b'\0';
1424 SKIP(parser);
1425 SKIP(parser);
1426 if yaml_parser_scan_tag_uri(
1427 parser,
1428 true,
1429 false,
1430 ptr::null_mut::<yaml_char_t>(),
1431 start_mark,
1432 addr_of_mut!(suffix),
1433 )
1434 .fail
1435 {
1436 current_block = 17708497480799081542;
1437 } else if !CHECK!((*parser).buffer, b'>') {
1438 yaml_parser_set_scanner_error(
1439 parser,
1440 b"while scanning a tag\0" as *const u8 as *const libc::c_char,
1441 start_mark,
1442 b"did not find the expected '>'\0" as *const u8 as *const libc::c_char,
1443 );
1444 current_block = 17708497480799081542;
1445 } else {
1446 SKIP(parser);
1447 current_block = 4488286894823169796;
1448 }
1449 } else if yaml_parser_scan_tag_handle(parser, false, start_mark, addr_of_mut!(handle)).fail
1450 {
1451 current_block = 17708497480799081542;
1452 } else if *handle == b'!'
1453 && *handle.wrapping_offset(1_isize) != b'\0'
1454 && *handle
1455 .wrapping_offset(strlen(handle as *mut libc::c_char).wrapping_sub(1_u64) as isize)
1456 == b'!'
1457 {
1458 if yaml_parser_scan_tag_uri(
1459 parser,
1460 false,
1461 false,
1462 ptr::null_mut::<yaml_char_t>(),
1463 start_mark,
1464 addr_of_mut!(suffix),
1465 )
1466 .fail
1467 {
1468 current_block = 17708497480799081542;
1469 } else {
1470 current_block = 4488286894823169796;
1471 }
1472 } else if yaml_parser_scan_tag_uri(
1473 parser,
1474 false,
1475 false,
1476 handle,
1477 start_mark,
1478 addr_of_mut!(suffix),
1479 )
1480 .fail
1481 {
1482 current_block = 17708497480799081542;
1483 } else {
1484 yaml_free(handle as *mut libc::c_void);
1485 handle = yaml_malloc(2_u64) as *mut yaml_char_t;
1486 *handle = b'!';
1487 *handle.wrapping_offset(1_isize) = b'\0';
1488 if *suffix == b'\0' {
1489 let tmp: *mut yaml_char_t = handle;
1490 handle = suffix;
1491 suffix = tmp;
1492 }
1493 current_block = 4488286894823169796;
1494 }
1495 if current_block != 17708497480799081542 {
1496 if CACHE(parser, 1_u64).ok {
1497 if !IS_BLANKZ!((*parser).buffer) {
1498 if (*parser).flow_level == 0 || !CHECK!((*parser).buffer, b',') {
1499 yaml_parser_set_scanner_error(
1500 parser,
1501 b"while scanning a tag\0" as *const u8 as *const libc::c_char,
1502 start_mark,
1503 b"did not find expected whitespace or line break\0" as *const u8
1504 as *const libc::c_char,
1505 );
1506 current_block = 17708497480799081542;
1507 } else {
1508 current_block = 7333393191927787629;
1509 }
1510 } else {
1511 current_block = 7333393191927787629;
1512 }
1513 if current_block != 17708497480799081542 {
1514 end_mark = (*parser).mark;
1515 memset(
1516 token as *mut libc::c_void,
1517 0,
1518 size_of::<yaml_token_t>() as libc::c_ulong,
1519 );
1520 (*token).type_ = YAML_TAG_TOKEN;
1521 (*token).start_mark = start_mark;
1522 (*token).end_mark = end_mark;
1523 let fresh234 = addr_of_mut!((*token).data.tag.handle);
1524 *fresh234 = handle;
1525 let fresh235 = addr_of_mut!((*token).data.tag.suffix);
1526 *fresh235 = suffix;
1527 return OK;
1528 }
1529 }
1530 }
1531 }
1532 yaml_free(handle as *mut libc::c_void);
1533 yaml_free(suffix as *mut libc::c_void);
1534 FAIL
1535}
1536
1537unsafe fn yaml_parser_scan_tag_handle(
1538 parser: *mut yaml_parser_t,
1539 directive: bool,
1540 start_mark: yaml_mark_t,
1541 handle: *mut *mut yaml_char_t,
1542) -> Success {
1543 let mut current_block: u64;
1544 let mut string = NULL_STRING;
1545 STRING_INIT!(string);
1546 if CACHE(parser, 1_u64).ok {
1547 if !CHECK!((*parser).buffer, b'!') {
1548 yaml_parser_set_scanner_error(
1549 parser,
1550 if directive {
1551 b"while scanning a tag directive\0" as *const u8 as *const libc::c_char
1552 } else {
1553 b"while scanning a tag\0" as *const u8 as *const libc::c_char
1554 },
1555 start_mark,
1556 b"did not find expected '!'\0" as *const u8 as *const libc::c_char,
1557 );
1558 } else {
1559 READ!(parser, string);
1560 if CACHE(parser, 1_u64).ok {
1561 loop {
1562 if !IS_ALPHA!((*parser).buffer) {
1563 current_block = 7651349459974463963;
1564 break;
1565 }
1566 READ!(parser, string);
1567 if CACHE(parser, 1_u64).fail {
1568 current_block = 1771849829115608806;
1569 break;
1570 }
1571 }
1572 if current_block != 1771849829115608806 {
1573 if CHECK!((*parser).buffer, b'!') {
1574 READ!(parser, string);
1575 current_block = 5689001924483802034;
1576 } else if directive
1577 && !(*string.start == b'!'
1578 && *string.start.wrapping_offset(1_isize) == b'\0')
1579 {
1580 yaml_parser_set_scanner_error(
1581 parser,
1582 b"while parsing a tag directive\0" as *const u8 as *const libc::c_char,
1583 start_mark,
1584 b"did not find expected '!'\0" as *const u8 as *const libc::c_char,
1585 );
1586 current_block = 1771849829115608806;
1587 } else {
1588 current_block = 5689001924483802034;
1589 }
1590 if current_block != 1771849829115608806 {
1591 *handle = string.start;
1592 return OK;
1593 }
1594 }
1595 }
1596 }
1597 }
1598 STRING_DEL!(string);
1599 FAIL
1600}
1601
1602unsafe fn yaml_parser_scan_tag_uri(
1603 parser: *mut yaml_parser_t,
1604 uri_char: bool,
1605 directive: bool,
1606 head: *mut yaml_char_t,
1607 start_mark: yaml_mark_t,
1608 uri: *mut *mut yaml_char_t,
1609) -> Success {
1610 let mut current_block: u64;
1611 let mut length: size_t = if !head.is_null() {
1612 strlen(head as *mut libc::c_char)
1613 } else {
1614 0_u64
1615 };
1616 let mut string = NULL_STRING;
1617 STRING_INIT!(string);
1618 current_block = 14916268686031723178;
1619 'c_21953: loop {
1620 match current_block {
1621 15265153392498847348 => {
1622 STRING_DEL!(string);
1623 return FAIL;
1624 }
1625 _ => {
1626 if string.end.c_offset_from(string.start) as size_t <= length {
1627 yaml_string_extend(
1628 addr_of_mut!(string.start),
1629 addr_of_mut!(string.pointer),
1630 addr_of_mut!(string.end),
1631 );
1632 current_block = 14916268686031723178;
1633 continue;
1634 } else {
1635 if length > 1_u64 {
1636 memcpy(
1637 string.start as *mut libc::c_void,
1638 head.wrapping_offset(1_isize) as *const libc::c_void,
1639 length.wrapping_sub(1_u64),
1640 );
1641 string.pointer = string
1642 .pointer
1643 .wrapping_offset(length.wrapping_sub(1_u64) as isize);
1644 }
1645 if CACHE(parser, 1_u64).fail {
1646 current_block = 15265153392498847348;
1647 continue;
1648 }
1649 while IS_ALPHA!((*parser).buffer)
1650 || CHECK!((*parser).buffer, b';')
1651 || CHECK!((*parser).buffer, b'/')
1652 || CHECK!((*parser).buffer, b'?')
1653 || CHECK!((*parser).buffer, b':')
1654 || CHECK!((*parser).buffer, b'@')
1655 || CHECK!((*parser).buffer, b'&')
1656 || CHECK!((*parser).buffer, b'=')
1657 || CHECK!((*parser).buffer, b'+')
1658 || CHECK!((*parser).buffer, b'$')
1659 || CHECK!((*parser).buffer, b'.')
1660 || CHECK!((*parser).buffer, b'%')
1661 || CHECK!((*parser).buffer, b'!')
1662 || CHECK!((*parser).buffer, b'~')
1663 || CHECK!((*parser).buffer, b'*')
1664 || CHECK!((*parser).buffer, b'\'')
1665 || CHECK!((*parser).buffer, b'(')
1666 || CHECK!((*parser).buffer, b')')
1667 || uri_char
1668 && (CHECK!((*parser).buffer, b',')
1669 || CHECK!((*parser).buffer, b'[')
1670 || CHECK!((*parser).buffer, b']'))
1671 {
1672 if CHECK!((*parser).buffer, b'%') {
1673 STRING_EXTEND!(string);
1674 if yaml_parser_scan_uri_escapes(
1675 parser,
1676 directive,
1677 start_mark,
1678 addr_of_mut!(string),
1679 )
1680 .fail
1681 {
1682 current_block = 15265153392498847348;
1683 continue 'c_21953;
1684 }
1685 } else {
1686 READ!(parser, string);
1687 }
1688 length = length.force_add(1);
1689 if CACHE(parser, 1_u64).fail {
1690 current_block = 15265153392498847348;
1691 continue 'c_21953;
1692 }
1693 }
1694 if length == 0 {
1695 STRING_EXTEND!(string);
1696 yaml_parser_set_scanner_error(
1697 parser,
1698 if directive {
1699 b"while parsing a %TAG directive\0" as *const u8
1700 as *const libc::c_char
1701 } else {
1702 b"while parsing a tag\0" as *const u8 as *const libc::c_char
1703 },
1704 start_mark,
1705 b"did not find expected tag URI\0" as *const u8 as *const libc::c_char,
1706 );
1707 current_block = 15265153392498847348;
1708 } else {
1709 *uri = string.start;
1710 return OK;
1711 }
1712 }
1713 }
1714 }
1715 }
1716}
1717
1718unsafe fn yaml_parser_scan_uri_escapes(
1719 parser: *mut yaml_parser_t,
1720 directive: bool,
1721 start_mark: yaml_mark_t,
1722 string: *mut yaml_string_t,
1723) -> Success {
1724 let mut width: libc::c_int = 0;
1725 loop {
1726 if CACHE(parser, 3_u64).fail {
1727 return FAIL;
1728 }
1729 if !(CHECK!((*parser).buffer, b'%')
1730 && IS_HEX_AT!((*parser).buffer, 1)
1731 && IS_HEX_AT!((*parser).buffer, 2))
1732 {
1733 yaml_parser_set_scanner_error(
1734 parser,
1735 if directive {
1736 b"while parsing a %TAG directive\0" as *const u8 as *const libc::c_char
1737 } else {
1738 b"while parsing a tag\0" as *const u8 as *const libc::c_char
1739 },
1740 start_mark,
1741 b"did not find URI escaped octet\0" as *const u8 as *const libc::c_char,
1742 );
1743 return FAIL;
1744 }
1745 let octet: libc::c_uchar = ((AS_HEX_AT!((*parser).buffer, 1) << 4)
1746 + AS_HEX_AT!((*parser).buffer, 2)) as libc::c_uchar;
1747 if width == 0 {
1748 width = if octet & 0x80 == 0 {
1749 1
1750 } else if octet & 0xE0 == 0xC0 {
1751 2
1752 } else if octet & 0xF0 == 0xE0 {
1753 3
1754 } else if octet & 0xF8 == 0xF0 {
1755 4
1756 } else {
1757 0
1758 };
1759 if width == 0 {
1760 yaml_parser_set_scanner_error(
1761 parser,
1762 if directive {
1763 b"while parsing a %TAG directive\0" as *const u8 as *const libc::c_char
1764 } else {
1765 b"while parsing a tag\0" as *const u8 as *const libc::c_char
1766 },
1767 start_mark,
1768 b"found an incorrect leading UTF-8 octet\0" as *const u8 as *const libc::c_char,
1769 );
1770 return FAIL;
1771 }
1772 } else if octet & 0xC0 != 0x80 {
1773 yaml_parser_set_scanner_error(
1774 parser,
1775 if directive {
1776 b"while parsing a %TAG directive\0" as *const u8 as *const libc::c_char
1777 } else {
1778 b"while parsing a tag\0" as *const u8 as *const libc::c_char
1779 },
1780 start_mark,
1781 b"found an incorrect trailing UTF-8 octet\0" as *const u8 as *const libc::c_char,
1782 );
1783 return FAIL;
1784 }
1785 let fresh368 = addr_of_mut!((*string).pointer);
1786 let fresh369 = *fresh368;
1787 *fresh368 = (*fresh368).wrapping_offset(1);
1788 *fresh369 = octet;
1789 SKIP(parser);
1790 SKIP(parser);
1791 SKIP(parser);
1792 width -= 1;
1793 if !(width != 0) {
1794 break;
1795 }
1796 }
1797 OK
1798}
1799
1800unsafe fn yaml_parser_scan_block_scalar(
1801 parser: *mut yaml_parser_t,
1802 token: *mut yaml_token_t,
1803 literal: bool,
1804) -> Success {
1805 let mut current_block: u64;
1806 let mut end_mark: yaml_mark_t;
1807 let mut string = NULL_STRING;
1808 let mut leading_break = NULL_STRING;
1809 let mut trailing_breaks = NULL_STRING;
1810 let mut chomping: libc::c_int = 0;
1811 let mut increment: libc::c_int = 0;
1812 let mut indent: libc::c_int = 0;
1813 let mut leading_blank: libc::c_int = 0;
1814 let mut trailing_blank: libc::c_int;
1815 STRING_INIT!(string);
1816 STRING_INIT!(leading_break);
1817 STRING_INIT!(trailing_breaks);
1818 let start_mark: yaml_mark_t = (*parser).mark;
1819 SKIP(parser);
1820 if CACHE(parser, 1_u64).ok {
1821 if CHECK!((*parser).buffer, b'+') || CHECK!((*parser).buffer, b'-') {
1822 chomping = if CHECK!((*parser).buffer, b'+') {
1823 1
1824 } else {
1825 -1
1826 };
1827 SKIP(parser);
1828 if CACHE(parser, 1_u64).fail {
1829 current_block = 14984465786483313892;
1830 } else if IS_DIGIT!((*parser).buffer) {
1831 if CHECK!((*parser).buffer, b'0') {
1832 yaml_parser_set_scanner_error(
1833 parser,
1834 b"while scanning a block scalar\0" as *const u8 as *const libc::c_char,
1835 start_mark,
1836 b"found an indentation indicator equal to 0\0" as *const u8
1837 as *const libc::c_char,
1838 );
1839 current_block = 14984465786483313892;
1840 } else {
1841 increment = AS_DIGIT!((*parser).buffer);
1842 SKIP(parser);
1843 current_block = 11913429853522160501;
1844 }
1845 } else {
1846 current_block = 11913429853522160501;
1847 }
1848 } else if IS_DIGIT!((*parser).buffer) {
1849 if CHECK!((*parser).buffer, b'0') {
1850 yaml_parser_set_scanner_error(
1851 parser,
1852 b"while scanning a block scalar\0" as *const u8 as *const libc::c_char,
1853 start_mark,
1854 b"found an indentation indicator equal to 0\0" as *const u8
1855 as *const libc::c_char,
1856 );
1857 current_block = 14984465786483313892;
1858 } else {
1859 increment = AS_DIGIT!((*parser).buffer);
1860 SKIP(parser);
1861 if CACHE(parser, 1_u64).fail {
1862 current_block = 14984465786483313892;
1863 } else {
1864 if CHECK!((*parser).buffer, b'+') || CHECK!((*parser).buffer, b'-') {
1865 chomping = if CHECK!((*parser).buffer, b'+') {
1866 1
1867 } else {
1868 -1
1869 };
1870 SKIP(parser);
1871 }
1872 current_block = 11913429853522160501;
1873 }
1874 }
1875 } else {
1876 current_block = 11913429853522160501;
1877 }
1878 if current_block != 14984465786483313892 {
1879 if CACHE(parser, 1_u64).ok {
1880 loop {
1881 if !IS_BLANK!((*parser).buffer) {
1882 current_block = 4090602189656566074;
1883 break;
1884 }
1885 SKIP(parser);
1886 if CACHE(parser, 1_u64).fail {
1887 current_block = 14984465786483313892;
1888 break;
1889 }
1890 }
1891 if current_block != 14984465786483313892 {
1892 if CHECK!((*parser).buffer, b'#') {
1893 loop {
1894 if IS_BREAKZ!((*parser).buffer) {
1895 current_block = 12997042908615822766;
1896 break;
1897 }
1898 SKIP(parser);
1899 if CACHE(parser, 1_u64).fail {
1900 current_block = 14984465786483313892;
1901 break;
1902 }
1903 }
1904 } else {
1905 current_block = 12997042908615822766;
1906 }
1907 if current_block != 14984465786483313892 {
1908 if !IS_BREAKZ!((*parser).buffer) {
1909 yaml_parser_set_scanner_error(
1910 parser,
1911 b"while scanning a block scalar\0" as *const u8
1912 as *const libc::c_char,
1913 start_mark,
1914 b"did not find expected comment or line break\0" as *const u8
1915 as *const libc::c_char,
1916 );
1917 } else {
1918 if IS_BREAK!((*parser).buffer) {
1919 if CACHE(parser, 2_u64).fail {
1920 current_block = 14984465786483313892;
1921 } else {
1922 SKIP_LINE(parser);
1923 current_block = 13619784596304402172;
1924 }
1925 } else {
1926 current_block = 13619784596304402172;
1927 }
1928 if current_block != 14984465786483313892 {
1929 end_mark = (*parser).mark;
1930 if increment != 0 {
1931 indent = if (*parser).indent >= 0 {
1932 (*parser).indent + increment
1933 } else {
1934 increment
1935 };
1936 }
1937 if yaml_parser_scan_block_scalar_breaks(
1938 parser,
1939 addr_of_mut!(indent),
1940 addr_of_mut!(trailing_breaks),
1941 start_mark,
1942 addr_of_mut!(end_mark),
1943 )
1944 .ok
1945 {
1946 if CACHE(parser, 1_u64).ok {
1947 's_281: loop {
1948 if !((*parser).mark.column as libc::c_int == indent
1949 && !IS_Z!((*parser).buffer))
1950 {
1951 current_block = 5793491756164225964;
1952 break;
1953 }
1954 trailing_blank =
1955 IS_BLANK!((*parser).buffer) as libc::c_int;
1956 if !literal
1957 && *leading_break.start == b'\n'
1958 && leading_blank == 0
1959 && trailing_blank == 0
1960 {
1961 if *trailing_breaks.start == b'\0' {
1962 STRING_EXTEND!(string);
1963 let fresh418 = string.pointer;
1964 string.pointer =
1965 string.pointer.wrapping_offset(1);
1966 *fresh418 = b' ';
1967 }
1968 CLEAR!(leading_break);
1969 } else {
1970 JOIN!(string, leading_break);
1971 CLEAR!(leading_break);
1972 }
1973 JOIN!(string, trailing_breaks);
1974 CLEAR!(trailing_breaks);
1975 leading_blank =
1976 IS_BLANK!((*parser).buffer) as libc::c_int;
1977 while !IS_BREAKZ!((*parser).buffer) {
1978 READ!(parser, string);
1979 if CACHE(parser, 1_u64).fail {
1980 current_block = 14984465786483313892;
1981 break 's_281;
1982 }
1983 }
1984 if CACHE(parser, 2_u64).fail {
1985 current_block = 14984465786483313892;
1986 break;
1987 }
1988 READ_LINE!(parser, leading_break);
1989 if yaml_parser_scan_block_scalar_breaks(
1990 parser,
1991 addr_of_mut!(indent),
1992 addr_of_mut!(trailing_breaks),
1993 start_mark,
1994 addr_of_mut!(end_mark),
1995 )
1996 .fail
1997 {
1998 current_block = 14984465786483313892;
1999 break;
2000 }
2001 }
2002 if current_block != 14984465786483313892 {
2003 if chomping != -1 {
2004 JOIN!(string, leading_break);
2005 current_block = 17787701279558130514;
2006 } else {
2007 current_block = 17787701279558130514;
2008 }
2009 if current_block != 14984465786483313892 {
2010 if chomping == 1 {
2011 JOIN!(string, trailing_breaks);
2012 }
2013 memset(
2014 token as *mut libc::c_void,
2015 0,
2016 size_of::<yaml_token_t>() as libc::c_ulong,
2017 );
2018 (*token).type_ = YAML_SCALAR_TOKEN;
2019 (*token).start_mark = start_mark;
2020 (*token).end_mark = end_mark;
2021 let fresh479 =
2022 addr_of_mut!((*token).data.scalar.value);
2023 *fresh479 = string.start;
2024 (*token).data.scalar.length =
2025 string.pointer.c_offset_from(string.start)
2026 as size_t;
2027 (*token).data.scalar.style = if literal {
2028 YAML_LITERAL_SCALAR_STYLE
2029 } else {
2030 YAML_FOLDED_SCALAR_STYLE
2031 };
2032 STRING_DEL!(leading_break);
2033 STRING_DEL!(trailing_breaks);
2034 return OK;
2035 }
2036 }
2037 }
2038 }
2039 }
2040 }
2041 }
2042 }
2043 }
2044 }
2045 }
2046 STRING_DEL!(string);
2047 STRING_DEL!(leading_break);
2048 STRING_DEL!(trailing_breaks);
2049 FAIL
2050}
2051
2052unsafe fn yaml_parser_scan_block_scalar_breaks(
2053 parser: *mut yaml_parser_t,
2054 indent: *mut libc::c_int,
2055 breaks: *mut yaml_string_t,
2056 start_mark: yaml_mark_t,
2057 end_mark: *mut yaml_mark_t,
2058) -> Success {
2059 let mut max_indent: libc::c_int = 0;
2060 *end_mark = (*parser).mark;
2061 loop {
2062 if CACHE(parser, 1_u64).fail {
2063 return FAIL;
2064 }
2065 while (*indent == 0 || ((*parser).mark.column as libc::c_int) < *indent)
2066 && IS_SPACE!((*parser).buffer)
2067 {
2068 SKIP(parser);
2069 if CACHE(parser, 1_u64).fail {
2070 return FAIL;
2071 }
2072 }
2073 if (*parser).mark.column as libc::c_int > max_indent {
2074 max_indent = (*parser).mark.column as libc::c_int;
2075 }
2076 if (*indent == 0 || ((*parser).mark.column as libc::c_int) < *indent)
2077 && IS_TAB!((*parser).buffer)
2078 {
2079 yaml_parser_set_scanner_error(
2080 parser,
2081 b"while scanning a block scalar\0" as *const u8 as *const libc::c_char,
2082 start_mark,
2083 b"found a tab character where an indentation space is expected\0" as *const u8
2084 as *const libc::c_char,
2085 );
2086 return FAIL;
2087 }
2088 if !IS_BREAK!((*parser).buffer) {
2089 break;
2090 }
2091 if CACHE(parser, 2_u64).fail {
2092 return FAIL;
2093 }
2094 READ_LINE!(parser, *breaks);
2095 *end_mark = (*parser).mark;
2096 }
2097 if *indent == 0 {
2098 *indent = max_indent;
2099 if *indent < (*parser).indent + 1 {
2100 *indent = (*parser).indent + 1;
2101 }
2102 if *indent < 1 {
2103 *indent = 1;
2104 }
2105 }
2106 OK
2107}
2108
2109unsafe fn yaml_parser_scan_flow_scalar(
2110 parser: *mut yaml_parser_t,
2111 token: *mut yaml_token_t,
2112 single: bool,
2113) -> Success {
2114 let current_block: u64;
2115 let end_mark: yaml_mark_t;
2116 let mut string = NULL_STRING;
2117 let mut leading_break = NULL_STRING;
2118 let mut trailing_breaks = NULL_STRING;
2119 let mut whitespaces = NULL_STRING;
2120 let mut leading_blanks;
2121 STRING_INIT!(string);
2122 STRING_INIT!(leading_break);
2123 STRING_INIT!(trailing_breaks);
2124 STRING_INIT!(whitespaces);
2125 let start_mark: yaml_mark_t = (*parser).mark;
2126 SKIP(parser);
2127 's_58: loop {
2128 if CACHE(parser, 4_u64).fail {
2129 current_block = 8114179180390253173;
2130 break;
2131 }
2132 if (*parser).mark.column == 0_u64
2133 && (CHECK_AT!((*parser).buffer, b'-', 0)
2134 && CHECK_AT!((*parser).buffer, b'-', 1)
2135 && CHECK_AT!((*parser).buffer, b'-', 2)
2136 || CHECK_AT!((*parser).buffer, b'.', 0)
2137 && CHECK_AT!((*parser).buffer, b'.', 1)
2138 && CHECK_AT!((*parser).buffer, b'.', 2))
2139 && IS_BLANKZ_AT!((*parser).buffer, 3)
2140 {
2141 yaml_parser_set_scanner_error(
2142 parser,
2143 b"while scanning a quoted scalar\0" as *const u8 as *const libc::c_char,
2144 start_mark,
2145 b"found unexpected document indicator\0" as *const u8 as *const libc::c_char,
2146 );
2147 current_block = 8114179180390253173;
2148 break;
2149 } else if IS_Z!((*parser).buffer) {
2150 yaml_parser_set_scanner_error(
2151 parser,
2152 b"while scanning a quoted scalar\0" as *const u8 as *const libc::c_char,
2153 start_mark,
2154 b"found unexpected end of stream\0" as *const u8 as *const libc::c_char,
2155 );
2156 current_block = 8114179180390253173;
2157 break;
2158 } else {
2159 if CACHE(parser, 2_u64).fail {
2160 current_block = 8114179180390253173;
2161 break;
2162 }
2163 leading_blanks = false;
2164 while !IS_BLANKZ!((*parser).buffer) {
2165 if single
2166 && CHECK_AT!((*parser).buffer, b'\'', 0)
2167 && CHECK_AT!((*parser).buffer, b'\'', 1)
2168 {
2169 STRING_EXTEND!(string);
2170 let fresh521 = string.pointer;
2171 string.pointer = string.pointer.wrapping_offset(1);
2172 *fresh521 = b'\'';
2173 SKIP(parser);
2174 SKIP(parser);
2175 } else {
2176 if CHECK!((*parser).buffer, if single { b'\'' } else { b'"' }) {
2177 break;
2178 }
2179 if !single
2180 && CHECK!((*parser).buffer, b'\\')
2181 && IS_BREAK_AT!((*parser).buffer, 1)
2182 {
2183 if CACHE(parser, 3_u64).fail {
2184 current_block = 8114179180390253173;
2185 break 's_58;
2186 }
2187 SKIP(parser);
2188 SKIP_LINE(parser);
2189 leading_blanks = true;
2190 break;
2191 } else if !single && CHECK!((*parser).buffer, b'\\') {
2192 let mut code_length: size_t = 0_u64;
2193 STRING_EXTEND!(string);
2194 match *(*parser).buffer.pointer.wrapping_offset(1_isize) {
2195 b'0' => {
2196 let fresh542 = string.pointer;
2197 string.pointer = string.pointer.wrapping_offset(1);
2198 *fresh542 = b'\0';
2199 }
2200 b'a' => {
2201 let fresh543 = string.pointer;
2202 string.pointer = string.pointer.wrapping_offset(1);
2203 *fresh543 = b'\x07';
2204 }
2205 b'b' => {
2206 let fresh544 = string.pointer;
2207 string.pointer = string.pointer.wrapping_offset(1);
2208 *fresh544 = b'\x08';
2209 }
2210 b't' | b'\t' => {
2211 let fresh545 = string.pointer;
2212 string.pointer = string.pointer.wrapping_offset(1);
2213 *fresh545 = b'\t';
2214 }
2215 b'n' => {
2216 let fresh546 = string.pointer;
2217 string.pointer = string.pointer.wrapping_offset(1);
2218 *fresh546 = b'\n';
2219 }
2220 b'v' => {
2221 let fresh547 = string.pointer;
2222 string.pointer = string.pointer.wrapping_offset(1);
2223 *fresh547 = b'\x0B';
2224 }
2225 b'f' => {
2226 let fresh548 = string.pointer;
2227 string.pointer = string.pointer.wrapping_offset(1);
2228 *fresh548 = b'\x0C';
2229 }
2230 b'r' => {
2231 let fresh549 = string.pointer;
2232 string.pointer = string.pointer.wrapping_offset(1);
2233 *fresh549 = b'\r';
2234 }
2235 b'e' => {
2236 let fresh550 = string.pointer;
2237 string.pointer = string.pointer.wrapping_offset(1);
2238 *fresh550 = b'\x1B';
2239 }
2240 b' ' => {
2241 let fresh551 = string.pointer;
2242 string.pointer = string.pointer.wrapping_offset(1);
2243 *fresh551 = b' ';
2244 }
2245 b'"' => {
2246 let fresh552 = string.pointer;
2247 string.pointer = string.pointer.wrapping_offset(1);
2248 *fresh552 = b'"';
2249 }
2250 b'/' => {
2251 let fresh553 = string.pointer;
2252 string.pointer = string.pointer.wrapping_offset(1);
2253 *fresh553 = b'/';
2254 }
2255 b'\\' => {
2256 let fresh554 = string.pointer;
2257 string.pointer = string.pointer.wrapping_offset(1);
2258 *fresh554 = b'\\';
2259 }
2260 b'N' => {
2262 let fresh555 = string.pointer;
2263 string.pointer = string.pointer.wrapping_offset(1);
2264 *fresh555 = b'\xC2';
2265 let fresh556 = string.pointer;
2266 string.pointer = string.pointer.wrapping_offset(1);
2267 *fresh556 = b'\x85';
2268 }
2269 b'_' => {
2271 let fresh557 = string.pointer;
2272 string.pointer = string.pointer.wrapping_offset(1);
2273 *fresh557 = b'\xC2';
2274 let fresh558 = string.pointer;
2275 string.pointer = string.pointer.wrapping_offset(1);
2276 *fresh558 = b'\xA0';
2277 }
2278 b'L' => {
2280 let fresh559 = string.pointer;
2281 string.pointer = string.pointer.wrapping_offset(1);
2282 *fresh559 = b'\xE2';
2283 let fresh560 = string.pointer;
2284 string.pointer = string.pointer.wrapping_offset(1);
2285 *fresh560 = b'\x80';
2286 let fresh561 = string.pointer;
2287 string.pointer = string.pointer.wrapping_offset(1);
2288 *fresh561 = b'\xA8';
2289 }
2290 b'P' => {
2292 let fresh562 = string.pointer;
2293 string.pointer = string.pointer.wrapping_offset(1);
2294 *fresh562 = b'\xE2';
2295 let fresh563 = string.pointer;
2296 string.pointer = string.pointer.wrapping_offset(1);
2297 *fresh563 = b'\x80';
2298 let fresh564 = string.pointer;
2299 string.pointer = string.pointer.wrapping_offset(1);
2300 *fresh564 = b'\xA9';
2301 }
2302 b'x' => {
2303 code_length = 2_u64;
2304 }
2305 b'u' => {
2306 code_length = 4_u64;
2307 }
2308 b'U' => {
2309 code_length = 8_u64;
2310 }
2311 _ => {
2312 yaml_parser_set_scanner_error(
2313 parser,
2314 b"while parsing a quoted scalar\0" as *const u8
2315 as *const libc::c_char,
2316 start_mark,
2317 b"found unknown escape character\0" as *const u8
2318 as *const libc::c_char,
2319 );
2320 current_block = 8114179180390253173;
2321 break 's_58;
2322 }
2323 }
2324 SKIP(parser);
2325 SKIP(parser);
2326 if code_length != 0 {
2327 let mut value: libc::c_uint = 0;
2328 let mut k: size_t;
2329 if CACHE(parser, code_length).fail {
2330 current_block = 8114179180390253173;
2331 break 's_58;
2332 }
2333 k = 0_u64;
2334 while k < code_length {
2335 if !IS_HEX_AT!((*parser).buffer, k as isize) {
2336 yaml_parser_set_scanner_error(
2337 parser,
2338 b"while parsing a quoted scalar\0" as *const u8
2339 as *const libc::c_char,
2340 start_mark,
2341 b"did not find expected hexadecimal number\0" as *const u8
2342 as *const libc::c_char,
2343 );
2344 current_block = 8114179180390253173;
2345 break 's_58;
2346 } else {
2347 value = (value << 4).force_add(AS_HEX_AT!(
2348 (*parser).buffer,
2349 k as isize
2350 )
2351 as libc::c_uint);
2352 k = k.force_add(1);
2353 }
2354 }
2355 if value >= 0xD800 && value <= 0xDFFF || value > 0x10FFFF {
2356 yaml_parser_set_scanner_error(
2357 parser,
2358 b"while parsing a quoted scalar\0" as *const u8
2359 as *const libc::c_char,
2360 start_mark,
2361 b"found invalid Unicode character escape code\0" as *const u8
2362 as *const libc::c_char,
2363 );
2364 current_block = 8114179180390253173;
2365 break 's_58;
2366 } else {
2367 if value <= 0x7F {
2368 let fresh573 = string.pointer;
2369 string.pointer = string.pointer.wrapping_offset(1);
2370 *fresh573 = value as yaml_char_t;
2371 } else if value <= 0x7FF {
2372 let fresh574 = string.pointer;
2373 string.pointer = string.pointer.wrapping_offset(1);
2374 *fresh574 = 0xC0_u32.force_add(value >> 6) as yaml_char_t;
2375 let fresh575 = string.pointer;
2376 string.pointer = string.pointer.wrapping_offset(1);
2377 *fresh575 = 0x80_u32.force_add(value & 0x3F) as yaml_char_t;
2378 } else if value <= 0xFFFF {
2379 let fresh576 = string.pointer;
2380 string.pointer = string.pointer.wrapping_offset(1);
2381 *fresh576 = 0xE0_u32.force_add(value >> 12) as yaml_char_t;
2382 let fresh577 = string.pointer;
2383 string.pointer = string.pointer.wrapping_offset(1);
2384 *fresh577 =
2385 0x80_u32.force_add(value >> 6 & 0x3F) as yaml_char_t;
2386 let fresh578 = string.pointer;
2387 string.pointer = string.pointer.wrapping_offset(1);
2388 *fresh578 = 0x80_u32.force_add(value & 0x3F) as yaml_char_t;
2389 } else {
2390 let fresh579 = string.pointer;
2391 string.pointer = string.pointer.wrapping_offset(1);
2392 *fresh579 = 0xF0_u32.force_add(value >> 18) as yaml_char_t;
2393 let fresh580 = string.pointer;
2394 string.pointer = string.pointer.wrapping_offset(1);
2395 *fresh580 =
2396 0x80_u32.force_add(value >> 12 & 0x3F) as yaml_char_t;
2397 let fresh581 = string.pointer;
2398 string.pointer = string.pointer.wrapping_offset(1);
2399 *fresh581 =
2400 0x80_u32.force_add(value >> 6 & 0x3F) as yaml_char_t;
2401 let fresh582 = string.pointer;
2402 string.pointer = string.pointer.wrapping_offset(1);
2403 *fresh582 = 0x80_u32.force_add(value & 0x3F) as yaml_char_t;
2404 }
2405 k = 0_u64;
2406 while k < code_length {
2407 SKIP(parser);
2408 k = k.force_add(1);
2409 }
2410 }
2411 }
2412 } else {
2413 READ!(parser, string);
2414 }
2415 }
2416 if CACHE(parser, 2_u64).fail {
2417 current_block = 8114179180390253173;
2418 break 's_58;
2419 }
2420 }
2421 if CACHE(parser, 1_u64).fail {
2422 current_block = 8114179180390253173;
2423 break;
2424 }
2425 if CHECK!((*parser).buffer, if single { b'\'' } else { b'"' }) {
2426 current_block = 7468767852762055642;
2427 break;
2428 }
2429 if CACHE(parser, 1_u64).fail {
2430 current_block = 8114179180390253173;
2431 break;
2432 }
2433 while IS_BLANK!((*parser).buffer) || IS_BREAK!((*parser).buffer) {
2434 if IS_BLANK!((*parser).buffer) {
2435 if !leading_blanks {
2436 READ!(parser, whitespaces);
2437 } else {
2438 SKIP(parser);
2439 }
2440 } else {
2441 if CACHE(parser, 2_u64).fail {
2442 current_block = 8114179180390253173;
2443 break 's_58;
2444 }
2445 if !leading_blanks {
2446 CLEAR!(whitespaces);
2447 READ_LINE!(parser, leading_break);
2448 leading_blanks = true;
2449 } else {
2450 READ_LINE!(parser, trailing_breaks);
2451 }
2452 }
2453 if CACHE(parser, 1_u64).fail {
2454 current_block = 8114179180390253173;
2455 break 's_58;
2456 }
2457 }
2458 if leading_blanks {
2459 if *leading_break.start == b'\n' {
2460 if *trailing_breaks.start == b'\0' {
2461 STRING_EXTEND!(string);
2462 let fresh711 = string.pointer;
2463 string.pointer = string.pointer.wrapping_offset(1);
2464 *fresh711 = b' ';
2465 } else {
2466 JOIN!(string, trailing_breaks);
2467 CLEAR!(trailing_breaks);
2468 }
2469 CLEAR!(leading_break);
2470 } else {
2471 JOIN!(string, leading_break);
2472 JOIN!(string, trailing_breaks);
2473 CLEAR!(leading_break);
2474 CLEAR!(trailing_breaks);
2475 }
2476 } else {
2477 JOIN!(string, whitespaces);
2478 CLEAR!(whitespaces);
2479 }
2480 }
2481 }
2482 if current_block != 8114179180390253173 {
2483 SKIP(parser);
2484 end_mark = (*parser).mark;
2485 memset(
2486 token as *mut libc::c_void,
2487 0,
2488 size_of::<yaml_token_t>() as libc::c_ulong,
2489 );
2490 (*token).type_ = YAML_SCALAR_TOKEN;
2491 (*token).start_mark = start_mark;
2492 (*token).end_mark = end_mark;
2493 let fresh716 = addr_of_mut!((*token).data.scalar.value);
2494 *fresh716 = string.start;
2495 (*token).data.scalar.length = string.pointer.c_offset_from(string.start) as size_t;
2496 (*token).data.scalar.style = if single {
2497 YAML_SINGLE_QUOTED_SCALAR_STYLE
2498 } else {
2499 YAML_DOUBLE_QUOTED_SCALAR_STYLE
2500 };
2501 STRING_DEL!(leading_break);
2502 STRING_DEL!(trailing_breaks);
2503 STRING_DEL!(whitespaces);
2504 return OK;
2505 }
2506 STRING_DEL!(string);
2507 STRING_DEL!(leading_break);
2508 STRING_DEL!(trailing_breaks);
2509 STRING_DEL!(whitespaces);
2510 FAIL
2511}
2512
2513unsafe fn yaml_parser_scan_plain_scalar(
2514 parser: *mut yaml_parser_t,
2515 token: *mut yaml_token_t,
2516) -> Success {
2517 let current_block: u64;
2518 let mut end_mark: yaml_mark_t;
2519 let mut string = NULL_STRING;
2520 let mut leading_break = NULL_STRING;
2521 let mut trailing_breaks = NULL_STRING;
2522 let mut whitespaces = NULL_STRING;
2523 let mut leading_blanks = false;
2524 let indent: libc::c_int = (*parser).indent + 1;
2525 STRING_INIT!(string);
2526 STRING_INIT!(leading_break);
2527 STRING_INIT!(trailing_breaks);
2528 STRING_INIT!(whitespaces);
2529 end_mark = (*parser).mark;
2530 let start_mark: yaml_mark_t = end_mark;
2531 's_57: loop {
2532 if CACHE(parser, 4_u64).fail {
2533 current_block = 16642808987012640029;
2534 break;
2535 }
2536 if (*parser).mark.column == 0_u64
2537 && (CHECK_AT!((*parser).buffer, b'-', 0)
2538 && CHECK_AT!((*parser).buffer, b'-', 1)
2539 && CHECK_AT!((*parser).buffer, b'-', 2)
2540 || CHECK_AT!((*parser).buffer, b'.', 0)
2541 && CHECK_AT!((*parser).buffer, b'.', 1)
2542 && CHECK_AT!((*parser).buffer, b'.', 2))
2543 && IS_BLANKZ_AT!((*parser).buffer, 3)
2544 {
2545 current_block = 6281126495347172768;
2546 break;
2547 }
2548 if CHECK!((*parser).buffer, b'#') {
2549 current_block = 6281126495347172768;
2550 break;
2551 }
2552 while !IS_BLANKZ!((*parser).buffer) {
2553 if (*parser).flow_level != 0
2554 && CHECK!((*parser).buffer, b':')
2555 && (CHECK_AT!((*parser).buffer, b',', 1)
2556 || CHECK_AT!((*parser).buffer, b'?', 1)
2557 || CHECK_AT!((*parser).buffer, b'[', 1)
2558 || CHECK_AT!((*parser).buffer, b']', 1)
2559 || CHECK_AT!((*parser).buffer, b'{', 1)
2560 || CHECK_AT!((*parser).buffer, b'}', 1))
2561 {
2562 yaml_parser_set_scanner_error(
2563 parser,
2564 b"while scanning a plain scalar\0" as *const u8 as *const libc::c_char,
2565 start_mark,
2566 b"found unexpected ':'\0" as *const u8 as *const libc::c_char,
2567 );
2568 current_block = 16642808987012640029;
2569 break 's_57;
2570 } else {
2571 if CHECK!((*parser).buffer, b':') && IS_BLANKZ_AT!((*parser).buffer, 1)
2572 || (*parser).flow_level != 0
2573 && (CHECK!((*parser).buffer, b',')
2574 || CHECK!((*parser).buffer, b'[')
2575 || CHECK!((*parser).buffer, b']')
2576 || CHECK!((*parser).buffer, b'{')
2577 || CHECK!((*parser).buffer, b'}'))
2578 {
2579 break;
2580 }
2581 if leading_blanks || whitespaces.start != whitespaces.pointer {
2582 if leading_blanks {
2583 if *leading_break.start == b'\n' {
2584 if *trailing_breaks.start == b'\0' {
2585 STRING_EXTEND!(string);
2586 let fresh717 = string.pointer;
2587 string.pointer = string.pointer.wrapping_offset(1);
2588 *fresh717 = b' ';
2589 } else {
2590 JOIN!(string, trailing_breaks);
2591 CLEAR!(trailing_breaks);
2592 }
2593 CLEAR!(leading_break);
2594 } else {
2595 JOIN!(string, leading_break);
2596 JOIN!(string, trailing_breaks);
2597 CLEAR!(leading_break);
2598 CLEAR!(trailing_breaks);
2599 }
2600 leading_blanks = false;
2601 } else {
2602 JOIN!(string, whitespaces);
2603 CLEAR!(whitespaces);
2604 }
2605 }
2606 READ!(parser, string);
2607 end_mark = (*parser).mark;
2608 if CACHE(parser, 2_u64).fail {
2609 current_block = 16642808987012640029;
2610 break 's_57;
2611 }
2612 }
2613 }
2614 if !(IS_BLANK!((*parser).buffer) || IS_BREAK!((*parser).buffer)) {
2615 current_block = 6281126495347172768;
2616 break;
2617 }
2618 if CACHE(parser, 1_u64).fail {
2619 current_block = 16642808987012640029;
2620 break;
2621 }
2622 while IS_BLANK!((*parser).buffer) || IS_BREAK!((*parser).buffer) {
2623 if IS_BLANK!((*parser).buffer) {
2624 if leading_blanks
2625 && ((*parser).mark.column as libc::c_int) < indent
2626 && IS_TAB!((*parser).buffer)
2627 {
2628 yaml_parser_set_scanner_error(
2629 parser,
2630 b"while scanning a plain scalar\0" as *const u8 as *const libc::c_char,
2631 start_mark,
2632 b"found a tab character that violates indentation\0" as *const u8
2633 as *const libc::c_char,
2634 );
2635 current_block = 16642808987012640029;
2636 break 's_57;
2637 } else if !leading_blanks {
2638 READ!(parser, whitespaces);
2639 } else {
2640 SKIP(parser);
2641 }
2642 } else {
2643 if CACHE(parser, 2_u64).fail {
2644 current_block = 16642808987012640029;
2645 break 's_57;
2646 }
2647 if !leading_blanks {
2648 CLEAR!(whitespaces);
2649 READ_LINE!(parser, leading_break);
2650 leading_blanks = true;
2651 } else {
2652 READ_LINE!(parser, trailing_breaks);
2653 }
2654 }
2655 if CACHE(parser, 1_u64).fail {
2656 current_block = 16642808987012640029;
2657 break 's_57;
2658 }
2659 }
2660 if (*parser).flow_level == 0 && ((*parser).mark.column as libc::c_int) < indent {
2661 current_block = 6281126495347172768;
2662 break;
2663 }
2664 }
2665 if current_block != 16642808987012640029 {
2666 memset(
2667 token as *mut libc::c_void,
2668 0,
2669 size_of::<yaml_token_t>() as libc::c_ulong,
2670 );
2671 (*token).type_ = YAML_SCALAR_TOKEN;
2672 (*token).start_mark = start_mark;
2673 (*token).end_mark = end_mark;
2674 let fresh842 = addr_of_mut!((*token).data.scalar.value);
2675 *fresh842 = string.start;
2676 (*token).data.scalar.length = string.pointer.c_offset_from(string.start) as size_t;
2677 (*token).data.scalar.style = YAML_PLAIN_SCALAR_STYLE;
2678 if leading_blanks {
2679 (*parser).simple_key_allowed = true;
2680 }
2681 STRING_DEL!(leading_break);
2682 STRING_DEL!(trailing_breaks);
2683 STRING_DEL!(whitespaces);
2684 return OK;
2685 }
2686 STRING_DEL!(string);
2687 STRING_DEL!(leading_break);
2688 STRING_DEL!(trailing_breaks);
2689 STRING_DEL!(whitespaces);
2690 FAIL
2691}