Skip to main content

unsafe_libyaml/
scanner.rs

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