mirror of
https://github.com/simonask/libyaml-safer
synced 2025-02-16 20:38:30 +00:00
Eliminate return value of stack init
This commit is contained in:
parent
82fd332271
commit
e0a86e6089
4 changed files with 360 additions and 396 deletions
354
src/api.rs
354
src/api.rs
|
@ -185,17 +185,12 @@ pub unsafe fn yaml_parser_initialize(parser: *mut yaml_parser_t) -> Success {
|
||||||
BUFFER_INIT!(parser, (*parser).raw_buffer, INPUT_RAW_BUFFER_SIZE);
|
BUFFER_INIT!(parser, (*parser).raw_buffer, INPUT_RAW_BUFFER_SIZE);
|
||||||
BUFFER_INIT!(parser, (*parser).buffer, INPUT_BUFFER_SIZE);
|
BUFFER_INIT!(parser, (*parser).buffer, INPUT_BUFFER_SIZE);
|
||||||
if QUEUE_INIT!(parser, (*parser).tokens, yaml_token_t).ok {
|
if QUEUE_INIT!(parser, (*parser).tokens, yaml_token_t).ok {
|
||||||
if STACK_INIT!(parser, (*parser).indents, libc::c_int).ok {
|
STACK_INIT!(parser, (*parser).indents, libc::c_int);
|
||||||
if STACK_INIT!(parser, (*parser).simple_keys, yaml_simple_key_t).ok {
|
STACK_INIT!(parser, (*parser).simple_keys, yaml_simple_key_t);
|
||||||
if STACK_INIT!(parser, (*parser).states, yaml_parser_state_t).ok {
|
STACK_INIT!(parser, (*parser).states, yaml_parser_state_t);
|
||||||
if STACK_INIT!(parser, (*parser).marks, yaml_mark_t).ok {
|
STACK_INIT!(parser, (*parser).marks, yaml_mark_t);
|
||||||
if STACK_INIT!(parser, (*parser).tag_directives, yaml_tag_directive_t).ok {
|
STACK_INIT!(parser, (*parser).tag_directives, yaml_tag_directive_t);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
BUFFER_DEL!((*parser).raw_buffer);
|
BUFFER_DEL!((*parser).raw_buffer);
|
||||||
BUFFER_DEL!((*parser).buffer);
|
BUFFER_DEL!((*parser).buffer);
|
||||||
|
@ -331,14 +326,11 @@ pub unsafe fn yaml_emitter_initialize(mut emitter: *mut yaml_emitter_t) -> Succe
|
||||||
);
|
);
|
||||||
BUFFER_INIT!(emitter, (*emitter).buffer, OUTPUT_BUFFER_SIZE);
|
BUFFER_INIT!(emitter, (*emitter).buffer, OUTPUT_BUFFER_SIZE);
|
||||||
BUFFER_INIT!(emitter, (*emitter).raw_buffer, OUTPUT_RAW_BUFFER_SIZE);
|
BUFFER_INIT!(emitter, (*emitter).raw_buffer, OUTPUT_RAW_BUFFER_SIZE);
|
||||||
if STACK_INIT!(emitter, (*emitter).states, yaml_emitter_state_t).ok {
|
STACK_INIT!(emitter, (*emitter).states, yaml_emitter_state_t);
|
||||||
if QUEUE_INIT!(emitter, (*emitter).events, yaml_event_t).ok {
|
if QUEUE_INIT!(emitter, (*emitter).events, yaml_event_t).ok {
|
||||||
if STACK_INIT!(emitter, (*emitter).indents, libc::c_int).ok {
|
STACK_INIT!(emitter, (*emitter).indents, libc::c_int);
|
||||||
if STACK_INIT!(emitter, (*emitter).tag_directives, yaml_tag_directive_t).ok {
|
STACK_INIT!(emitter, (*emitter).tag_directives, yaml_tag_directive_t);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
BUFFER_DEL!((*emitter).buffer);
|
BUFFER_DEL!((*emitter).buffer);
|
||||||
BUFFER_DEL!((*emitter).raw_buffer);
|
BUFFER_DEL!((*emitter).raw_buffer);
|
||||||
|
@ -687,55 +679,50 @@ pub unsafe fn yaml_document_start_event_initialize(
|
||||||
1394248824506584008 => {
|
1394248824506584008 => {
|
||||||
if tag_directives_start != tag_directives_end {
|
if tag_directives_start != tag_directives_end {
|
||||||
let mut tag_directive: *mut yaml_tag_directive_t;
|
let mut tag_directive: *mut yaml_tag_directive_t;
|
||||||
if STACK_INIT!(
|
STACK_INIT!(
|
||||||
addr_of_mut!(context),
|
addr_of_mut!(context),
|
||||||
tag_directives_copy,
|
tag_directives_copy,
|
||||||
yaml_tag_directive_t
|
yaml_tag_directive_t
|
||||||
)
|
);
|
||||||
.fail
|
tag_directive = tag_directives_start;
|
||||||
{
|
loop {
|
||||||
current_block = 14964981520188694172;
|
if !(tag_directive != tag_directives_end) {
|
||||||
} else {
|
current_block = 16203760046146113240;
|
||||||
tag_directive = tag_directives_start;
|
break;
|
||||||
loop {
|
|
||||||
if !(tag_directive != tag_directives_end) {
|
|
||||||
current_block = 16203760046146113240;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
__assert!(!((*tag_directive).handle).is_null());
|
|
||||||
__assert!(!((*tag_directive).prefix).is_null());
|
|
||||||
if yaml_check_utf8(
|
|
||||||
(*tag_directive).handle,
|
|
||||||
strlen((*tag_directive).handle as *mut libc::c_char),
|
|
||||||
)
|
|
||||||
.fail
|
|
||||||
{
|
|
||||||
current_block = 14964981520188694172;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if yaml_check_utf8(
|
|
||||||
(*tag_directive).prefix,
|
|
||||||
strlen((*tag_directive).prefix as *mut libc::c_char),
|
|
||||||
)
|
|
||||||
.fail
|
|
||||||
{
|
|
||||||
current_block = 14964981520188694172;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
value.handle = yaml_strdup((*tag_directive).handle);
|
|
||||||
value.prefix = yaml_strdup((*tag_directive).prefix);
|
|
||||||
if value.handle.is_null() || value.prefix.is_null() {
|
|
||||||
current_block = 14964981520188694172;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if PUSH!(addr_of_mut!(context), tag_directives_copy, value).fail {
|
|
||||||
current_block = 14964981520188694172;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
value.handle = ptr::null_mut::<yaml_char_t>();
|
|
||||||
value.prefix = ptr::null_mut::<yaml_char_t>();
|
|
||||||
tag_directive = tag_directive.wrapping_offset(1);
|
|
||||||
}
|
}
|
||||||
|
__assert!(!((*tag_directive).handle).is_null());
|
||||||
|
__assert!(!((*tag_directive).prefix).is_null());
|
||||||
|
if yaml_check_utf8(
|
||||||
|
(*tag_directive).handle,
|
||||||
|
strlen((*tag_directive).handle as *mut libc::c_char),
|
||||||
|
)
|
||||||
|
.fail
|
||||||
|
{
|
||||||
|
current_block = 14964981520188694172;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if yaml_check_utf8(
|
||||||
|
(*tag_directive).prefix,
|
||||||
|
strlen((*tag_directive).prefix as *mut libc::c_char),
|
||||||
|
)
|
||||||
|
.fail
|
||||||
|
{
|
||||||
|
current_block = 14964981520188694172;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
value.handle = yaml_strdup((*tag_directive).handle);
|
||||||
|
value.prefix = yaml_strdup((*tag_directive).prefix);
|
||||||
|
if value.handle.is_null() || value.prefix.is_null() {
|
||||||
|
current_block = 14964981520188694172;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if PUSH!(addr_of_mut!(context), tag_directives_copy, value).fail {
|
||||||
|
current_block = 14964981520188694172;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
value.handle = ptr::null_mut::<yaml_char_t>();
|
||||||
|
value.prefix = ptr::null_mut::<yaml_char_t>();
|
||||||
|
tag_directive = tag_directive.wrapping_offset(1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
current_block = 16203760046146113240;
|
current_block = 16203760046146113240;
|
||||||
|
@ -1222,101 +1209,94 @@ pub unsafe fn yaml_document_initialize(
|
||||||
!tag_directives_start.is_null() && !tag_directives_end.is_null()
|
!tag_directives_start.is_null() && !tag_directives_end.is_null()
|
||||||
|| tag_directives_start == tag_directives_end
|
|| tag_directives_start == tag_directives_end
|
||||||
);
|
);
|
||||||
if STACK_INIT!(addr_of_mut!(context), nodes, yaml_node_t).ok {
|
STACK_INIT!(addr_of_mut!(context), nodes, yaml_node_t);
|
||||||
if !version_directive.is_null() {
|
if !version_directive.is_null() {
|
||||||
version_directive_copy =
|
version_directive_copy = yaml_malloc(size_of::<yaml_version_directive_t>() as libc::c_ulong)
|
||||||
yaml_malloc(size_of::<yaml_version_directive_t>() as libc::c_ulong)
|
as *mut yaml_version_directive_t;
|
||||||
as *mut yaml_version_directive_t;
|
(*version_directive_copy).major = (*version_directive).major;
|
||||||
(*version_directive_copy).major = (*version_directive).major;
|
(*version_directive_copy).minor = (*version_directive).minor;
|
||||||
(*version_directive_copy).minor = (*version_directive).minor;
|
current_block = 7746791466490516765;
|
||||||
current_block = 7746791466490516765;
|
} else {
|
||||||
} else {
|
current_block = 7746791466490516765;
|
||||||
current_block = 7746791466490516765;
|
}
|
||||||
}
|
match current_block {
|
||||||
match current_block {
|
8142820162064489797 => {}
|
||||||
8142820162064489797 => {}
|
_ => {
|
||||||
_ => {
|
if tag_directives_start != tag_directives_end {
|
||||||
if tag_directives_start != tag_directives_end {
|
let mut tag_directive: *mut yaml_tag_directive_t;
|
||||||
let mut tag_directive: *mut yaml_tag_directive_t;
|
STACK_INIT!(
|
||||||
if STACK_INIT!(
|
addr_of_mut!(context),
|
||||||
addr_of_mut!(context),
|
tag_directives_copy,
|
||||||
tag_directives_copy,
|
yaml_tag_directive_t
|
||||||
yaml_tag_directive_t
|
);
|
||||||
|
tag_directive = tag_directives_start;
|
||||||
|
loop {
|
||||||
|
if !(tag_directive != tag_directives_end) {
|
||||||
|
current_block = 14818589718467733107;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
__assert!(!((*tag_directive).handle).is_null());
|
||||||
|
__assert!(!((*tag_directive).prefix).is_null());
|
||||||
|
if yaml_check_utf8(
|
||||||
|
(*tag_directive).handle,
|
||||||
|
strlen((*tag_directive).handle as *mut libc::c_char),
|
||||||
)
|
)
|
||||||
.fail
|
.fail
|
||||||
{
|
{
|
||||||
current_block = 8142820162064489797;
|
current_block = 8142820162064489797;
|
||||||
} else {
|
break;
|
||||||
tag_directive = tag_directives_start;
|
|
||||||
loop {
|
|
||||||
if !(tag_directive != tag_directives_end) {
|
|
||||||
current_block = 14818589718467733107;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
__assert!(!((*tag_directive).handle).is_null());
|
|
||||||
__assert!(!((*tag_directive).prefix).is_null());
|
|
||||||
if yaml_check_utf8(
|
|
||||||
(*tag_directive).handle,
|
|
||||||
strlen((*tag_directive).handle as *mut libc::c_char),
|
|
||||||
)
|
|
||||||
.fail
|
|
||||||
{
|
|
||||||
current_block = 8142820162064489797;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if yaml_check_utf8(
|
|
||||||
(*tag_directive).prefix,
|
|
||||||
strlen((*tag_directive).prefix as *mut libc::c_char),
|
|
||||||
)
|
|
||||||
.fail
|
|
||||||
{
|
|
||||||
current_block = 8142820162064489797;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
value.handle = yaml_strdup((*tag_directive).handle);
|
|
||||||
value.prefix = yaml_strdup((*tag_directive).prefix);
|
|
||||||
if value.handle.is_null() || value.prefix.is_null() {
|
|
||||||
current_block = 8142820162064489797;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if PUSH!(addr_of_mut!(context), tag_directives_copy, value).fail {
|
|
||||||
current_block = 8142820162064489797;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
value.handle = ptr::null_mut::<yaml_char_t>();
|
|
||||||
value.prefix = ptr::null_mut::<yaml_char_t>();
|
|
||||||
tag_directive = tag_directive.wrapping_offset(1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
if yaml_check_utf8(
|
||||||
current_block = 14818589718467733107;
|
(*tag_directive).prefix,
|
||||||
|
strlen((*tag_directive).prefix as *mut libc::c_char),
|
||||||
|
)
|
||||||
|
.fail
|
||||||
|
{
|
||||||
|
current_block = 8142820162064489797;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
value.handle = yaml_strdup((*tag_directive).handle);
|
||||||
|
value.prefix = yaml_strdup((*tag_directive).prefix);
|
||||||
|
if value.handle.is_null() || value.prefix.is_null() {
|
||||||
|
current_block = 8142820162064489797;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if PUSH!(addr_of_mut!(context), tag_directives_copy, value).fail {
|
||||||
|
current_block = 8142820162064489797;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
value.handle = ptr::null_mut::<yaml_char_t>();
|
||||||
|
value.prefix = ptr::null_mut::<yaml_char_t>();
|
||||||
|
tag_directive = tag_directive.wrapping_offset(1);
|
||||||
}
|
}
|
||||||
match current_block {
|
} else {
|
||||||
8142820162064489797 => {}
|
current_block = 14818589718467733107;
|
||||||
_ => {
|
}
|
||||||
memset(
|
match current_block {
|
||||||
document as *mut libc::c_void,
|
8142820162064489797 => {}
|
||||||
0,
|
_ => {
|
||||||
size_of::<yaml_document_t>() as libc::c_ulong,
|
memset(
|
||||||
);
|
document as *mut libc::c_void,
|
||||||
let fresh176 = addr_of_mut!((*document).nodes.start);
|
0,
|
||||||
*fresh176 = nodes.start;
|
size_of::<yaml_document_t>() as libc::c_ulong,
|
||||||
let fresh177 = addr_of_mut!((*document).nodes.end);
|
);
|
||||||
*fresh177 = nodes.end;
|
let fresh176 = addr_of_mut!((*document).nodes.start);
|
||||||
let fresh178 = addr_of_mut!((*document).nodes.top);
|
*fresh176 = nodes.start;
|
||||||
*fresh178 = nodes.start;
|
let fresh177 = addr_of_mut!((*document).nodes.end);
|
||||||
let fresh179 = addr_of_mut!((*document).version_directive);
|
*fresh177 = nodes.end;
|
||||||
*fresh179 = version_directive_copy;
|
let fresh178 = addr_of_mut!((*document).nodes.top);
|
||||||
let fresh180 = addr_of_mut!((*document).tag_directives.start);
|
*fresh178 = nodes.start;
|
||||||
*fresh180 = tag_directives_copy.start;
|
let fresh179 = addr_of_mut!((*document).version_directive);
|
||||||
let fresh181 = addr_of_mut!((*document).tag_directives.end);
|
*fresh179 = version_directive_copy;
|
||||||
*fresh181 = tag_directives_copy.top;
|
let fresh180 = addr_of_mut!((*document).tag_directives.start);
|
||||||
(*document).start_implicit = start_implicit;
|
*fresh180 = tag_directives_copy.start;
|
||||||
(*document).end_implicit = end_implicit;
|
let fresh181 = addr_of_mut!((*document).tag_directives.end);
|
||||||
(*document).start_mark = mark;
|
*fresh181 = tag_directives_copy.top;
|
||||||
(*document).end_mark = mark;
|
(*document).start_implicit = start_implicit;
|
||||||
return OK;
|
(*document).end_implicit = end_implicit;
|
||||||
}
|
(*document).start_mark = mark;
|
||||||
|
(*document).end_mark = mark;
|
||||||
|
return OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1519,24 +1499,22 @@ pub unsafe fn yaml_document_add_sequence(
|
||||||
if yaml_check_utf8(tag, strlen(tag as *mut libc::c_char)).ok {
|
if yaml_check_utf8(tag, strlen(tag as *mut libc::c_char)).ok {
|
||||||
tag_copy = yaml_strdup(tag);
|
tag_copy = yaml_strdup(tag);
|
||||||
if !tag_copy.is_null() {
|
if !tag_copy.is_null() {
|
||||||
if STACK_INIT!(addr_of_mut!(context), items, yaml_node_item_t).ok {
|
STACK_INIT!(addr_of_mut!(context), items, yaml_node_item_t);
|
||||||
memset(
|
memset(
|
||||||
node as *mut libc::c_void,
|
node as *mut libc::c_void,
|
||||||
0,
|
0,
|
||||||
size_of::<yaml_node_t>() as libc::c_ulong,
|
size_of::<yaml_node_t>() as libc::c_ulong,
|
||||||
);
|
);
|
||||||
(*node).type_ = YAML_SEQUENCE_NODE;
|
(*node).type_ = YAML_SEQUENCE_NODE;
|
||||||
(*node).tag = tag_copy;
|
(*node).tag = tag_copy;
|
||||||
(*node).start_mark = mark;
|
(*node).start_mark = mark;
|
||||||
(*node).end_mark = mark;
|
(*node).end_mark = mark;
|
||||||
(*node).data.sequence.items.start = items.start;
|
(*node).data.sequence.items.start = items.start;
|
||||||
(*node).data.sequence.items.end = items.end;
|
(*node).data.sequence.items.end = items.end;
|
||||||
(*node).data.sequence.items.top = items.start;
|
(*node).data.sequence.items.top = items.start;
|
||||||
(*node).data.sequence.style = style;
|
(*node).data.sequence.style = style;
|
||||||
if PUSH!(addr_of_mut!(context), (*document).nodes, *node).ok {
|
if PUSH!(addr_of_mut!(context), (*document).nodes, *node).ok {
|
||||||
return (*document).nodes.top.c_offset_from((*document).nodes.start)
|
return (*document).nodes.top.c_offset_from((*document).nodes.start) as libc::c_int;
|
||||||
as libc::c_int;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1584,24 +1562,22 @@ pub unsafe fn yaml_document_add_mapping(
|
||||||
if yaml_check_utf8(tag, strlen(tag as *mut libc::c_char)).ok {
|
if yaml_check_utf8(tag, strlen(tag as *mut libc::c_char)).ok {
|
||||||
tag_copy = yaml_strdup(tag);
|
tag_copy = yaml_strdup(tag);
|
||||||
if !tag_copy.is_null() {
|
if !tag_copy.is_null() {
|
||||||
if STACK_INIT!(addr_of_mut!(context), pairs, yaml_node_pair_t).ok {
|
STACK_INIT!(addr_of_mut!(context), pairs, yaml_node_pair_t);
|
||||||
memset(
|
memset(
|
||||||
node as *mut libc::c_void,
|
node as *mut libc::c_void,
|
||||||
0,
|
0,
|
||||||
size_of::<yaml_node_t>() as libc::c_ulong,
|
size_of::<yaml_node_t>() as libc::c_ulong,
|
||||||
);
|
);
|
||||||
(*node).type_ = YAML_MAPPING_NODE;
|
(*node).type_ = YAML_MAPPING_NODE;
|
||||||
(*node).tag = tag_copy;
|
(*node).tag = tag_copy;
|
||||||
(*node).start_mark = mark;
|
(*node).start_mark = mark;
|
||||||
(*node).end_mark = mark;
|
(*node).end_mark = mark;
|
||||||
(*node).data.mapping.pairs.start = pairs.start;
|
(*node).data.mapping.pairs.start = pairs.start;
|
||||||
(*node).data.mapping.pairs.end = pairs.end;
|
(*node).data.mapping.pairs.end = pairs.end;
|
||||||
(*node).data.mapping.pairs.top = pairs.start;
|
(*node).data.mapping.pairs.top = pairs.start;
|
||||||
(*node).data.mapping.style = style;
|
(*node).data.mapping.style = style;
|
||||||
if PUSH!(addr_of_mut!(context), (*document).nodes, *node).ok {
|
if PUSH!(addr_of_mut!(context), (*document).nodes, *node).ok {
|
||||||
return (*document).nodes.top.c_offset_from((*document).nodes.start)
|
return (*document).nodes.top.c_offset_from((*document).nodes.start) as libc::c_int;
|
||||||
as libc::c_int;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
208
src/loader.rs
208
src/loader.rs
|
@ -48,37 +48,35 @@ pub unsafe fn yaml_parser_load(
|
||||||
0,
|
0,
|
||||||
size_of::<yaml_document_t>() as libc::c_ulong,
|
size_of::<yaml_document_t>() as libc::c_ulong,
|
||||||
);
|
);
|
||||||
if STACK_INIT!(parser, (*document).nodes, yaml_node_t).ok {
|
STACK_INIT!(parser, (*document).nodes, yaml_node_t);
|
||||||
if !(*parser).stream_start_produced {
|
if !(*parser).stream_start_produced {
|
||||||
if yaml_parser_parse(parser, event).fail {
|
if yaml_parser_parse(parser, event).fail {
|
||||||
current_block = 6234624449317607669;
|
current_block = 6234624449317607669;
|
||||||
} else {
|
|
||||||
__assert!((*event).type_ == YAML_STREAM_START_EVENT);
|
|
||||||
current_block = 7815301370352969686;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
|
__assert!((*event).type_ == YAML_STREAM_START_EVENT);
|
||||||
current_block = 7815301370352969686;
|
current_block = 7815301370352969686;
|
||||||
}
|
}
|
||||||
match current_block {
|
} else {
|
||||||
6234624449317607669 => {}
|
current_block = 7815301370352969686;
|
||||||
_ => {
|
}
|
||||||
if (*parser).stream_end_produced {
|
match current_block {
|
||||||
|
6234624449317607669 => {}
|
||||||
|
_ => {
|
||||||
|
if (*parser).stream_end_produced {
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
if yaml_parser_parse(parser, event).ok {
|
||||||
|
if (*event).type_ == YAML_STREAM_END_EVENT {
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
if yaml_parser_parse(parser, event).ok {
|
STACK_INIT!(parser, (*parser).aliases, yaml_alias_data_t);
|
||||||
if (*event).type_ == YAML_STREAM_END_EVENT {
|
let fresh6 = addr_of_mut!((*parser).document);
|
||||||
return OK;
|
*fresh6 = document;
|
||||||
}
|
if yaml_parser_load_document(parser, event).ok {
|
||||||
if STACK_INIT!(parser, (*parser).aliases, yaml_alias_data_t).ok {
|
yaml_parser_delete_aliases(parser);
|
||||||
let fresh6 = addr_of_mut!((*parser).document);
|
let fresh7 = addr_of_mut!((*parser).document);
|
||||||
*fresh6 = document;
|
*fresh7 = ptr::null_mut::<yaml_document_t>();
|
||||||
if yaml_parser_load_document(parser, event).ok {
|
return OK;
|
||||||
yaml_parser_delete_aliases(parser);
|
|
||||||
let fresh7 = addr_of_mut!((*parser).document);
|
|
||||||
*fresh7 = ptr::null_mut::<yaml_document_t>();
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -144,9 +142,7 @@ unsafe fn yaml_parser_load_document(
|
||||||
*fresh18 = (*event).data.document_start.tag_directives.end;
|
*fresh18 = (*event).data.document_start.tag_directives.end;
|
||||||
(*(*parser).document).start_implicit = (*event).data.document_start.implicit;
|
(*(*parser).document).start_implicit = (*event).data.document_start.implicit;
|
||||||
(*(*parser).document).start_mark = (*event).start_mark;
|
(*(*parser).document).start_mark = (*event).start_mark;
|
||||||
if STACK_INIT!(parser, ctx, libc::c_int).fail {
|
STACK_INIT!(parser, ctx, libc::c_int);
|
||||||
return FAIL;
|
|
||||||
}
|
|
||||||
if yaml_parser_load_nodes(parser, addr_of_mut!(ctx)).fail {
|
if yaml_parser_load_nodes(parser, addr_of_mut!(ctx)).fail {
|
||||||
STACK_DEL!(ctx);
|
STACK_DEL!(ctx);
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
@ -442,46 +438,45 @@ unsafe fn yaml_parser_load_sequence(
|
||||||
match current_block {
|
match current_block {
|
||||||
13474536459355229096 => {}
|
13474536459355229096 => {}
|
||||||
_ => {
|
_ => {
|
||||||
if STACK_INIT!(parser, items, yaml_node_item_t).ok {
|
STACK_INIT!(parser, items, yaml_node_item_t);
|
||||||
memset(
|
memset(
|
||||||
node as *mut libc::c_void,
|
node as *mut libc::c_void,
|
||||||
0,
|
0,
|
||||||
size_of::<yaml_node_t>() as libc::c_ulong,
|
size_of::<yaml_node_t>() as libc::c_ulong,
|
||||||
);
|
);
|
||||||
(*node).type_ = YAML_SEQUENCE_NODE;
|
(*node).type_ = YAML_SEQUENCE_NODE;
|
||||||
(*node).tag = tag;
|
(*node).tag = tag;
|
||||||
(*node).start_mark = (*event).start_mark;
|
(*node).start_mark = (*event).start_mark;
|
||||||
(*node).end_mark = (*event).end_mark;
|
(*node).end_mark = (*event).end_mark;
|
||||||
(*node).data.sequence.items.start = items.start;
|
(*node).data.sequence.items.start = items.start;
|
||||||
(*node).data.sequence.items.end = items.end;
|
(*node).data.sequence.items.end = items.end;
|
||||||
(*node).data.sequence.items.top = items.start;
|
(*node).data.sequence.items.top = items.start;
|
||||||
(*node).data.sequence.style = (*event).data.sequence_start.style;
|
(*node).data.sequence.style = (*event).data.sequence_start.style;
|
||||||
if PUSH!(parser, (*(*parser).document).nodes, *node).ok {
|
if PUSH!(parser, (*(*parser).document).nodes, *node).ok {
|
||||||
index = (*(*parser).document)
|
index = (*(*parser).document)
|
||||||
.nodes
|
.nodes
|
||||||
.top
|
.top
|
||||||
.c_offset_from((*(*parser).document).nodes.start)
|
.c_offset_from((*(*parser).document).nodes.start)
|
||||||
as libc::c_int;
|
as libc::c_int;
|
||||||
if yaml_parser_register_anchor(
|
if yaml_parser_register_anchor(
|
||||||
parser,
|
parser,
|
||||||
index,
|
index,
|
||||||
(*event).data.sequence_start.anchor,
|
(*event).data.sequence_start.anchor,
|
||||||
)
|
)
|
||||||
.fail
|
.fail
|
||||||
{
|
{
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
|
||||||
if yaml_parser_load_node_add(parser, ctx, index).fail {
|
|
||||||
return FAIL;
|
|
||||||
}
|
|
||||||
if STACK_LIMIT!(parser, *ctx).fail {
|
|
||||||
return FAIL;
|
|
||||||
}
|
|
||||||
if PUSH!(parser, *ctx, index).fail {
|
|
||||||
return FAIL;
|
|
||||||
}
|
|
||||||
return OK;
|
|
||||||
}
|
}
|
||||||
|
if yaml_parser_load_node_add(parser, ctx, index).fail {
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
if STACK_LIMIT!(parser, *ctx).fail {
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
if PUSH!(parser, *ctx, index).fail {
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
return OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -553,46 +548,45 @@ unsafe fn yaml_parser_load_mapping(
|
||||||
match current_block {
|
match current_block {
|
||||||
13635467803606088781 => {}
|
13635467803606088781 => {}
|
||||||
_ => {
|
_ => {
|
||||||
if STACK_INIT!(parser, pairs, yaml_node_pair_t).ok {
|
STACK_INIT!(parser, pairs, yaml_node_pair_t);
|
||||||
memset(
|
memset(
|
||||||
node as *mut libc::c_void,
|
node as *mut libc::c_void,
|
||||||
0,
|
0,
|
||||||
size_of::<yaml_node_t>() as libc::c_ulong,
|
size_of::<yaml_node_t>() as libc::c_ulong,
|
||||||
);
|
);
|
||||||
(*node).type_ = YAML_MAPPING_NODE;
|
(*node).type_ = YAML_MAPPING_NODE;
|
||||||
(*node).tag = tag;
|
(*node).tag = tag;
|
||||||
(*node).start_mark = (*event).start_mark;
|
(*node).start_mark = (*event).start_mark;
|
||||||
(*node).end_mark = (*event).end_mark;
|
(*node).end_mark = (*event).end_mark;
|
||||||
(*node).data.mapping.pairs.start = pairs.start;
|
(*node).data.mapping.pairs.start = pairs.start;
|
||||||
(*node).data.mapping.pairs.end = pairs.end;
|
(*node).data.mapping.pairs.end = pairs.end;
|
||||||
(*node).data.mapping.pairs.top = pairs.start;
|
(*node).data.mapping.pairs.top = pairs.start;
|
||||||
(*node).data.mapping.style = (*event).data.mapping_start.style;
|
(*node).data.mapping.style = (*event).data.mapping_start.style;
|
||||||
if PUSH!(parser, (*(*parser).document).nodes, *node).ok {
|
if PUSH!(parser, (*(*parser).document).nodes, *node).ok {
|
||||||
index = (*(*parser).document)
|
index = (*(*parser).document)
|
||||||
.nodes
|
.nodes
|
||||||
.top
|
.top
|
||||||
.c_offset_from((*(*parser).document).nodes.start)
|
.c_offset_from((*(*parser).document).nodes.start)
|
||||||
as libc::c_int;
|
as libc::c_int;
|
||||||
if yaml_parser_register_anchor(
|
if yaml_parser_register_anchor(
|
||||||
parser,
|
parser,
|
||||||
index,
|
index,
|
||||||
(*event).data.mapping_start.anchor,
|
(*event).data.mapping_start.anchor,
|
||||||
)
|
)
|
||||||
.fail
|
.fail
|
||||||
{
|
{
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
|
||||||
if yaml_parser_load_node_add(parser, ctx, index).fail {
|
|
||||||
return FAIL;
|
|
||||||
}
|
|
||||||
if STACK_LIMIT!(parser, *ctx).fail {
|
|
||||||
return FAIL;
|
|
||||||
}
|
|
||||||
if PUSH!(parser, *ctx, index).fail {
|
|
||||||
return FAIL;
|
|
||||||
}
|
|
||||||
return OK;
|
|
||||||
}
|
}
|
||||||
|
if yaml_parser_load_node_add(parser, ctx, index).fail {
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
if STACK_LIMIT!(parser, *ctx).fail {
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
if PUSH!(parser, *ctx, index).fail {
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
return OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -365,7 +365,6 @@ macro_rules! STACK_INIT {
|
||||||
$stack.start = yaml_malloc(16 * size_of::<$type>() as libc::c_ulong) as *mut $type;
|
$stack.start = yaml_malloc(16 * size_of::<$type>() as libc::c_ulong) as *mut $type;
|
||||||
$stack.top = $stack.start;
|
$stack.top = $stack.start;
|
||||||
$stack.end = $stack.start.offset(16_isize);
|
$stack.end = $stack.start.offset(16_isize);
|
||||||
OK
|
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
193
src/parser.rs
193
src/parser.rs
|
@ -1307,114 +1307,109 @@ unsafe fn yaml_parser_process_directives(
|
||||||
top: ptr::null_mut::<yaml_tag_directive_t>(),
|
top: ptr::null_mut::<yaml_tag_directive_t>(),
|
||||||
};
|
};
|
||||||
let mut token: *mut yaml_token_t;
|
let mut token: *mut yaml_token_t;
|
||||||
if STACK_INIT!(parser, tag_directives, yaml_tag_directive_t).ok {
|
STACK_INIT!(parser, tag_directives, yaml_tag_directive_t);
|
||||||
token = PEEK_TOKEN(parser);
|
token = PEEK_TOKEN(parser);
|
||||||
if !token.is_null() {
|
if !token.is_null() {
|
||||||
loop {
|
loop {
|
||||||
if !((*token).type_ == YAML_VERSION_DIRECTIVE_TOKEN
|
if !((*token).type_ == YAML_VERSION_DIRECTIVE_TOKEN
|
||||||
|| (*token).type_ == YAML_TAG_DIRECTIVE_TOKEN)
|
|| (*token).type_ == YAML_TAG_DIRECTIVE_TOKEN)
|
||||||
|
{
|
||||||
|
current_block = 16924917904204750491;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (*token).type_ == YAML_VERSION_DIRECTIVE_TOKEN {
|
||||||
|
if !version_directive.is_null() {
|
||||||
|
yaml_parser_set_parser_error(
|
||||||
|
parser,
|
||||||
|
b"found duplicate %YAML directive\0" as *const u8 as *const libc::c_char,
|
||||||
|
(*token).start_mark,
|
||||||
|
);
|
||||||
|
current_block = 17143798186130252483;
|
||||||
|
break;
|
||||||
|
} else if (*token).data.version_directive.major != 1
|
||||||
|
|| (*token).data.version_directive.minor != 1
|
||||||
|
&& (*token).data.version_directive.minor != 2
|
||||||
{
|
{
|
||||||
current_block = 16924917904204750491;
|
yaml_parser_set_parser_error(
|
||||||
|
parser,
|
||||||
|
b"found incompatible YAML document\0" as *const u8 as *const libc::c_char,
|
||||||
|
(*token).start_mark,
|
||||||
|
);
|
||||||
|
current_block = 17143798186130252483;
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
version_directive =
|
||||||
|
yaml_malloc(size_of::<yaml_version_directive_t>() as libc::c_ulong)
|
||||||
|
as *mut yaml_version_directive_t;
|
||||||
|
(*version_directive).major = (*token).data.version_directive.major;
|
||||||
|
(*version_directive).minor = (*token).data.version_directive.minor;
|
||||||
|
}
|
||||||
|
} 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,
|
||||||
|
};
|
||||||
|
if yaml_parser_append_tag_directive(parser, value, false, (*token).start_mark).fail
|
||||||
|
{
|
||||||
|
current_block = 17143798186130252483;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (*token).type_ == YAML_VERSION_DIRECTIVE_TOKEN {
|
if PUSH!(parser, tag_directives, value).fail {
|
||||||
if !version_directive.is_null() {
|
|
||||||
yaml_parser_set_parser_error(
|
|
||||||
parser,
|
|
||||||
b"found duplicate %YAML directive\0" as *const u8
|
|
||||||
as *const libc::c_char,
|
|
||||||
(*token).start_mark,
|
|
||||||
);
|
|
||||||
current_block = 17143798186130252483;
|
|
||||||
break;
|
|
||||||
} else if (*token).data.version_directive.major != 1
|
|
||||||
|| (*token).data.version_directive.minor != 1
|
|
||||||
&& (*token).data.version_directive.minor != 2
|
|
||||||
{
|
|
||||||
yaml_parser_set_parser_error(
|
|
||||||
parser,
|
|
||||||
b"found incompatible YAML document\0" as *const u8
|
|
||||||
as *const libc::c_char,
|
|
||||||
(*token).start_mark,
|
|
||||||
);
|
|
||||||
current_block = 17143798186130252483;
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
version_directive =
|
|
||||||
yaml_malloc(size_of::<yaml_version_directive_t>() as libc::c_ulong)
|
|
||||||
as *mut yaml_version_directive_t;
|
|
||||||
(*version_directive).major = (*token).data.version_directive.major;
|
|
||||||
(*version_directive).minor = (*token).data.version_directive.minor;
|
|
||||||
}
|
|
||||||
} 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,
|
|
||||||
};
|
|
||||||
if yaml_parser_append_tag_directive(parser, value, false, (*token).start_mark)
|
|
||||||
.fail
|
|
||||||
{
|
|
||||||
current_block = 17143798186130252483;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if PUSH!(parser, tag_directives, value).fail {
|
|
||||||
current_block = 17143798186130252483;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
SKIP_TOKEN(parser);
|
|
||||||
token = PEEK_TOKEN(parser);
|
|
||||||
if token.is_null() {
|
|
||||||
current_block = 17143798186130252483;
|
current_block = 17143798186130252483;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
match current_block {
|
SKIP_TOKEN(parser);
|
||||||
17143798186130252483 => {}
|
token = PEEK_TOKEN(parser);
|
||||||
_ => {
|
if token.is_null() {
|
||||||
default_tag_directive = default_tag_directives.as_mut_ptr();
|
current_block = 17143798186130252483;
|
||||||
loop {
|
break;
|
||||||
if (*default_tag_directive).handle.is_null() {
|
}
|
||||||
current_block = 18377268871191777778;
|
}
|
||||||
break;
|
match current_block {
|
||||||
}
|
17143798186130252483 => {}
|
||||||
if yaml_parser_append_tag_directive(
|
_ => {
|
||||||
parser,
|
default_tag_directive = default_tag_directives.as_mut_ptr();
|
||||||
*default_tag_directive,
|
loop {
|
||||||
true,
|
if (*default_tag_directive).handle.is_null() {
|
||||||
(*token).start_mark,
|
current_block = 18377268871191777778;
|
||||||
)
|
break;
|
||||||
.fail
|
|
||||||
{
|
|
||||||
current_block = 17143798186130252483;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default_tag_directive = default_tag_directive.wrapping_offset(1);
|
|
||||||
}
|
}
|
||||||
match current_block {
|
if yaml_parser_append_tag_directive(
|
||||||
17143798186130252483 => {}
|
parser,
|
||||||
_ => {
|
*default_tag_directive,
|
||||||
if !version_directive_ref.is_null() {
|
true,
|
||||||
*version_directive_ref = version_directive;
|
(*token).start_mark,
|
||||||
}
|
)
|
||||||
if !tag_directives_start_ref.is_null() {
|
.fail
|
||||||
if STACK_EMPTY!(tag_directives) {
|
{
|
||||||
*tag_directives_end_ref =
|
current_block = 17143798186130252483;
|
||||||
ptr::null_mut::<yaml_tag_directive_t>();
|
break;
|
||||||
*tag_directives_start_ref = *tag_directives_end_ref;
|
}
|
||||||
STACK_DEL!(tag_directives);
|
default_tag_directive = default_tag_directive.wrapping_offset(1);
|
||||||
} else {
|
}
|
||||||
*tag_directives_start_ref = tag_directives.start;
|
match current_block {
|
||||||
*tag_directives_end_ref = tag_directives.top;
|
17143798186130252483 => {}
|
||||||
}
|
_ => {
|
||||||
} else {
|
if !version_directive_ref.is_null() {
|
||||||
STACK_DEL!(tag_directives);
|
*version_directive_ref = version_directive;
|
||||||
}
|
|
||||||
if version_directive_ref.is_null() {
|
|
||||||
yaml_free(version_directive as *mut libc::c_void);
|
|
||||||
}
|
|
||||||
return OK;
|
|
||||||
}
|
}
|
||||||
|
if !tag_directives_start_ref.is_null() {
|
||||||
|
if STACK_EMPTY!(tag_directives) {
|
||||||
|
*tag_directives_end_ref = ptr::null_mut::<yaml_tag_directive_t>();
|
||||||
|
*tag_directives_start_ref = *tag_directives_end_ref;
|
||||||
|
STACK_DEL!(tag_directives);
|
||||||
|
} else {
|
||||||
|
*tag_directives_start_ref = tag_directives.start;
|
||||||
|
*tag_directives_end_ref = tag_directives.top;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
STACK_DEL!(tag_directives);
|
||||||
|
}
|
||||||
|
if version_directive_ref.is_null() {
|
||||||
|
yaml_free(version_directive as *mut libc::c_void);
|
||||||
|
}
|
||||||
|
return OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue