Merge pull request #10 from dtolnay/enums

Remove integer casts from enum comparisons
This commit is contained in:
David Tolnay 2022-07-27 18:04:46 -07:00 committed by GitHub
commit 085e3af17f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 327 additions and 363 deletions

View file

@ -7,10 +7,11 @@ use crate::{
yaml_node_pair_t, yaml_node_t, yaml_parser_state_t, yaml_parser_t, yaml_read_handler_t,
yaml_scalar_style_t, yaml_sequence_style_t, yaml_simple_key_t, yaml_tag_directive_t,
yaml_token_t, yaml_version_directive_t, yaml_write_handler_t, PointerExt, YAML_ALIAS_EVENT,
YAML_DOCUMENT_END_EVENT, YAML_DOCUMENT_START_EVENT, YAML_MAPPING_END_EVENT, YAML_MAPPING_NODE,
YAML_MAPPING_START_EVENT, YAML_MEMORY_ERROR, YAML_NO_ERROR, YAML_SCALAR_EVENT,
YAML_SCALAR_NODE, YAML_SEQUENCE_END_EVENT, YAML_SEQUENCE_NODE, YAML_SEQUENCE_START_EVENT,
YAML_STREAM_END_EVENT, YAML_STREAM_START_EVENT,
YAML_ALIAS_TOKEN, YAML_ANCHOR_TOKEN, YAML_ANY_ENCODING, YAML_DOCUMENT_END_EVENT,
YAML_DOCUMENT_START_EVENT, YAML_MAPPING_END_EVENT, YAML_MAPPING_NODE, YAML_MAPPING_START_EVENT,
YAML_MEMORY_ERROR, YAML_NO_ERROR, YAML_SCALAR_EVENT, YAML_SCALAR_NODE, YAML_SCALAR_TOKEN,
YAML_SEQUENCE_END_EVENT, YAML_SEQUENCE_NODE, YAML_SEQUENCE_START_EVENT, YAML_STREAM_END_EVENT,
YAML_STREAM_START_EVENT, YAML_TAG_DIRECTIVE_TOKEN, YAML_TAG_TOKEN,
};
use core::mem::{size_of, MaybeUninit};
use core::ptr::{self, addr_of_mut};
@ -330,7 +331,7 @@ pub unsafe fn yaml_parser_set_input(
/// Set the source encoding.
pub unsafe fn yaml_parser_set_encoding(mut parser: *mut yaml_parser_t, encoding: yaml_encoding_t) {
__assert!(!parser.is_null());
__assert!((*parser).encoding as u64 == 0);
__assert!((*parser).encoding == YAML_ANY_ENCODING);
(*parser).encoding = encoding;
}
@ -488,7 +489,7 @@ pub unsafe fn yaml_emitter_set_encoding(
encoding: yaml_encoding_t,
) {
__assert!(!emitter.is_null());
__assert!((*emitter).encoding as u64 == 0);
__assert!((*emitter).encoding == YAML_ANY_ENCODING);
(*emitter).encoding = encoding;
}
@ -526,22 +527,22 @@ pub unsafe fn yaml_emitter_set_break(mut emitter: *mut yaml_emitter_t, line_brea
/// Free any memory allocated for a token object.
pub unsafe fn yaml_token_delete(token: *mut yaml_token_t) {
__assert!(!token.is_null());
match (*token).type_ as libc::c_uint {
4 => {
match (*token).type_ {
YAML_TAG_DIRECTIVE_TOKEN => {
yaml_free((*token).data.tag_directive.handle as *mut libc::c_void);
yaml_free((*token).data.tag_directive.prefix as *mut libc::c_void);
}
18 => {
YAML_ALIAS_TOKEN => {
yaml_free((*token).data.alias.value as *mut libc::c_void);
}
19 => {
YAML_ANCHOR_TOKEN => {
yaml_free((*token).data.anchor.value as *mut libc::c_void);
}
20 => {
YAML_TAG_TOKEN => {
yaml_free((*token).data.tag.handle as *mut libc::c_void);
yaml_free((*token).data.tag.suffix as *mut libc::c_void);
}
21 => {
YAML_SCALAR_TOKEN => {
yaml_free((*token).data.scalar.value as *mut libc::c_void);
}
_ => {}
@ -1162,8 +1163,8 @@ pub unsafe fn yaml_mapping_end_event_initialize(mut event: *mut yaml_event_t) ->
pub unsafe fn yaml_event_delete(event: *mut yaml_event_t) {
let mut tag_directive: *mut yaml_tag_directive_t;
__assert!(!event.is_null());
match (*event).type_ as libc::c_uint {
3 => {
match (*event).type_ {
YAML_DOCUMENT_START_EVENT => {
yaml_free((*event).data.document_start.version_directive as *mut libc::c_void);
tag_directive = (*event).data.document_start.tag_directives.start;
while tag_directive != (*event).data.document_start.tag_directives.end {
@ -1173,19 +1174,19 @@ pub unsafe fn yaml_event_delete(event: *mut yaml_event_t) {
}
yaml_free((*event).data.document_start.tag_directives.start as *mut libc::c_void);
}
5 => {
YAML_ALIAS_EVENT => {
yaml_free((*event).data.alias.anchor as *mut libc::c_void);
}
6 => {
YAML_SCALAR_EVENT => {
yaml_free((*event).data.scalar.anchor as *mut libc::c_void);
yaml_free((*event).data.scalar.tag as *mut libc::c_void);
yaml_free((*event).data.scalar.value as *mut libc::c_void);
}
7 => {
YAML_SEQUENCE_START_EVENT => {
yaml_free((*event).data.sequence_start.anchor as *mut libc::c_void);
yaml_free((*event).data.sequence_start.tag as *mut libc::c_void);
}
9 => {
YAML_MAPPING_START_EVENT => {
yaml_free((*event).data.mapping_start.anchor as *mut libc::c_void);
yaml_free((*event).data.mapping_start.tag as *mut libc::c_void);
}
@ -1370,14 +1371,14 @@ pub unsafe fn yaml_document_delete(document: *mut yaml_document_t) {
while !STACK_EMPTY!((*document).nodes) {
let mut node = POP!((*document).nodes);
yaml_free(node.tag as *mut libc::c_void);
match node.type_ as libc::c_uint {
1 => {
match node.type_ {
YAML_SCALAR_NODE => {
yaml_free(node.data.scalar.value as *mut libc::c_void);
}
2 => {
YAML_SEQUENCE_NODE => {
STACK_DEL!(node.data.sequence.items);
}
3 => {
YAML_MAPPING_NODE => {
STACK_DEL!(node.data.mapping.pairs);
}
_ => {
@ -1657,8 +1658,8 @@ pub unsafe fn yaml_document_append_sequence_item(
<= (*document).nodes.top
);
__assert!(
(*((*document).nodes.start).wrapping_offset((sequence - 1) as isize)).type_ as libc::c_uint
== YAML_SEQUENCE_NODE as libc::c_int as libc::c_uint
(*((*document).nodes.start).wrapping_offset((sequence - 1) as isize)).type_
== YAML_SEQUENCE_NODE
);
__assert!(
item > 0
@ -1695,8 +1696,8 @@ pub unsafe fn yaml_document_append_mapping_pair(
&& ((*document).nodes.start).wrapping_offset(mapping as isize) <= (*document).nodes.top
);
__assert!(
(*((*document).nodes.start).wrapping_offset((mapping - 1) as isize)).type_ as libc::c_uint
== YAML_MAPPING_NODE as libc::c_int as libc::c_uint
(*((*document).nodes.start).wrapping_offset((mapping - 1) as isize)).type_
== YAML_MAPPING_NODE
);
__assert!(
key > 0 && ((*document).nodes.start).wrapping_offset(key as isize) <= (*document).nodes.top

View file

@ -190,14 +190,14 @@ unsafe fn yaml_emitter_delete_document_and_anchors(mut emitter: *mut yaml_emitte
.wrapping_offset(index as isize);
if !(*(*emitter).anchors.wrapping_offset(index as isize)).serialized {
yaml_free(node.tag as *mut libc::c_void);
if node.type_ as libc::c_uint == YAML_SCALAR_NODE as libc::c_int as libc::c_uint {
if node.type_ == YAML_SCALAR_NODE {
yaml_free(node.data.scalar.value as *mut libc::c_void);
}
}
if node.type_ as libc::c_uint == YAML_SEQUENCE_NODE as libc::c_int as libc::c_uint {
if node.type_ == YAML_SEQUENCE_NODE {
STACK_DEL!(node.data.sequence.items);
}
if node.type_ as libc::c_uint == YAML_MAPPING_NODE as libc::c_int as libc::c_uint {
if node.type_ == YAML_MAPPING_NODE {
STACK_DEL!(node.data.mapping.pairs);
}
index += 1;
@ -223,15 +223,15 @@ unsafe fn yaml_emitter_anchor_node(emitter: *mut yaml_emitter_t, index: libc::c_
addr_of_mut!((*((*emitter).anchors).wrapping_offset((index - 1) as isize)).references);
*fresh8 += 1;
if (*(*emitter).anchors.wrapping_offset((index - 1) as isize)).references == 1 {
match (*node).type_ as libc::c_uint {
2 => {
match (*node).type_ {
YAML_SEQUENCE_NODE => {
item = (*node).data.sequence.items.start;
while item < (*node).data.sequence.items.top {
yaml_emitter_anchor_node(emitter, *item);
item = item.wrapping_offset(1);
}
}
3 => {
YAML_MAPPING_NODE => {
pair = (*node).data.mapping.pairs.start;
while pair < (*node).data.mapping.pairs.top {
yaml_emitter_anchor_node(emitter, (*pair).key);
@ -278,10 +278,10 @@ unsafe fn yaml_emitter_dump_node(emitter: *mut yaml_emitter_t, index: libc::c_in
return yaml_emitter_dump_alias(emitter, anchor);
}
(*(*emitter).anchors.wrapping_offset((index - 1) as isize)).serialized = true;
match (*node).type_ as libc::c_uint {
1 => yaml_emitter_dump_scalar(emitter, node, anchor),
2 => yaml_emitter_dump_sequence(emitter, node, anchor),
3 => yaml_emitter_dump_mapping(emitter, node, anchor),
match (*node).type_ {
YAML_SCALAR_NODE => yaml_emitter_dump_scalar(emitter, node, anchor),
YAML_SEQUENCE_NODE => yaml_emitter_dump_sequence(emitter, node, anchor),
YAML_MAPPING_NODE => yaml_emitter_dump_mapping(emitter, node, anchor),
_ => __assert!(false),
}
}

View file

@ -4,21 +4,22 @@ use crate::success::{Success, FAIL, OK};
use crate::yaml::{size_t, yaml_char_t, yaml_string_t};
use crate::{
libc, yaml_emitter_flush, yaml_emitter_t, yaml_event_delete, yaml_event_t, yaml_scalar_style_t,
yaml_tag_directive_t, yaml_version_directive_t, PointerExt, YAML_ANY_SCALAR_STYLE,
YAML_CRLN_BREAK, YAML_CR_BREAK, YAML_DOCUMENT_END_EVENT, YAML_DOCUMENT_START_EVENT,
YAML_DOUBLE_QUOTED_SCALAR_STYLE, YAML_EMITTER_ERROR, YAML_EMIT_BLOCK_MAPPING_FIRST_KEY_STATE,
YAML_EMIT_BLOCK_MAPPING_KEY_STATE, YAML_EMIT_BLOCK_MAPPING_SIMPLE_VALUE_STATE,
YAML_EMIT_BLOCK_MAPPING_VALUE_STATE, YAML_EMIT_BLOCK_SEQUENCE_FIRST_ITEM_STATE,
YAML_EMIT_BLOCK_SEQUENCE_ITEM_STATE, YAML_EMIT_DOCUMENT_CONTENT_STATE,
YAML_EMIT_DOCUMENT_END_STATE, YAML_EMIT_DOCUMENT_START_STATE, YAML_EMIT_END_STATE,
YAML_EMIT_FIRST_DOCUMENT_START_STATE, YAML_EMIT_FLOW_MAPPING_FIRST_KEY_STATE,
YAML_EMIT_FLOW_MAPPING_KEY_STATE, YAML_EMIT_FLOW_MAPPING_SIMPLE_VALUE_STATE,
YAML_EMIT_FLOW_MAPPING_VALUE_STATE, YAML_EMIT_FLOW_SEQUENCE_FIRST_ITEM_STATE,
YAML_EMIT_FLOW_SEQUENCE_ITEM_STATE, YAML_FLOW_MAPPING_STYLE, YAML_FLOW_SEQUENCE_STYLE,
yaml_tag_directive_t, yaml_version_directive_t, PointerExt, YAML_ALIAS_EVENT, YAML_ANY_BREAK,
YAML_ANY_ENCODING, YAML_ANY_SCALAR_STYLE, YAML_CRLN_BREAK, YAML_CR_BREAK,
YAML_DOCUMENT_END_EVENT, YAML_DOCUMENT_START_EVENT, YAML_DOUBLE_QUOTED_SCALAR_STYLE,
YAML_EMITTER_ERROR, YAML_EMIT_BLOCK_MAPPING_FIRST_KEY_STATE, YAML_EMIT_BLOCK_MAPPING_KEY_STATE,
YAML_EMIT_BLOCK_MAPPING_SIMPLE_VALUE_STATE, YAML_EMIT_BLOCK_MAPPING_VALUE_STATE,
YAML_EMIT_BLOCK_SEQUENCE_FIRST_ITEM_STATE, YAML_EMIT_BLOCK_SEQUENCE_ITEM_STATE,
YAML_EMIT_DOCUMENT_CONTENT_STATE, YAML_EMIT_DOCUMENT_END_STATE, YAML_EMIT_DOCUMENT_START_STATE,
YAML_EMIT_END_STATE, YAML_EMIT_FIRST_DOCUMENT_START_STATE,
YAML_EMIT_FLOW_MAPPING_FIRST_KEY_STATE, YAML_EMIT_FLOW_MAPPING_KEY_STATE,
YAML_EMIT_FLOW_MAPPING_SIMPLE_VALUE_STATE, YAML_EMIT_FLOW_MAPPING_VALUE_STATE,
YAML_EMIT_FLOW_SEQUENCE_FIRST_ITEM_STATE, YAML_EMIT_FLOW_SEQUENCE_ITEM_STATE,
YAML_EMIT_STREAM_START_STATE, YAML_FLOW_MAPPING_STYLE, YAML_FLOW_SEQUENCE_STYLE,
YAML_FOLDED_SCALAR_STYLE, YAML_LITERAL_SCALAR_STYLE, YAML_LN_BREAK, YAML_MAPPING_END_EVENT,
YAML_MAPPING_START_EVENT, YAML_MEMORY_ERROR, YAML_PLAIN_SCALAR_STYLE, YAML_SEQUENCE_END_EVENT,
YAML_SEQUENCE_START_EVENT, YAML_SINGLE_QUOTED_SCALAR_STYLE, YAML_STREAM_END_EVENT,
YAML_STREAM_START_EVENT, YAML_UTF8_ENCODING,
YAML_MAPPING_START_EVENT, YAML_MEMORY_ERROR, YAML_PLAIN_SCALAR_STYLE, YAML_SCALAR_EVENT,
YAML_SEQUENCE_END_EVENT, YAML_SEQUENCE_START_EVENT, YAML_SINGLE_QUOTED_SCALAR_STYLE,
YAML_STREAM_END_EVENT, YAML_STREAM_START_EVENT, YAML_UTF8_ENCODING,
};
use core::ptr::{self, addr_of_mut};
@ -47,20 +48,17 @@ unsafe fn PUT_BREAK(emitter: *mut yaml_emitter_t) -> Success {
if FLUSH(emitter).fail {
return FAIL;
}
if (*emitter).line_break as libc::c_uint == YAML_CR_BREAK as libc::c_int as libc::c_uint {
if (*emitter).line_break == YAML_CR_BREAK {
let fresh62 = addr_of_mut!((*emitter).buffer.pointer);
let fresh63 = *fresh62;
*fresh62 = (*fresh62).wrapping_offset(1);
*fresh63 = b'\r';
} else if (*emitter).line_break as libc::c_uint == YAML_LN_BREAK as libc::c_int as libc::c_uint
{
} else if (*emitter).line_break == YAML_LN_BREAK {
let fresh64 = addr_of_mut!((*emitter).buffer.pointer);
let fresh65 = *fresh64;
*fresh64 = (*fresh64).wrapping_offset(1);
*fresh65 = b'\n';
} else if (*emitter).line_break as libc::c_uint
== YAML_CRLN_BREAK as libc::c_int as libc::c_uint
{
} else if (*emitter).line_break == YAML_CRLN_BREAK {
let fresh66 = addr_of_mut!((*emitter).buffer.pointer);
let fresh67 = *fresh66;
*fresh66 = (*fresh66).wrapping_offset(1);
@ -156,10 +154,10 @@ unsafe fn yaml_emitter_need_more_events(emitter: *mut yaml_emitter_t) -> Success
if QUEUE_EMPTY!((*emitter).events) {
return OK;
}
let accumulate = match (*(*emitter).events.head).type_ as libc::c_uint {
3 => 1,
7 => 2,
9 => 3,
let accumulate = match (*(*emitter).events.head).type_ {
YAML_DOCUMENT_START_EVENT => 1,
YAML_SEQUENCE_START_EVENT => 2,
YAML_MAPPING_START_EVENT => 3,
_ => return FAIL,
};
if (*emitter).events.tail.c_offset_from((*emitter).events.head) as libc::c_long
@ -169,11 +167,17 @@ unsafe fn yaml_emitter_need_more_events(emitter: *mut yaml_emitter_t) -> Success
}
event = (*emitter).events.head;
while event != (*emitter).events.tail {
match (*event).type_ as libc::c_uint {
1 | 3 | 7 | 9 => {
match (*event).type_ {
YAML_STREAM_START_EVENT
| YAML_DOCUMENT_START_EVENT
| YAML_SEQUENCE_START_EVENT
| YAML_MAPPING_START_EVENT => {
level += 1;
}
2 | 4 | 8 | 10 => {
YAML_STREAM_END_EVENT
| YAML_DOCUMENT_END_EVENT
| YAML_SEQUENCE_END_EVENT
| YAML_MAPPING_END_EVENT => {
level -= 1;
}
_ => {}
@ -245,33 +249,55 @@ unsafe fn yaml_emitter_state_machine(
emitter: *mut yaml_emitter_t,
event: *mut yaml_event_t,
) -> Success {
match (*emitter).state as libc::c_uint {
0 => return yaml_emitter_emit_stream_start(emitter, event),
1 => return yaml_emitter_emit_document_start(emitter, event, true),
2 => return yaml_emitter_emit_document_start(emitter, event, false),
3 => return yaml_emitter_emit_document_content(emitter, event),
4 => return yaml_emitter_emit_document_end(emitter, event),
5 => return yaml_emitter_emit_flow_sequence_item(emitter, event, true),
6 => return yaml_emitter_emit_flow_sequence_item(emitter, event, false),
7 => return yaml_emitter_emit_flow_mapping_key(emitter, event, true),
8 => return yaml_emitter_emit_flow_mapping_key(emitter, event, false),
9 => return yaml_emitter_emit_flow_mapping_value(emitter, event, true),
10 => return yaml_emitter_emit_flow_mapping_value(emitter, event, false),
11 => return yaml_emitter_emit_block_sequence_item(emitter, event, true),
12 => return yaml_emitter_emit_block_sequence_item(emitter, event, false),
13 => return yaml_emitter_emit_block_mapping_key(emitter, event, true),
14 => return yaml_emitter_emit_block_mapping_key(emitter, event, false),
15 => return yaml_emitter_emit_block_mapping_value(emitter, event, true),
16 => return yaml_emitter_emit_block_mapping_value(emitter, event, false),
17 => {
return yaml_emitter_set_emitter_error(
emitter,
b"expected nothing after STREAM-END\0" as *const u8 as *const libc::c_char,
)
match (*emitter).state {
YAML_EMIT_STREAM_START_STATE => yaml_emitter_emit_stream_start(emitter, event),
YAML_EMIT_FIRST_DOCUMENT_START_STATE => {
yaml_emitter_emit_document_start(emitter, event, true)
}
_ => {}
YAML_EMIT_DOCUMENT_START_STATE => yaml_emitter_emit_document_start(emitter, event, false),
YAML_EMIT_DOCUMENT_CONTENT_STATE => yaml_emitter_emit_document_content(emitter, event),
YAML_EMIT_DOCUMENT_END_STATE => yaml_emitter_emit_document_end(emitter, event),
YAML_EMIT_FLOW_SEQUENCE_FIRST_ITEM_STATE => {
yaml_emitter_emit_flow_sequence_item(emitter, event, true)
}
YAML_EMIT_FLOW_SEQUENCE_ITEM_STATE => {
yaml_emitter_emit_flow_sequence_item(emitter, event, false)
}
YAML_EMIT_FLOW_MAPPING_FIRST_KEY_STATE => {
yaml_emitter_emit_flow_mapping_key(emitter, event, true)
}
YAML_EMIT_FLOW_MAPPING_KEY_STATE => {
yaml_emitter_emit_flow_mapping_key(emitter, event, false)
}
YAML_EMIT_FLOW_MAPPING_SIMPLE_VALUE_STATE => {
yaml_emitter_emit_flow_mapping_value(emitter, event, true)
}
YAML_EMIT_FLOW_MAPPING_VALUE_STATE => {
yaml_emitter_emit_flow_mapping_value(emitter, event, false)
}
YAML_EMIT_BLOCK_SEQUENCE_FIRST_ITEM_STATE => {
yaml_emitter_emit_block_sequence_item(emitter, event, true)
}
YAML_EMIT_BLOCK_SEQUENCE_ITEM_STATE => {
yaml_emitter_emit_block_sequence_item(emitter, event, false)
}
YAML_EMIT_BLOCK_MAPPING_FIRST_KEY_STATE => {
yaml_emitter_emit_block_mapping_key(emitter, event, true)
}
YAML_EMIT_BLOCK_MAPPING_KEY_STATE => {
yaml_emitter_emit_block_mapping_key(emitter, event, false)
}
YAML_EMIT_BLOCK_MAPPING_SIMPLE_VALUE_STATE => {
yaml_emitter_emit_block_mapping_value(emitter, event, true)
}
YAML_EMIT_BLOCK_MAPPING_VALUE_STATE => {
yaml_emitter_emit_block_mapping_value(emitter, event, false)
}
YAML_EMIT_END_STATE => yaml_emitter_set_emitter_error(
emitter,
b"expected nothing after STREAM-END\0" as *const u8 as *const libc::c_char,
),
}
FAIL
}
unsafe fn yaml_emitter_emit_stream_start(
@ -279,11 +305,11 @@ unsafe fn yaml_emitter_emit_stream_start(
event: *mut yaml_event_t,
) -> Success {
(*emitter).open_ended = 0;
if (*event).type_ as libc::c_uint == YAML_STREAM_START_EVENT as libc::c_int as libc::c_uint {
if (*emitter).encoding as u64 == 0 {
if (*event).type_ == YAML_STREAM_START_EVENT {
if (*emitter).encoding == YAML_ANY_ENCODING {
(*emitter).encoding = (*event).data.stream_start.encoding;
}
if (*emitter).encoding as u64 == 0 {
if (*emitter).encoding == YAML_ANY_ENCODING {
(*emitter).encoding = YAML_UTF8_ENCODING;
}
if (*emitter).best_indent < 2 || (*emitter).best_indent > 9 {
@ -295,7 +321,7 @@ unsafe fn yaml_emitter_emit_stream_start(
if (*emitter).best_width < 0 {
(*emitter).best_width = 2147483647;
}
if (*emitter).line_break as u64 == 0 {
if (*emitter).line_break == YAML_ANY_BREAK {
(*emitter).line_break = YAML_LN_BREAK;
}
(*emitter).indent = -1;
@ -303,8 +329,7 @@ unsafe fn yaml_emitter_emit_stream_start(
(*emitter).column = 0;
(*emitter).whitespace = true;
(*emitter).indention = true;
if (*emitter).encoding as libc::c_uint != YAML_UTF8_ENCODING as libc::c_int as libc::c_uint
{
if (*emitter).encoding != YAML_UTF8_ENCODING {
if yaml_emitter_write_bom(emitter).fail {
return FAIL;
}
@ -323,7 +348,7 @@ unsafe fn yaml_emitter_emit_document_start(
event: *mut yaml_event_t,
first: bool,
) -> Success {
if (*event).type_ as libc::c_uint == YAML_DOCUMENT_START_EVENT as libc::c_int as libc::c_uint {
if (*event).type_ == YAML_DOCUMENT_START_EVENT {
let mut default_tag_directives: [yaml_tag_directive_t; 3] = [
yaml_tag_directive_t {
handle: b"!\0" as *const u8 as *const libc::c_char as *mut yaml_char_t,
@ -502,8 +527,7 @@ unsafe fn yaml_emitter_emit_document_start(
(*emitter).state = YAML_EMIT_DOCUMENT_CONTENT_STATE;
(*emitter).open_ended = 0;
return OK;
} else if (*event).type_ as libc::c_uint == YAML_STREAM_END_EVENT as libc::c_int as libc::c_uint
{
} else if (*event).type_ == YAML_STREAM_END_EVENT {
if (*emitter).open_ended == 2 {
if yaml_emitter_write_indicator(
emitter,
@ -547,7 +571,7 @@ unsafe fn yaml_emitter_emit_document_end(
mut emitter: *mut yaml_emitter_t,
event: *mut yaml_event_t,
) -> Success {
if (*event).type_ as libc::c_uint == YAML_DOCUMENT_END_EVENT as libc::c_int as libc::c_uint {
if (*event).type_ == YAML_DOCUMENT_END_EVENT {
if yaml_emitter_write_indent(emitter).fail {
return FAIL;
}
@ -610,7 +634,7 @@ unsafe fn yaml_emitter_emit_flow_sequence_item(
let fresh12 = addr_of_mut!((*emitter).flow_level);
*fresh12 += 1;
}
if (*event).type_ as libc::c_uint == YAML_SEQUENCE_END_EVENT as libc::c_int as libc::c_uint {
if (*event).type_ == YAML_SEQUENCE_END_EVENT {
let fresh13 = addr_of_mut!((*emitter).flow_level);
*fresh13 -= 1;
(*emitter).indent = POP!((*emitter).indents);
@ -697,7 +721,7 @@ unsafe fn yaml_emitter_emit_flow_mapping_key(
let fresh18 = addr_of_mut!((*emitter).flow_level);
*fresh18 += 1;
}
if (*event).type_ as libc::c_uint == YAML_MAPPING_END_EVENT as libc::c_int as libc::c_uint {
if (*event).type_ == YAML_MAPPING_END_EVENT {
let fresh19 = addr_of_mut!((*emitter).flow_level);
*fresh19 -= 1;
(*emitter).indent = POP!((*emitter).indents);
@ -842,7 +866,7 @@ unsafe fn yaml_emitter_emit_block_sequence_item(
return FAIL;
}
}
if (*event).type_ as libc::c_uint == YAML_SEQUENCE_END_EVENT as libc::c_int as libc::c_uint {
if (*event).type_ == YAML_SEQUENCE_END_EVENT {
(*emitter).indent = POP!((*emitter).indents);
(*emitter).state = POP!((*emitter).states);
return OK;
@ -883,7 +907,7 @@ unsafe fn yaml_emitter_emit_block_mapping_key(
return FAIL;
}
}
if (*event).type_ as libc::c_uint == YAML_MAPPING_END_EVENT as libc::c_int as libc::c_uint {
if (*event).type_ == YAML_MAPPING_END_EVENT {
(*emitter).indent = POP!((*emitter).indents);
(*emitter).state = POP!((*emitter).states);
return OK;
@ -984,11 +1008,11 @@ unsafe fn yaml_emitter_emit_node(
(*emitter).sequence_context = sequence;
(*emitter).mapping_context = mapping;
(*emitter).simple_key_context = simple_key;
match (*event).type_ as libc::c_uint {
5 => yaml_emitter_emit_alias(emitter, event),
6 => yaml_emitter_emit_scalar(emitter, event),
7 => yaml_emitter_emit_sequence_start(emitter, event),
9 => yaml_emitter_emit_mapping_start(emitter, event),
match (*event).type_ {
YAML_ALIAS_EVENT => yaml_emitter_emit_alias(emitter, event),
YAML_SCALAR_EVENT => yaml_emitter_emit_scalar(emitter, event),
YAML_SEQUENCE_START_EVENT => yaml_emitter_emit_sequence_start(emitter, event),
YAML_MAPPING_START_EVENT => yaml_emitter_emit_mapping_start(emitter, event),
_ => yaml_emitter_set_emitter_error(
emitter,
b"expected SCALAR, SEQUENCE-START, MAPPING-START, or ALIAS\0" as *const u8
@ -1049,8 +1073,7 @@ unsafe fn yaml_emitter_emit_sequence_start(
}
if (*emitter).flow_level != 0
|| (*emitter).canonical
|| (*event).data.sequence_start.style as libc::c_uint
== YAML_FLOW_SEQUENCE_STYLE as libc::c_int as libc::c_uint
|| (*event).data.sequence_start.style == YAML_FLOW_SEQUENCE_STYLE
|| yaml_emitter_check_empty_sequence(emitter)
{
(*emitter).state = YAML_EMIT_FLOW_SEQUENCE_FIRST_ITEM_STATE;
@ -1072,8 +1095,7 @@ unsafe fn yaml_emitter_emit_mapping_start(
}
if (*emitter).flow_level != 0
|| (*emitter).canonical
|| (*event).data.mapping_start.style as libc::c_uint
== YAML_FLOW_MAPPING_STYLE as libc::c_int as libc::c_uint
|| (*event).data.mapping_start.style == YAML_FLOW_MAPPING_STYLE
|| yaml_emitter_check_empty_mapping(emitter)
{
(*emitter).state = YAML_EMIT_FLOW_MAPPING_FIRST_KEY_STATE;
@ -1091,31 +1113,27 @@ unsafe fn yaml_emitter_check_empty_sequence(emitter: *mut yaml_emitter_t) -> boo
if ((*emitter).events.tail.c_offset_from((*emitter).events.head) as libc::c_long) < 2_i64 {
return false;
}
(*(*emitter).events.head).type_ as libc::c_uint
== YAML_SEQUENCE_START_EVENT as libc::c_int as libc::c_uint
&& (*(*emitter).events.head.wrapping_offset(1_isize)).type_ as libc::c_uint
== YAML_SEQUENCE_END_EVENT as libc::c_int as libc::c_uint
(*(*emitter).events.head).type_ == YAML_SEQUENCE_START_EVENT
&& (*(*emitter).events.head.wrapping_offset(1_isize)).type_ == YAML_SEQUENCE_END_EVENT
}
unsafe fn yaml_emitter_check_empty_mapping(emitter: *mut yaml_emitter_t) -> bool {
if ((*emitter).events.tail.c_offset_from((*emitter).events.head) as libc::c_long) < 2_i64 {
return false;
}
(*(*emitter).events.head).type_ as libc::c_uint
== YAML_MAPPING_START_EVENT as libc::c_int as libc::c_uint
&& (*(*emitter).events.head.wrapping_offset(1_isize)).type_ as libc::c_uint
== YAML_MAPPING_END_EVENT as libc::c_int as libc::c_uint
(*(*emitter).events.head).type_ == YAML_MAPPING_START_EVENT
&& (*(*emitter).events.head.wrapping_offset(1_isize)).type_ == YAML_MAPPING_END_EVENT
}
unsafe fn yaml_emitter_check_simple_key(emitter: *mut yaml_emitter_t) -> bool {
let event: *mut yaml_event_t = (*emitter).events.head;
let mut length: size_t = 0_u64;
match (*event).type_ as libc::c_uint {
5 => {
match (*event).type_ {
YAML_ALIAS_EVENT => {
length = (length as libc::c_ulong).wrapping_add((*emitter).anchor_data.anchor_length)
as size_t as size_t;
}
6 => {
YAML_SCALAR_EVENT => {
if (*emitter).scalar_data.multiline {
return false;
}
@ -1128,7 +1146,7 @@ unsafe fn yaml_emitter_check_simple_key(emitter: *mut yaml_emitter_t) -> bool {
.wrapping_add((*emitter).scalar_data.length),
) as size_t as size_t;
}
7 => {
YAML_SEQUENCE_START_EVENT => {
if !yaml_emitter_check_empty_sequence(emitter) {
return false;
}
@ -1140,7 +1158,7 @@ unsafe fn yaml_emitter_check_simple_key(emitter: *mut yaml_emitter_t) -> bool {
.wrapping_add((*emitter).tag_data.suffix_length),
) as size_t as size_t;
}
9 => {
YAML_MAPPING_START_EVENT => {
if !yaml_emitter_check_empty_mapping(emitter) {
return false;
}
@ -1172,7 +1190,7 @@ unsafe fn yaml_emitter_select_scalar_style(
b"neither tag nor implicit flags are specified\0" as *const u8 as *const libc::c_char,
);
}
if style as libc::c_uint == YAML_ANY_SCALAR_STYLE as libc::c_int as libc::c_uint {
if style == YAML_ANY_SCALAR_STYLE {
style = YAML_PLAIN_SCALAR_STYLE;
}
if (*emitter).canonical {
@ -1181,7 +1199,7 @@ unsafe fn yaml_emitter_select_scalar_style(
if (*emitter).simple_key_context && (*emitter).scalar_data.multiline {
style = YAML_DOUBLE_QUOTED_SCALAR_STYLE;
}
if style as libc::c_uint == YAML_PLAIN_SCALAR_STYLE as libc::c_int as libc::c_uint {
if style == YAML_PLAIN_SCALAR_STYLE {
if (*emitter).flow_level != 0 && !(*emitter).scalar_data.flow_plain_allowed
|| (*emitter).flow_level == 0 && !(*emitter).scalar_data.block_plain_allowed
{
@ -1196,14 +1214,12 @@ unsafe fn yaml_emitter_select_scalar_style(
style = YAML_SINGLE_QUOTED_SCALAR_STYLE;
}
}
if style as libc::c_uint == YAML_SINGLE_QUOTED_SCALAR_STYLE as libc::c_int as libc::c_uint {
if style == YAML_SINGLE_QUOTED_SCALAR_STYLE {
if !(*emitter).scalar_data.single_quoted_allowed {
style = YAML_DOUBLE_QUOTED_SCALAR_STYLE;
}
}
if style as libc::c_uint == YAML_LITERAL_SCALAR_STYLE as libc::c_int as libc::c_uint
|| style as libc::c_uint == YAML_FOLDED_SCALAR_STYLE as libc::c_int as libc::c_uint
{
if style == YAML_LITERAL_SCALAR_STYLE || style == YAML_FOLDED_SCALAR_STYLE {
if !(*emitter).scalar_data.block_allowed
|| (*emitter).flow_level != 0
|| (*emitter).simple_key_context
@ -1211,10 +1227,7 @@ unsafe fn yaml_emitter_select_scalar_style(
style = YAML_DOUBLE_QUOTED_SCALAR_STYLE;
}
}
if no_tag
&& !(*event).data.scalar.quoted_implicit
&& style as libc::c_uint != YAML_PLAIN_SCALAR_STYLE as libc::c_int as libc::c_uint
{
if no_tag && !(*event).data.scalar.quoted_implicit && style != YAML_PLAIN_SCALAR_STYLE {
let fresh46 = addr_of_mut!((*emitter).tag_data.handle);
*fresh46 = b"!\0" as *const u8 as *const libc::c_char as *mut yaml_char_t;
(*emitter).tag_data.handle_length = 1_u64;
@ -1313,8 +1326,8 @@ unsafe fn yaml_emitter_process_tag(emitter: *mut yaml_emitter_t) -> Success {
}
unsafe fn yaml_emitter_process_scalar(emitter: *mut yaml_emitter_t) -> Success {
match (*emitter).scalar_data.style as libc::c_uint {
1 => {
match (*emitter).scalar_data.style {
YAML_PLAIN_SCALAR_STYLE => {
return yaml_emitter_write_plain_scalar(
emitter,
(*emitter).scalar_data.value,
@ -1322,7 +1335,7 @@ unsafe fn yaml_emitter_process_scalar(emitter: *mut yaml_emitter_t) -> Success {
!(*emitter).simple_key_context,
);
}
2 => {
YAML_SINGLE_QUOTED_SCALAR_STYLE => {
return yaml_emitter_write_single_quoted_scalar(
emitter,
(*emitter).scalar_data.value,
@ -1330,7 +1343,7 @@ unsafe fn yaml_emitter_process_scalar(emitter: *mut yaml_emitter_t) -> Success {
!(*emitter).simple_key_context,
);
}
3 => {
YAML_DOUBLE_QUOTED_SCALAR_STYLE => {
return yaml_emitter_write_double_quoted_scalar(
emitter,
(*emitter).scalar_data.value,
@ -1338,14 +1351,14 @@ unsafe fn yaml_emitter_process_scalar(emitter: *mut yaml_emitter_t) -> Success {
!(*emitter).simple_key_context,
);
}
4 => {
YAML_LITERAL_SCALAR_STYLE => {
return yaml_emitter_write_literal_scalar(
emitter,
(*emitter).scalar_data.value,
(*emitter).scalar_data.length,
);
}
5 => {
YAML_FOLDED_SCALAR_STYLE => {
return yaml_emitter_write_folded_scalar(
emitter,
(*emitter).scalar_data.value,
@ -1684,14 +1697,14 @@ unsafe fn yaml_emitter_analyze_event(
let fresh55 = addr_of_mut!((*emitter).scalar_data.value);
*fresh55 = ptr::null_mut::<yaml_char_t>();
(*emitter).scalar_data.length = 0_u64;
match (*event).type_ as libc::c_uint {
5 => {
match (*event).type_ {
YAML_ALIAS_EVENT => {
if yaml_emitter_analyze_anchor(emitter, (*event).data.alias.anchor, true).fail {
return FAIL;
}
OK
}
6 => {
YAML_SCALAR_EVENT => {
if !(*event).data.scalar.anchor.is_null() {
if yaml_emitter_analyze_anchor(emitter, (*event).data.scalar.anchor, false).fail {
return FAIL;
@ -1717,7 +1730,7 @@ unsafe fn yaml_emitter_analyze_event(
}
OK
}
7 => {
YAML_SEQUENCE_START_EVENT => {
if !(*event).data.sequence_start.anchor.is_null() {
if yaml_emitter_analyze_anchor(emitter, (*event).data.sequence_start.anchor, false)
.fail
@ -1734,7 +1747,7 @@ unsafe fn yaml_emitter_analyze_event(
}
OK
}
9 => {
YAML_MAPPING_START_EVENT => {
if !(*event).data.mapping_start.anchor.is_null() {
if yaml_emitter_analyze_anchor(emitter, (*event).data.mapping_start.anchor, false)
.fail

View file

@ -5,9 +5,10 @@ use crate::yaml::yaml_char_t;
use crate::{
libc, yaml_alias_data_t, yaml_document_delete, yaml_document_t, yaml_event_t, yaml_mark_t,
yaml_node_item_t, yaml_node_pair_t, yaml_node_t, yaml_parser_parse, yaml_parser_t, PointerExt,
YAML_COMPOSER_ERROR, YAML_DOCUMENT_END_EVENT, YAML_DOCUMENT_START_EVENT, YAML_MAPPING_NODE,
YAML_MEMORY_ERROR, YAML_SCALAR_NODE, YAML_SEQUENCE_NODE, YAML_STREAM_END_EVENT,
YAML_STREAM_START_EVENT,
YAML_ALIAS_EVENT, YAML_COMPOSER_ERROR, YAML_DOCUMENT_END_EVENT, YAML_DOCUMENT_START_EVENT,
YAML_MAPPING_END_EVENT, YAML_MAPPING_NODE, YAML_MAPPING_START_EVENT, YAML_MEMORY_ERROR,
YAML_SCALAR_EVENT, YAML_SCALAR_NODE, YAML_SEQUENCE_END_EVENT, YAML_SEQUENCE_NODE,
YAML_SEQUENCE_START_EVENT, YAML_STREAM_END_EVENT, YAML_STREAM_START_EVENT,
};
use core::mem::{size_of, MaybeUninit};
use core::ptr::{self, addr_of_mut};
@ -52,10 +53,7 @@ pub unsafe fn yaml_parser_load(
if yaml_parser_parse(parser, event).fail {
current_block = 6234624449317607669;
} else {
__assert!(
(*event).type_ as libc::c_uint
== YAML_STREAM_START_EVENT as libc::c_int as libc::c_uint
);
__assert!((*event).type_ == YAML_STREAM_START_EVENT);
current_block = 7815301370352969686;
}
} else {
@ -68,9 +66,7 @@ pub unsafe fn yaml_parser_load(
return OK;
}
if yaml_parser_parse(parser, event).ok {
if (*event).type_ as libc::c_uint
== YAML_STREAM_END_EVENT as libc::c_int as libc::c_uint
{
if (*event).type_ == YAML_STREAM_END_EVENT {
return OK;
}
if STACK_INIT!(parser, (*parser).aliases, yaml_alias_data_t).ok {
@ -139,9 +135,7 @@ unsafe fn yaml_parser_load_document(
end: ptr::null_mut::<libc::c_int>(),
top: ptr::null_mut::<libc::c_int>(),
};
__assert!(
(*event).type_ as libc::c_uint == YAML_DOCUMENT_START_EVENT as libc::c_int as libc::c_uint
);
__assert!((*event).type_ == YAML_DOCUMENT_START_EVENT);
let fresh16 = addr_of_mut!((*(*parser).document).version_directive);
*fresh16 = (*event).data.document_start.version_directive;
let fresh17 = addr_of_mut!((*(*parser).document).tag_directives.start);
@ -168,45 +162,43 @@ unsafe fn yaml_parser_load_nodes(mut parser: *mut yaml_parser_t, ctx: *mut loade
if yaml_parser_parse(parser, event).fail {
return FAIL;
}
match (*event).type_ as libc::c_uint {
5 => {
match (*event).type_ {
YAML_ALIAS_EVENT => {
if yaml_parser_load_alias(parser, event, ctx).fail {
return FAIL;
}
}
6 => {
YAML_SCALAR_EVENT => {
if yaml_parser_load_scalar(parser, event, ctx).fail {
return FAIL;
}
}
7 => {
YAML_SEQUENCE_START_EVENT => {
if yaml_parser_load_sequence(parser, event, ctx).fail {
return FAIL;
}
}
8 => {
YAML_SEQUENCE_END_EVENT => {
if yaml_parser_load_sequence_end(parser, event, ctx).fail {
return FAIL;
}
}
9 => {
YAML_MAPPING_START_EVENT => {
if yaml_parser_load_mapping(parser, event, ctx).fail {
return FAIL;
}
}
10 => {
YAML_MAPPING_END_EVENT => {
if yaml_parser_load_mapping_end(parser, event, ctx).fail {
return FAIL;
}
}
4 => {}
YAML_DOCUMENT_END_EVENT => {}
_ => {
__assert!(false);
}
}
if !((*event).type_ as libc::c_uint
!= YAML_DOCUMENT_END_EVENT as libc::c_int as libc::c_uint)
{
if (*event).type_ == YAML_DOCUMENT_END_EVENT {
break;
}
}
@ -271,8 +263,8 @@ unsafe fn yaml_parser_load_node_add(
*((*(*parser).document).nodes.start).wrapping_offset((parent_index - 1) as isize)
);
let current_block_17: u64;
match (*parent).type_ as libc::c_uint {
2 => {
match (*parent).type_ {
YAML_SEQUENCE_NODE => {
if STACK_LIMIT!(parser, (*parent).data.sequence.items).fail {
return FAIL;
}
@ -280,7 +272,7 @@ unsafe fn yaml_parser_load_node_add(
return FAIL;
}
}
3 => {
YAML_MAPPING_NODE => {
let mut pair = MaybeUninit::<yaml_node_pair_t>::uninit();
let pair = pair.as_mut_ptr();
if !STACK_EMPTY!((*parent).data.mapping.pairs) {
@ -508,8 +500,7 @@ unsafe fn yaml_parser_load_sequence_end(
let index: libc::c_int = *(*ctx).top.wrapping_offset(-1_isize);
__assert!(
(*((*(*parser).document).nodes.start).wrapping_offset((index - 1) as isize)).type_
as libc::c_uint
== YAML_SEQUENCE_NODE as libc::c_int as libc::c_uint
== YAML_SEQUENCE_NODE
);
(*(*(*parser).document)
.nodes
@ -620,8 +611,7 @@ unsafe fn yaml_parser_load_mapping_end(
let index: libc::c_int = *(*ctx).top.wrapping_offset(-1_isize);
__assert!(
(*((*(*parser).document).nodes.start).wrapping_offset((index - 1) as isize)).type_
as libc::c_uint
== YAML_MAPPING_NODE as libc::c_int as libc::c_uint
== YAML_MAPPING_NODE
);
(*(*(*parser).document)
.nodes

View file

@ -12,22 +12,24 @@ use crate::{
YAML_DOCUMENT_START_TOKEN, YAML_FLOW_ENTRY_TOKEN, YAML_FLOW_MAPPING_END_TOKEN,
YAML_FLOW_MAPPING_START_TOKEN, YAML_FLOW_MAPPING_STYLE, YAML_FLOW_SEQUENCE_END_TOKEN,
YAML_FLOW_SEQUENCE_START_TOKEN, YAML_FLOW_SEQUENCE_STYLE, YAML_KEY_TOKEN,
YAML_MAPPING_END_EVENT, YAML_MAPPING_START_EVENT, YAML_MEMORY_ERROR, YAML_PARSER_ERROR,
YAML_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE, YAML_PARSE_BLOCK_MAPPING_KEY_STATE,
YAML_PARSE_BLOCK_MAPPING_VALUE_STATE, YAML_PARSE_BLOCK_NODE_STATE,
YAML_MAPPING_END_EVENT, YAML_MAPPING_START_EVENT, YAML_MEMORY_ERROR, YAML_NO_ERROR,
YAML_PARSER_ERROR, YAML_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE,
YAML_PARSE_BLOCK_MAPPING_KEY_STATE, YAML_PARSE_BLOCK_MAPPING_VALUE_STATE,
YAML_PARSE_BLOCK_NODE_OR_INDENTLESS_SEQUENCE_STATE, YAML_PARSE_BLOCK_NODE_STATE,
YAML_PARSE_BLOCK_SEQUENCE_ENTRY_STATE, YAML_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE,
YAML_PARSE_DOCUMENT_CONTENT_STATE, YAML_PARSE_DOCUMENT_END_STATE,
YAML_PARSE_DOCUMENT_START_STATE, YAML_PARSE_END_STATE,
YAML_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE, YAML_PARSE_FLOW_MAPPING_FIRST_KEY_STATE,
YAML_PARSE_FLOW_MAPPING_KEY_STATE, YAML_PARSE_FLOW_MAPPING_VALUE_STATE,
YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE,
YAML_PARSE_FLOW_NODE_STATE, YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE,
YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE,
YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE, YAML_PARSE_FLOW_SEQUENCE_ENTRY_STATE,
YAML_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE, YAML_PARSE_IMPLICIT_DOCUMENT_START_STATE,
YAML_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE, YAML_PLAIN_SCALAR_STYLE, YAML_SCALAR_EVENT,
YAML_SCALAR_TOKEN, YAML_SEQUENCE_END_EVENT, YAML_SEQUENCE_START_EVENT, YAML_STREAM_END_EVENT,
YAML_STREAM_END_TOKEN, YAML_STREAM_START_EVENT, YAML_STREAM_START_TOKEN,
YAML_TAG_DIRECTIVE_TOKEN, YAML_TAG_TOKEN, YAML_VALUE_TOKEN, YAML_VERSION_DIRECTIVE_TOKEN,
YAML_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE, YAML_PARSE_STREAM_START_STATE,
YAML_PLAIN_SCALAR_STYLE, YAML_SCALAR_EVENT, YAML_SCALAR_TOKEN, YAML_SEQUENCE_END_EVENT,
YAML_SEQUENCE_START_EVENT, YAML_STREAM_END_EVENT, YAML_STREAM_END_TOKEN,
YAML_STREAM_START_EVENT, YAML_STREAM_START_TOKEN, YAML_TAG_DIRECTIVE_TOKEN, YAML_TAG_TOKEN,
YAML_VALUE_TOKEN, YAML_VERSION_DIRECTIVE_TOKEN,
};
use core::mem::size_of;
use core::ptr::{self, addr_of_mut};
@ -44,8 +46,7 @@ unsafe fn SKIP_TOKEN(parser: *mut yaml_parser_t) {
(*parser).token_available = false;
let fresh3 = addr_of_mut!((*parser).tokens_parsed);
*fresh3 = (*fresh3).wrapping_add(1);
(*parser).stream_end_produced = (*(*parser).tokens.head).type_ as libc::c_uint
== YAML_STREAM_END_TOKEN as libc::c_int as libc::c_uint;
(*parser).stream_end_produced = (*(*parser).tokens.head).type_ == YAML_STREAM_END_TOKEN;
let fresh4 = addr_of_mut!((*parser).tokens.head);
*fresh4 = (*fresh4).wrapping_offset(1);
}
@ -71,8 +72,8 @@ pub unsafe fn yaml_parser_parse(parser: *mut yaml_parser_t, event: *mut yaml_eve
size_of::<yaml_event_t>() as libc::c_ulong,
);
if (*parser).stream_end_produced
|| (*parser).error as libc::c_uint != 0
|| (*parser).state as libc::c_uint == YAML_PARSE_END_STATE as libc::c_int as libc::c_uint
|| (*parser).error != YAML_NO_ERROR
|| (*parser).state == YAML_PARSE_END_STATE
{
return OK;
}
@ -110,46 +111,70 @@ unsafe fn yaml_parser_state_machine(
parser: *mut yaml_parser_t,
event: *mut yaml_event_t,
) -> Success {
match (*parser).state as libc::c_uint {
0 => return yaml_parser_parse_stream_start(parser, event),
1 => return yaml_parser_parse_document_start(parser, event, true),
2 => return yaml_parser_parse_document_start(parser, event, false),
3 => return yaml_parser_parse_document_content(parser, event),
4 => return yaml_parser_parse_document_end(parser, event),
5 => {
match (*parser).state {
YAML_PARSE_STREAM_START_STATE => return yaml_parser_parse_stream_start(parser, event),
YAML_PARSE_IMPLICIT_DOCUMENT_START_STATE => {
return yaml_parser_parse_document_start(parser, event, true)
}
YAML_PARSE_DOCUMENT_START_STATE => {
return yaml_parser_parse_document_start(parser, event, false)
}
YAML_PARSE_DOCUMENT_CONTENT_STATE => {
return yaml_parser_parse_document_content(parser, event)
}
YAML_PARSE_DOCUMENT_END_STATE => return yaml_parser_parse_document_end(parser, event),
YAML_PARSE_BLOCK_NODE_STATE => {
return yaml_parser_parse_node(parser, event, true, false);
}
6 => {
YAML_PARSE_BLOCK_NODE_OR_INDENTLESS_SEQUENCE_STATE => {
return yaml_parser_parse_node(parser, event, true, true);
}
7 => {
YAML_PARSE_FLOW_NODE_STATE => {
return yaml_parser_parse_node(parser, event, false, false);
}
8 => {
YAML_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE => {
return yaml_parser_parse_block_sequence_entry(parser, event, true);
}
9 => {
YAML_PARSE_BLOCK_SEQUENCE_ENTRY_STATE => {
return yaml_parser_parse_block_sequence_entry(parser, event, false);
}
10 => return yaml_parser_parse_indentless_sequence_entry(parser, event),
11 => return yaml_parser_parse_block_mapping_key(parser, event, true),
12 => return yaml_parser_parse_block_mapping_key(parser, event, false),
13 => return yaml_parser_parse_block_mapping_value(parser, event),
14 => {
YAML_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE => {
return yaml_parser_parse_indentless_sequence_entry(parser, event)
}
YAML_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE => {
return yaml_parser_parse_block_mapping_key(parser, event, true)
}
YAML_PARSE_BLOCK_MAPPING_KEY_STATE => {
return yaml_parser_parse_block_mapping_key(parser, event, false)
}
YAML_PARSE_BLOCK_MAPPING_VALUE_STATE => {
return yaml_parser_parse_block_mapping_value(parser, event)
}
YAML_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE => {
return yaml_parser_parse_flow_sequence_entry(parser, event, true);
}
15 => {
YAML_PARSE_FLOW_SEQUENCE_ENTRY_STATE => {
return yaml_parser_parse_flow_sequence_entry(parser, event, false);
}
16 => return yaml_parser_parse_flow_sequence_entry_mapping_key(parser, event),
17 => return yaml_parser_parse_flow_sequence_entry_mapping_value(parser, event),
18 => return yaml_parser_parse_flow_sequence_entry_mapping_end(parser, event),
19 => return yaml_parser_parse_flow_mapping_key(parser, event, true),
20 => return yaml_parser_parse_flow_mapping_key(parser, event, false),
21 => {
YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE => {
return yaml_parser_parse_flow_sequence_entry_mapping_key(parser, event)
}
YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE => {
return yaml_parser_parse_flow_sequence_entry_mapping_value(parser, event)
}
YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE => {
return yaml_parser_parse_flow_sequence_entry_mapping_end(parser, event)
}
YAML_PARSE_FLOW_MAPPING_FIRST_KEY_STATE => {
return yaml_parser_parse_flow_mapping_key(parser, event, true)
}
YAML_PARSE_FLOW_MAPPING_KEY_STATE => {
return yaml_parser_parse_flow_mapping_key(parser, event, false)
}
YAML_PARSE_FLOW_MAPPING_VALUE_STATE => {
return yaml_parser_parse_flow_mapping_value(parser, event, false);
}
22 => {
YAML_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE => {
return yaml_parser_parse_flow_mapping_value(parser, event, true);
}
_ => {}
@ -165,7 +190,7 @@ unsafe fn yaml_parser_parse_stream_start(
if token.is_null() {
return FAIL;
}
if (*token).type_ as libc::c_uint != YAML_STREAM_START_TOKEN as libc::c_int as libc::c_uint {
if (*token).type_ != YAML_STREAM_START_TOKEN {
yaml_parser_set_parser_error(
parser,
b"did not find expected <stream-start>\0" as *const u8 as *const libc::c_char,
@ -208,9 +233,7 @@ unsafe fn yaml_parser_parse_document_start(
return FAIL;
}
if !implicit {
while (*token).type_ as libc::c_uint
== YAML_DOCUMENT_END_TOKEN as libc::c_int as libc::c_uint
{
while (*token).type_ == YAML_DOCUMENT_END_TOKEN {
SKIP_TOKEN(parser);
token = PEEK_TOKEN(parser);
if token.is_null() {
@ -219,12 +242,10 @@ unsafe fn yaml_parser_parse_document_start(
}
}
if implicit
&& (*token).type_ as libc::c_uint
!= YAML_VERSION_DIRECTIVE_TOKEN as libc::c_int as libc::c_uint
&& (*token).type_ as libc::c_uint != YAML_TAG_DIRECTIVE_TOKEN as libc::c_int as libc::c_uint
&& (*token).type_ as libc::c_uint
!= YAML_DOCUMENT_START_TOKEN as libc::c_int as libc::c_uint
&& (*token).type_ as libc::c_uint != YAML_STREAM_END_TOKEN as libc::c_int as libc::c_uint
&& (*token).type_ != YAML_VERSION_DIRECTIVE_TOKEN
&& (*token).type_ != YAML_TAG_DIRECTIVE_TOKEN
&& (*token).type_ != YAML_DOCUMENT_START_TOKEN
&& (*token).type_ != YAML_STREAM_END_TOKEN
{
if yaml_parser_process_directives(
parser,
@ -256,8 +277,7 @@ unsafe fn yaml_parser_parse_document_start(
*fresh11 = ptr::null_mut::<yaml_tag_directive_t>();
(*event).data.document_start.implicit = true;
OK
} else if (*token).type_ as libc::c_uint != YAML_STREAM_END_TOKEN as libc::c_int as libc::c_uint
{
} else if (*token).type_ != YAML_STREAM_END_TOKEN {
let end_mark: yaml_mark_t;
let start_mark: yaml_mark_t = (*token).start_mark;
if yaml_parser_process_directives(
@ -272,9 +292,7 @@ unsafe fn yaml_parser_parse_document_start(
}
token = PEEK_TOKEN(parser);
if !token.is_null() {
if (*token).type_ as libc::c_uint
!= YAML_DOCUMENT_START_TOKEN as libc::c_int as libc::c_uint
{
if (*token).type_ != YAML_DOCUMENT_START_TOKEN {
yaml_parser_set_parser_error(
parser,
b"did not find expected <document start>\0" as *const u8 as *const libc::c_char,
@ -335,12 +353,11 @@ unsafe fn yaml_parser_parse_document_content(
if token.is_null() {
return FAIL;
}
if (*token).type_ as libc::c_uint == YAML_VERSION_DIRECTIVE_TOKEN as libc::c_int as libc::c_uint
|| (*token).type_ as libc::c_uint == YAML_TAG_DIRECTIVE_TOKEN as libc::c_int as libc::c_uint
|| (*token).type_ as libc::c_uint
== YAML_DOCUMENT_START_TOKEN as libc::c_int as libc::c_uint
|| (*token).type_ as libc::c_uint == YAML_DOCUMENT_END_TOKEN as libc::c_int as libc::c_uint
|| (*token).type_ as libc::c_uint == YAML_STREAM_END_TOKEN as libc::c_int as libc::c_uint
if (*token).type_ == YAML_VERSION_DIRECTIVE_TOKEN
|| (*token).type_ == YAML_TAG_DIRECTIVE_TOKEN
|| (*token).type_ == YAML_DOCUMENT_START_TOKEN
|| (*token).type_ == YAML_DOCUMENT_END_TOKEN
|| (*token).type_ == YAML_STREAM_END_TOKEN
{
(*parser).state = POP!((*parser).states);
yaml_parser_process_empty_scalar(parser, event, (*token).start_mark)
@ -361,7 +378,7 @@ unsafe fn yaml_parser_parse_document_end(
}
end_mark = (*token).start_mark;
let start_mark: yaml_mark_t = end_mark;
if (*token).type_ as libc::c_uint == YAML_DOCUMENT_END_TOKEN as libc::c_int as libc::c_uint {
if (*token).type_ == YAML_DOCUMENT_END_TOKEN {
end_mark = (*token).end_mark;
SKIP_TOKEN(parser);
implicit = false;
@ -408,7 +425,7 @@ unsafe fn yaml_parser_parse_node(
if token.is_null() {
return FAIL;
}
if (*token).type_ as libc::c_uint == YAML_ALIAS_TOKEN as libc::c_int as libc::c_uint {
if (*token).type_ == YAML_ALIAS_TOKEN {
(*parser).state = POP!((*parser).states);
memset(
event as *mut libc::c_void,
@ -425,7 +442,7 @@ unsafe fn yaml_parser_parse_node(
} else {
end_mark = (*token).start_mark;
start_mark = end_mark;
if (*token).type_ as libc::c_uint == YAML_ANCHOR_TOKEN as libc::c_int as libc::c_uint {
if (*token).type_ == YAML_ANCHOR_TOKEN {
anchor = (*token).data.anchor.value;
start_mark = (*token).start_mark;
end_mark = (*token).end_mark;
@ -433,9 +450,7 @@ unsafe fn yaml_parser_parse_node(
token = PEEK_TOKEN(parser);
if token.is_null() {
current_block = 17786380918591080555;
} else if (*token).type_ as libc::c_uint
== YAML_TAG_TOKEN as libc::c_int as libc::c_uint
{
} else if (*token).type_ == YAML_TAG_TOKEN {
tag_handle = (*token).data.tag.handle;
tag_suffix = (*token).data.tag.suffix;
tag_mark = (*token).start_mark;
@ -450,7 +465,7 @@ unsafe fn yaml_parser_parse_node(
} else {
current_block = 11743904203796629665;
}
} else if (*token).type_ as libc::c_uint == YAML_TAG_TOKEN as libc::c_int as libc::c_uint {
} else if (*token).type_ == YAML_TAG_TOKEN {
tag_handle = (*token).data.tag.handle;
tag_suffix = (*token).data.tag.suffix;
tag_mark = (*token).start_mark;
@ -460,9 +475,7 @@ unsafe fn yaml_parser_parse_node(
token = PEEK_TOKEN(parser);
if token.is_null() {
current_block = 17786380918591080555;
} else if (*token).type_ as libc::c_uint
== YAML_ANCHOR_TOKEN as libc::c_int as libc::c_uint
{
} else if (*token).type_ == YAML_ANCHOR_TOKEN {
anchor = (*token).data.anchor.value;
end_mark = (*token).end_mark;
SKIP_TOKEN(parser);
@ -563,10 +576,7 @@ unsafe fn yaml_parser_parse_node(
17786380918591080555 => {}
_ => {
implicit = tag.is_null() || *tag == 0;
if indentless_sequence
&& (*token).type_ as libc::c_uint
== YAML_BLOCK_ENTRY_TOKEN as libc::c_int as libc::c_uint
{
if indentless_sequence && (*token).type_ == YAML_BLOCK_ENTRY_TOKEN {
end_mark = (*token).end_mark;
(*parser).state = YAML_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE;
memset(
@ -584,14 +594,11 @@ unsafe fn yaml_parser_parse_node(
(*event).data.sequence_start.implicit = implicit;
(*event).data.sequence_start.style = YAML_BLOCK_SEQUENCE_STYLE;
return OK;
} else if (*token).type_ as libc::c_uint
== YAML_SCALAR_TOKEN as libc::c_int as libc::c_uint
{
} else if (*token).type_ == YAML_SCALAR_TOKEN {
let mut plain_implicit = false;
let mut quoted_implicit = false;
end_mark = (*token).end_mark;
if (*token).data.scalar.style as libc::c_uint
== YAML_PLAIN_SCALAR_STYLE as libc::c_int as libc::c_uint
if (*token).data.scalar.style == YAML_PLAIN_SCALAR_STYLE
&& tag.is_null()
|| !tag.is_null()
&& strcmp(
@ -624,9 +631,7 @@ unsafe fn yaml_parser_parse_node(
(*event).data.scalar.style = (*token).data.scalar.style;
SKIP_TOKEN(parser);
return OK;
} else if (*token).type_ as libc::c_uint
== YAML_FLOW_SEQUENCE_START_TOKEN as libc::c_int as libc::c_uint
{
} else if (*token).type_ == YAML_FLOW_SEQUENCE_START_TOKEN {
end_mark = (*token).end_mark;
(*parser).state = YAML_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE;
memset(
@ -644,9 +649,7 @@ unsafe fn yaml_parser_parse_node(
(*event).data.sequence_start.implicit = implicit;
(*event).data.sequence_start.style = YAML_FLOW_SEQUENCE_STYLE;
return OK;
} else if (*token).type_ as libc::c_uint
== YAML_FLOW_MAPPING_START_TOKEN as libc::c_int as libc::c_uint
{
} else if (*token).type_ == YAML_FLOW_MAPPING_START_TOKEN {
end_mark = (*token).end_mark;
(*parser).state = YAML_PARSE_FLOW_MAPPING_FIRST_KEY_STATE;
memset(
@ -664,10 +667,7 @@ unsafe fn yaml_parser_parse_node(
(*event).data.mapping_start.implicit = implicit;
(*event).data.mapping_start.style = YAML_FLOW_MAPPING_STYLE;
return OK;
} else if block
&& (*token).type_ as libc::c_uint
== YAML_BLOCK_SEQUENCE_START_TOKEN as libc::c_int as libc::c_uint
{
} else if block && (*token).type_ == YAML_BLOCK_SEQUENCE_START_TOKEN {
end_mark = (*token).end_mark;
(*parser).state = YAML_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE;
memset(
@ -685,10 +685,7 @@ unsafe fn yaml_parser_parse_node(
(*event).data.sequence_start.implicit = implicit;
(*event).data.sequence_start.style = YAML_BLOCK_SEQUENCE_STYLE;
return OK;
} else if block
&& (*token).type_ as libc::c_uint
== YAML_BLOCK_MAPPING_START_TOKEN as libc::c_int as libc::c_uint
{
} else if block && (*token).type_ == YAML_BLOCK_MAPPING_START_TOKEN {
end_mark = (*token).end_mark;
(*parser).state = YAML_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE;
memset(
@ -779,16 +776,14 @@ unsafe fn yaml_parser_parse_block_sequence_entry(
if token.is_null() {
return FAIL;
}
if (*token).type_ as libc::c_uint == YAML_BLOCK_ENTRY_TOKEN as libc::c_int as libc::c_uint {
if (*token).type_ == YAML_BLOCK_ENTRY_TOKEN {
let mark: yaml_mark_t = (*token).end_mark;
SKIP_TOKEN(parser);
token = PEEK_TOKEN(parser);
if token.is_null() {
return FAIL;
}
if (*token).type_ as libc::c_uint != YAML_BLOCK_ENTRY_TOKEN as libc::c_int as libc::c_uint
&& (*token).type_ as libc::c_uint != YAML_BLOCK_END_TOKEN as libc::c_int as libc::c_uint
{
if (*token).type_ != YAML_BLOCK_ENTRY_TOKEN && (*token).type_ != YAML_BLOCK_END_TOKEN {
if PUSH!(
parser,
(*parser).states,
@ -803,8 +798,7 @@ unsafe fn yaml_parser_parse_block_sequence_entry(
(*parser).state = YAML_PARSE_BLOCK_SEQUENCE_ENTRY_STATE;
yaml_parser_process_empty_scalar(parser, event, mark)
}
} else if (*token).type_ as libc::c_uint == YAML_BLOCK_END_TOKEN as libc::c_int as libc::c_uint
{
} else if (*token).type_ == YAML_BLOCK_END_TOKEN {
(*parser).state = POP!((*parser).states);
let _ = POP!((*parser).marks);
memset(
@ -838,17 +832,17 @@ unsafe fn yaml_parser_parse_indentless_sequence_entry(
if token.is_null() {
return FAIL;
}
if (*token).type_ as libc::c_uint == YAML_BLOCK_ENTRY_TOKEN as libc::c_int as libc::c_uint {
if (*token).type_ == YAML_BLOCK_ENTRY_TOKEN {
let mark: yaml_mark_t = (*token).end_mark;
SKIP_TOKEN(parser);
token = PEEK_TOKEN(parser);
if token.is_null() {
return FAIL;
}
if (*token).type_ as libc::c_uint != YAML_BLOCK_ENTRY_TOKEN as libc::c_int as libc::c_uint
&& (*token).type_ as libc::c_uint != YAML_KEY_TOKEN as libc::c_int as libc::c_uint
&& (*token).type_ as libc::c_uint != YAML_VALUE_TOKEN as libc::c_int as libc::c_uint
&& (*token).type_ as libc::c_uint != YAML_BLOCK_END_TOKEN as libc::c_int as libc::c_uint
if (*token).type_ != YAML_BLOCK_ENTRY_TOKEN
&& (*token).type_ != YAML_KEY_TOKEN
&& (*token).type_ != YAML_VALUE_TOKEN
&& (*token).type_ != YAML_BLOCK_END_TOKEN
{
if PUSH!(
parser,
@ -895,16 +889,16 @@ unsafe fn yaml_parser_parse_block_mapping_key(
if token.is_null() {
return FAIL;
}
if (*token).type_ as libc::c_uint == YAML_KEY_TOKEN as libc::c_int as libc::c_uint {
if (*token).type_ == YAML_KEY_TOKEN {
let mark: yaml_mark_t = (*token).end_mark;
SKIP_TOKEN(parser);
token = PEEK_TOKEN(parser);
if token.is_null() {
return FAIL;
}
if (*token).type_ as libc::c_uint != YAML_KEY_TOKEN as libc::c_int as libc::c_uint
&& (*token).type_ as libc::c_uint != YAML_VALUE_TOKEN as libc::c_int as libc::c_uint
&& (*token).type_ as libc::c_uint != YAML_BLOCK_END_TOKEN as libc::c_int as libc::c_uint
if (*token).type_ != YAML_KEY_TOKEN
&& (*token).type_ != YAML_VALUE_TOKEN
&& (*token).type_ != YAML_BLOCK_END_TOKEN
{
if PUSH!(
parser,
@ -920,8 +914,7 @@ unsafe fn yaml_parser_parse_block_mapping_key(
(*parser).state = YAML_PARSE_BLOCK_MAPPING_VALUE_STATE;
yaml_parser_process_empty_scalar(parser, event, mark)
}
} else if (*token).type_ as libc::c_uint == YAML_BLOCK_END_TOKEN as libc::c_int as libc::c_uint
{
} else if (*token).type_ == YAML_BLOCK_END_TOKEN {
(*parser).state = POP!((*parser).states);
let _ = POP!((*parser).marks);
memset(
@ -955,16 +948,16 @@ unsafe fn yaml_parser_parse_block_mapping_value(
if token.is_null() {
return FAIL;
}
if (*token).type_ as libc::c_uint == YAML_VALUE_TOKEN as libc::c_int as libc::c_uint {
if (*token).type_ == YAML_VALUE_TOKEN {
let mark: yaml_mark_t = (*token).end_mark;
SKIP_TOKEN(parser);
token = PEEK_TOKEN(parser);
if token.is_null() {
return FAIL;
}
if (*token).type_ as libc::c_uint != YAML_KEY_TOKEN as libc::c_int as libc::c_uint
&& (*token).type_ as libc::c_uint != YAML_VALUE_TOKEN as libc::c_int as libc::c_uint
&& (*token).type_ as libc::c_uint != YAML_BLOCK_END_TOKEN as libc::c_int as libc::c_uint
if (*token).type_ != YAML_KEY_TOKEN
&& (*token).type_ != YAML_VALUE_TOKEN
&& (*token).type_ != YAML_BLOCK_END_TOKEN
{
if PUSH!(parser, (*parser).states, YAML_PARSE_BLOCK_MAPPING_KEY_STATE).fail {
return FAIL;
@ -997,12 +990,9 @@ unsafe fn yaml_parser_parse_flow_sequence_entry(
if token.is_null() {
return FAIL;
}
if (*token).type_ as libc::c_uint != YAML_FLOW_SEQUENCE_END_TOKEN as libc::c_int as libc::c_uint
{
if (*token).type_ != YAML_FLOW_SEQUENCE_END_TOKEN {
if !first {
if (*token).type_ as libc::c_uint
== YAML_FLOW_ENTRY_TOKEN as libc::c_int as libc::c_uint
{
if (*token).type_ == YAML_FLOW_ENTRY_TOKEN {
SKIP_TOKEN(parser);
token = PEEK_TOKEN(parser);
if token.is_null() {
@ -1019,7 +1009,7 @@ unsafe fn yaml_parser_parse_flow_sequence_entry(
return FAIL;
}
}
if (*token).type_ as libc::c_uint == YAML_KEY_TOKEN as libc::c_int as libc::c_uint {
if (*token).type_ == YAML_KEY_TOKEN {
(*parser).state = YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE;
memset(
event as *mut libc::c_void,
@ -1037,9 +1027,7 @@ unsafe fn yaml_parser_parse_flow_sequence_entry(
(*event).data.mapping_start.style = YAML_FLOW_MAPPING_STYLE;
SKIP_TOKEN(parser);
return OK;
} else if (*token).type_ as libc::c_uint
!= YAML_FLOW_SEQUENCE_END_TOKEN as libc::c_int as libc::c_uint
{
} else if (*token).type_ != YAML_FLOW_SEQUENCE_END_TOKEN {
if PUSH!(
parser,
(*parser).states,
@ -1074,10 +1062,9 @@ unsafe fn yaml_parser_parse_flow_sequence_entry_mapping_key(
if token.is_null() {
return FAIL;
}
if (*token).type_ as libc::c_uint != YAML_VALUE_TOKEN as libc::c_int as libc::c_uint
&& (*token).type_ as libc::c_uint != YAML_FLOW_ENTRY_TOKEN as libc::c_int as libc::c_uint
&& (*token).type_ as libc::c_uint
!= YAML_FLOW_SEQUENCE_END_TOKEN as libc::c_int as libc::c_uint
if (*token).type_ != YAML_VALUE_TOKEN
&& (*token).type_ != YAML_FLOW_ENTRY_TOKEN
&& (*token).type_ != YAML_FLOW_SEQUENCE_END_TOKEN
{
if PUSH!(
parser,
@ -1106,15 +1093,13 @@ unsafe fn yaml_parser_parse_flow_sequence_entry_mapping_value(
if token.is_null() {
return FAIL;
}
if (*token).type_ as libc::c_uint == YAML_VALUE_TOKEN as libc::c_int as libc::c_uint {
if (*token).type_ == YAML_VALUE_TOKEN {
SKIP_TOKEN(parser);
token = PEEK_TOKEN(parser);
if token.is_null() {
return FAIL;
}
if (*token).type_ as libc::c_uint != YAML_FLOW_ENTRY_TOKEN as libc::c_int as libc::c_uint
&& (*token).type_ as libc::c_uint
!= YAML_FLOW_SEQUENCE_END_TOKEN as libc::c_int as libc::c_uint
if (*token).type_ != YAML_FLOW_ENTRY_TOKEN && (*token).type_ != YAML_FLOW_SEQUENCE_END_TOKEN
{
if PUSH!(
parser,
@ -1169,12 +1154,9 @@ unsafe fn yaml_parser_parse_flow_mapping_key(
if token.is_null() {
return FAIL;
}
if (*token).type_ as libc::c_uint != YAML_FLOW_MAPPING_END_TOKEN as libc::c_int as libc::c_uint
{
if (*token).type_ != YAML_FLOW_MAPPING_END_TOKEN {
if !first {
if (*token).type_ as libc::c_uint
== YAML_FLOW_ENTRY_TOKEN as libc::c_int as libc::c_uint
{
if (*token).type_ == YAML_FLOW_ENTRY_TOKEN {
SKIP_TOKEN(parser);
token = PEEK_TOKEN(parser);
if token.is_null() {
@ -1191,17 +1173,15 @@ unsafe fn yaml_parser_parse_flow_mapping_key(
return FAIL;
}
}
if (*token).type_ as libc::c_uint == YAML_KEY_TOKEN as libc::c_int as libc::c_uint {
if (*token).type_ == YAML_KEY_TOKEN {
SKIP_TOKEN(parser);
token = PEEK_TOKEN(parser);
if token.is_null() {
return FAIL;
}
if (*token).type_ as libc::c_uint != YAML_VALUE_TOKEN as libc::c_int as libc::c_uint
&& (*token).type_ as libc::c_uint
!= YAML_FLOW_ENTRY_TOKEN as libc::c_int as libc::c_uint
&& (*token).type_ as libc::c_uint
!= YAML_FLOW_MAPPING_END_TOKEN as libc::c_int as libc::c_uint
if (*token).type_ != YAML_VALUE_TOKEN
&& (*token).type_ != YAML_FLOW_ENTRY_TOKEN
&& (*token).type_ != YAML_FLOW_MAPPING_END_TOKEN
{
if PUSH!(
parser,
@ -1217,9 +1197,7 @@ unsafe fn yaml_parser_parse_flow_mapping_key(
(*parser).state = YAML_PARSE_FLOW_MAPPING_VALUE_STATE;
return yaml_parser_process_empty_scalar(parser, event, (*token).start_mark);
}
} else if (*token).type_ as libc::c_uint
!= YAML_FLOW_MAPPING_END_TOKEN as libc::c_int as libc::c_uint
{
} else if (*token).type_ != YAML_FLOW_MAPPING_END_TOKEN {
if PUSH!(
parser,
(*parser).states,
@ -1260,15 +1238,13 @@ unsafe fn yaml_parser_parse_flow_mapping_value(
(*parser).state = YAML_PARSE_FLOW_MAPPING_KEY_STATE;
return yaml_parser_process_empty_scalar(parser, event, (*token).start_mark);
}
if (*token).type_ as libc::c_uint == YAML_VALUE_TOKEN as libc::c_int as libc::c_uint {
if (*token).type_ == YAML_VALUE_TOKEN {
SKIP_TOKEN(parser);
token = PEEK_TOKEN(parser);
if token.is_null() {
return FAIL;
}
if (*token).type_ as libc::c_uint != YAML_FLOW_ENTRY_TOKEN as libc::c_int as libc::c_uint
&& (*token).type_ as libc::c_uint
!= YAML_FLOW_MAPPING_END_TOKEN as libc::c_int as libc::c_uint
if (*token).type_ != YAML_FLOW_ENTRY_TOKEN && (*token).type_ != YAML_FLOW_MAPPING_END_TOKEN
{
if PUSH!(parser, (*parser).states, YAML_PARSE_FLOW_MAPPING_KEY_STATE).fail {
return FAIL;
@ -1351,17 +1327,13 @@ unsafe fn yaml_parser_process_directives(
token = PEEK_TOKEN(parser);
if !token.is_null() {
loop {
if !((*token).type_ as libc::c_uint
== YAML_VERSION_DIRECTIVE_TOKEN as libc::c_int as libc::c_uint
|| (*token).type_ as libc::c_uint
== YAML_TAG_DIRECTIVE_TOKEN as libc::c_int as libc::c_uint)
if !((*token).type_ == YAML_VERSION_DIRECTIVE_TOKEN
|| (*token).type_ == YAML_TAG_DIRECTIVE_TOKEN)
{
current_block = 16924917904204750491;
break;
}
if (*token).type_ as libc::c_uint
== YAML_VERSION_DIRECTIVE_TOKEN as libc::c_int as libc::c_uint
{
if (*token).type_ == YAML_VERSION_DIRECTIVE_TOKEN {
if !version_directive.is_null() {
yaml_parser_set_parser_error(
parser,
@ -1396,9 +1368,7 @@ unsafe fn yaml_parser_process_directives(
(*version_directive).minor = (*token).data.version_directive.minor;
}
}
} else if (*token).type_ as libc::c_uint
== YAML_TAG_DIRECTIVE_TOKEN as libc::c_int as libc::c_uint
{
} else if (*token).type_ == YAML_TAG_DIRECTIVE_TOKEN {
let value = yaml_tag_directive_t {
handle: (*token).data.tag_directive.handle,
prefix: (*token).data.tag_directive.prefix,

View file

@ -2,7 +2,7 @@ use crate::externs::{memcmp, memmove};
use crate::success::{Success, FAIL, OK};
use crate::yaml::{size_t, yaml_char_t};
use crate::{
libc, yaml_parser_t, PointerExt, YAML_READER_ERROR, YAML_UTF16BE_ENCODING,
libc, yaml_parser_t, PointerExt, YAML_ANY_ENCODING, YAML_READER_ERROR, YAML_UTF16BE_ENCODING,
YAML_UTF16LE_ENCODING, YAML_UTF8_ENCODING,
};
use core::ptr::addr_of_mut;
@ -160,7 +160,7 @@ pub(crate) unsafe fn yaml_parser_update_buffer(
if (*parser).unread >= length {
return OK;
}
if (*parser).encoding as u64 == 0 {
if (*parser).encoding == YAML_ANY_ENCODING {
if yaml_parser_determine_encoding(parser).fail {
return FAIL;
}
@ -209,8 +209,8 @@ pub(crate) unsafe fn yaml_parser_update_buffer(
.last
.c_offset_from((*parser).raw_buffer.pointer)
as libc::c_long as size_t;
match (*parser).encoding as libc::c_uint {
1 => {
match (*parser).encoding {
YAML_UTF8_ENCODING => {
octet = *(*parser).raw_buffer.pointer;
width = if octet as libc::c_int & 0x80 == 0 {
1
@ -293,17 +293,13 @@ pub(crate) unsafe fn yaml_parser_update_buffer(
}
}
}
2 | 3 => {
low = if (*parser).encoding as libc::c_uint
== YAML_UTF16LE_ENCODING as libc::c_int as libc::c_uint
{
YAML_UTF16LE_ENCODING | YAML_UTF16BE_ENCODING => {
low = if (*parser).encoding == YAML_UTF16LE_ENCODING {
0
} else {
1
};
high = if (*parser).encoding as libc::c_uint
== YAML_UTF16LE_ENCODING as libc::c_int as libc::c_uint
{
high = if (*parser).encoding == YAML_UTF16LE_ENCODING {
1
} else {
0

View file

@ -13,10 +13,10 @@ use crate::{
YAML_DOCUMENT_END_TOKEN, YAML_DOCUMENT_START_TOKEN, YAML_DOUBLE_QUOTED_SCALAR_STYLE,
YAML_FLOW_ENTRY_TOKEN, YAML_FLOW_MAPPING_END_TOKEN, YAML_FLOW_MAPPING_START_TOKEN,
YAML_FLOW_SEQUENCE_END_TOKEN, YAML_FLOW_SEQUENCE_START_TOKEN, YAML_FOLDED_SCALAR_STYLE,
YAML_KEY_TOKEN, YAML_LITERAL_SCALAR_STYLE, YAML_MEMORY_ERROR, YAML_PLAIN_SCALAR_STYLE,
YAML_SCALAR_TOKEN, YAML_SCANNER_ERROR, YAML_SINGLE_QUOTED_SCALAR_STYLE, YAML_STREAM_END_TOKEN,
YAML_STREAM_START_TOKEN, YAML_TAG_DIRECTIVE_TOKEN, YAML_TAG_TOKEN, YAML_VALUE_TOKEN,
YAML_VERSION_DIRECTIVE_TOKEN,
YAML_KEY_TOKEN, YAML_LITERAL_SCALAR_STYLE, YAML_MEMORY_ERROR, YAML_NO_ERROR,
YAML_PLAIN_SCALAR_STYLE, YAML_SCALAR_TOKEN, YAML_SCANNER_ERROR,
YAML_SINGLE_QUOTED_SCALAR_STYLE, YAML_STREAM_END_TOKEN, YAML_STREAM_START_TOKEN,
YAML_TAG_DIRECTIVE_TOKEN, YAML_TAG_TOKEN, YAML_VALUE_TOKEN, YAML_VERSION_DIRECTIVE_TOKEN,
};
use core::mem::{size_of, MaybeUninit};
use core::ptr::{self, addr_of_mut};
@ -153,7 +153,7 @@ pub unsafe fn yaml_parser_scan(
0,
size_of::<yaml_token_t>() as libc::c_ulong,
);
if (*parser).stream_end_produced || (*parser).error as libc::c_uint != 0 {
if (*parser).stream_end_produced || (*parser).error != YAML_NO_ERROR {
return OK;
}
if !(*parser).token_available {
@ -165,7 +165,7 @@ pub unsafe fn yaml_parser_scan(
(*parser).token_available = false;
let fresh2 = addr_of_mut!((*parser).tokens_parsed);
*fresh2 = (*fresh2).wrapping_add(1);
if (*token).type_ as libc::c_uint == YAML_STREAM_END_TOKEN as libc::c_int as libc::c_uint {
if (*token).type_ == YAML_STREAM_END_TOKEN {
(*parser).stream_end_produced = true;
}
OK
@ -1450,9 +1450,7 @@ unsafe fn yaml_parser_scan_anchor(
{
yaml_parser_set_scanner_error(
parser,
if type_ as libc::c_uint
== YAML_ANCHOR_TOKEN as libc::c_int as libc::c_uint
{
if type_ == YAML_ANCHOR_TOKEN {
b"while scanning an anchor\0" as *const u8 as *const libc::c_char
} else {
b"while scanning an alias\0" as *const u8 as *const libc::c_char
@ -1462,8 +1460,7 @@ unsafe fn yaml_parser_scan_anchor(
as *const libc::c_char,
);
} else {
if type_ as libc::c_uint == YAML_ANCHOR_TOKEN as libc::c_int as libc::c_uint
{
if type_ == YAML_ANCHOR_TOKEN {
memset(
token as *mut libc::c_void,
0,

View file

@ -1,7 +1,8 @@
use crate::success::{Success, FAIL, OK};
use crate::yaml::size_t;
use crate::{
libc, yaml_emitter_t, PointerExt, YAML_UTF16LE_ENCODING, YAML_UTF8_ENCODING, YAML_WRITER_ERROR,
libc, yaml_emitter_t, PointerExt, YAML_ANY_ENCODING, YAML_UTF16LE_ENCODING, YAML_UTF8_ENCODING,
YAML_WRITER_ERROR,
};
use core::ptr::addr_of_mut;
@ -19,7 +20,7 @@ unsafe fn yaml_emitter_set_writer_error(
pub unsafe fn yaml_emitter_flush(emitter: *mut yaml_emitter_t) -> Success {
__assert!(!emitter.is_null());
__assert!(((*emitter).write_handler).is_some());
__assert!((*emitter).encoding as u64 != 0);
__assert!((*emitter).encoding != YAML_ANY_ENCODING);
let fresh1 = addr_of_mut!((*emitter).buffer.last);
*fresh1 = (*emitter).buffer.pointer;
let fresh2 = addr_of_mut!((*emitter).buffer.pointer);
@ -27,7 +28,7 @@ pub unsafe fn yaml_emitter_flush(emitter: *mut yaml_emitter_t) -> Success {
if (*emitter).buffer.start == (*emitter).buffer.last {
return OK;
}
if (*emitter).encoding as libc::c_uint == YAML_UTF8_ENCODING as libc::c_int as libc::c_uint {
if (*emitter).encoding == YAML_UTF8_ENCODING {
if (*emitter).write_handler.expect("non-null function pointer")(
(*emitter).write_handler_data,
(*emitter).buffer.start,
@ -49,16 +50,12 @@ pub unsafe fn yaml_emitter_flush(emitter: *mut yaml_emitter_t) -> Success {
);
}
}
let low: libc::c_int = if (*emitter).encoding as libc::c_uint
== YAML_UTF16LE_ENCODING as libc::c_int as libc::c_uint
{
let low: libc::c_int = if (*emitter).encoding == YAML_UTF16LE_ENCODING {
0
} else {
1
};
let high: libc::c_int = if (*emitter).encoding as libc::c_uint
== YAML_UTF16LE_ENCODING as libc::c_int as libc::c_uint
{
let high: libc::c_int = if (*emitter).encoding == YAML_UTF16LE_ENCODING {
1
} else {
0