mirror of
https://github.com/simonask/libyaml-safer
synced 2024-11-22 19:33:03 +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).buffer, INPUT_BUFFER_SIZE);
|
||||
if QUEUE_INIT!(parser, (*parser).tokens, yaml_token_t).ok {
|
||||
if STACK_INIT!(parser, (*parser).indents, libc::c_int).ok {
|
||||
if STACK_INIT!(parser, (*parser).simple_keys, yaml_simple_key_t).ok {
|
||||
if STACK_INIT!(parser, (*parser).states, yaml_parser_state_t).ok {
|
||||
if STACK_INIT!(parser, (*parser).marks, yaml_mark_t).ok {
|
||||
if STACK_INIT!(parser, (*parser).tag_directives, yaml_tag_directive_t).ok {
|
||||
return OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
STACK_INIT!(parser, (*parser).indents, libc::c_int);
|
||||
STACK_INIT!(parser, (*parser).simple_keys, yaml_simple_key_t);
|
||||
STACK_INIT!(parser, (*parser).states, yaml_parser_state_t);
|
||||
STACK_INIT!(parser, (*parser).marks, yaml_mark_t);
|
||||
STACK_INIT!(parser, (*parser).tag_directives, yaml_tag_directive_t);
|
||||
return OK;
|
||||
}
|
||||
BUFFER_DEL!((*parser).raw_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).raw_buffer, OUTPUT_RAW_BUFFER_SIZE);
|
||||
if STACK_INIT!(emitter, (*emitter).states, yaml_emitter_state_t).ok {
|
||||
if QUEUE_INIT!(emitter, (*emitter).events, yaml_event_t).ok {
|
||||
if STACK_INIT!(emitter, (*emitter).indents, libc::c_int).ok {
|
||||
if STACK_INIT!(emitter, (*emitter).tag_directives, yaml_tag_directive_t).ok {
|
||||
return OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
STACK_INIT!(emitter, (*emitter).states, yaml_emitter_state_t);
|
||||
if QUEUE_INIT!(emitter, (*emitter).events, yaml_event_t).ok {
|
||||
STACK_INIT!(emitter, (*emitter).indents, libc::c_int);
|
||||
STACK_INIT!(emitter, (*emitter).tag_directives, yaml_tag_directive_t);
|
||||
return OK;
|
||||
}
|
||||
BUFFER_DEL!((*emitter).buffer);
|
||||
BUFFER_DEL!((*emitter).raw_buffer);
|
||||
|
@ -687,55 +679,50 @@ pub unsafe fn yaml_document_start_event_initialize(
|
|||
1394248824506584008 => {
|
||||
if tag_directives_start != tag_directives_end {
|
||||
let mut tag_directive: *mut yaml_tag_directive_t;
|
||||
if STACK_INIT!(
|
||||
STACK_INIT!(
|
||||
addr_of_mut!(context),
|
||||
tag_directives_copy,
|
||||
yaml_tag_directive_t
|
||||
)
|
||||
.fail
|
||||
{
|
||||
current_block = 14964981520188694172;
|
||||
} else {
|
||||
tag_directive = tag_directives_start;
|
||||
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);
|
||||
);
|
||||
tag_directive = tag_directives_start;
|
||||
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);
|
||||
}
|
||||
} else {
|
||||
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 == tag_directives_end
|
||||
);
|
||||
if STACK_INIT!(addr_of_mut!(context), nodes, yaml_node_t).ok {
|
||||
if !version_directive.is_null() {
|
||||
version_directive_copy =
|
||||
yaml_malloc(size_of::<yaml_version_directive_t>() as libc::c_ulong)
|
||||
as *mut yaml_version_directive_t;
|
||||
(*version_directive_copy).major = (*version_directive).major;
|
||||
(*version_directive_copy).minor = (*version_directive).minor;
|
||||
current_block = 7746791466490516765;
|
||||
} else {
|
||||
current_block = 7746791466490516765;
|
||||
}
|
||||
match current_block {
|
||||
8142820162064489797 => {}
|
||||
_ => {
|
||||
if tag_directives_start != tag_directives_end {
|
||||
let mut tag_directive: *mut yaml_tag_directive_t;
|
||||
if STACK_INIT!(
|
||||
addr_of_mut!(context),
|
||||
tag_directives_copy,
|
||||
yaml_tag_directive_t
|
||||
STACK_INIT!(addr_of_mut!(context), nodes, yaml_node_t);
|
||||
if !version_directive.is_null() {
|
||||
version_directive_copy = yaml_malloc(size_of::<yaml_version_directive_t>() as libc::c_ulong)
|
||||
as *mut yaml_version_directive_t;
|
||||
(*version_directive_copy).major = (*version_directive).major;
|
||||
(*version_directive_copy).minor = (*version_directive).minor;
|
||||
current_block = 7746791466490516765;
|
||||
} else {
|
||||
current_block = 7746791466490516765;
|
||||
}
|
||||
match current_block {
|
||||
8142820162064489797 => {}
|
||||
_ => {
|
||||
if tag_directives_start != tag_directives_end {
|
||||
let mut tag_directive: *mut yaml_tag_directive_t;
|
||||
STACK_INIT!(
|
||||
addr_of_mut!(context),
|
||||
tag_directives_copy,
|
||||
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
|
||||
{
|
||||
current_block = 8142820162064489797;
|
||||
} else {
|
||||
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);
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
current_block = 14818589718467733107;
|
||||
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);
|
||||
}
|
||||
match current_block {
|
||||
8142820162064489797 => {}
|
||||
_ => {
|
||||
memset(
|
||||
document as *mut libc::c_void,
|
||||
0,
|
||||
size_of::<yaml_document_t>() as libc::c_ulong,
|
||||
);
|
||||
let fresh176 = addr_of_mut!((*document).nodes.start);
|
||||
*fresh176 = nodes.start;
|
||||
let fresh177 = addr_of_mut!((*document).nodes.end);
|
||||
*fresh177 = nodes.end;
|
||||
let fresh178 = addr_of_mut!((*document).nodes.top);
|
||||
*fresh178 = nodes.start;
|
||||
let fresh179 = addr_of_mut!((*document).version_directive);
|
||||
*fresh179 = version_directive_copy;
|
||||
let fresh180 = addr_of_mut!((*document).tag_directives.start);
|
||||
*fresh180 = tag_directives_copy.start;
|
||||
let fresh181 = addr_of_mut!((*document).tag_directives.end);
|
||||
*fresh181 = tag_directives_copy.top;
|
||||
(*document).start_implicit = start_implicit;
|
||||
(*document).end_implicit = end_implicit;
|
||||
(*document).start_mark = mark;
|
||||
(*document).end_mark = mark;
|
||||
return OK;
|
||||
}
|
||||
} else {
|
||||
current_block = 14818589718467733107;
|
||||
}
|
||||
match current_block {
|
||||
8142820162064489797 => {}
|
||||
_ => {
|
||||
memset(
|
||||
document as *mut libc::c_void,
|
||||
0,
|
||||
size_of::<yaml_document_t>() as libc::c_ulong,
|
||||
);
|
||||
let fresh176 = addr_of_mut!((*document).nodes.start);
|
||||
*fresh176 = nodes.start;
|
||||
let fresh177 = addr_of_mut!((*document).nodes.end);
|
||||
*fresh177 = nodes.end;
|
||||
let fresh178 = addr_of_mut!((*document).nodes.top);
|
||||
*fresh178 = nodes.start;
|
||||
let fresh179 = addr_of_mut!((*document).version_directive);
|
||||
*fresh179 = version_directive_copy;
|
||||
let fresh180 = addr_of_mut!((*document).tag_directives.start);
|
||||
*fresh180 = tag_directives_copy.start;
|
||||
let fresh181 = addr_of_mut!((*document).tag_directives.end);
|
||||
*fresh181 = tag_directives_copy.top;
|
||||
(*document).start_implicit = start_implicit;
|
||||
(*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 {
|
||||
tag_copy = yaml_strdup(tag);
|
||||
if !tag_copy.is_null() {
|
||||
if STACK_INIT!(addr_of_mut!(context), items, yaml_node_item_t).ok {
|
||||
memset(
|
||||
node as *mut libc::c_void,
|
||||
0,
|
||||
size_of::<yaml_node_t>() as libc::c_ulong,
|
||||
);
|
||||
(*node).type_ = YAML_SEQUENCE_NODE;
|
||||
(*node).tag = tag_copy;
|
||||
(*node).start_mark = mark;
|
||||
(*node).end_mark = mark;
|
||||
(*node).data.sequence.items.start = items.start;
|
||||
(*node).data.sequence.items.end = items.end;
|
||||
(*node).data.sequence.items.top = items.start;
|
||||
(*node).data.sequence.style = style;
|
||||
if PUSH!(addr_of_mut!(context), (*document).nodes, *node).ok {
|
||||
return (*document).nodes.top.c_offset_from((*document).nodes.start)
|
||||
as libc::c_int;
|
||||
}
|
||||
STACK_INIT!(addr_of_mut!(context), items, yaml_node_item_t);
|
||||
memset(
|
||||
node as *mut libc::c_void,
|
||||
0,
|
||||
size_of::<yaml_node_t>() as libc::c_ulong,
|
||||
);
|
||||
(*node).type_ = YAML_SEQUENCE_NODE;
|
||||
(*node).tag = tag_copy;
|
||||
(*node).start_mark = mark;
|
||||
(*node).end_mark = mark;
|
||||
(*node).data.sequence.items.start = items.start;
|
||||
(*node).data.sequence.items.end = items.end;
|
||||
(*node).data.sequence.items.top = items.start;
|
||||
(*node).data.sequence.style = style;
|
||||
if PUSH!(addr_of_mut!(context), (*document).nodes, *node).ok {
|
||||
return (*document).nodes.top.c_offset_from((*document).nodes.start) 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 {
|
||||
tag_copy = yaml_strdup(tag);
|
||||
if !tag_copy.is_null() {
|
||||
if STACK_INIT!(addr_of_mut!(context), pairs, yaml_node_pair_t).ok {
|
||||
memset(
|
||||
node as *mut libc::c_void,
|
||||
0,
|
||||
size_of::<yaml_node_t>() as libc::c_ulong,
|
||||
);
|
||||
(*node).type_ = YAML_MAPPING_NODE;
|
||||
(*node).tag = tag_copy;
|
||||
(*node).start_mark = mark;
|
||||
(*node).end_mark = mark;
|
||||
(*node).data.mapping.pairs.start = pairs.start;
|
||||
(*node).data.mapping.pairs.end = pairs.end;
|
||||
(*node).data.mapping.pairs.top = pairs.start;
|
||||
(*node).data.mapping.style = style;
|
||||
if PUSH!(addr_of_mut!(context), (*document).nodes, *node).ok {
|
||||
return (*document).nodes.top.c_offset_from((*document).nodes.start)
|
||||
as libc::c_int;
|
||||
}
|
||||
STACK_INIT!(addr_of_mut!(context), pairs, yaml_node_pair_t);
|
||||
memset(
|
||||
node as *mut libc::c_void,
|
||||
0,
|
||||
size_of::<yaml_node_t>() as libc::c_ulong,
|
||||
);
|
||||
(*node).type_ = YAML_MAPPING_NODE;
|
||||
(*node).tag = tag_copy;
|
||||
(*node).start_mark = mark;
|
||||
(*node).end_mark = mark;
|
||||
(*node).data.mapping.pairs.start = pairs.start;
|
||||
(*node).data.mapping.pairs.end = pairs.end;
|
||||
(*node).data.mapping.pairs.top = pairs.start;
|
||||
(*node).data.mapping.style = style;
|
||||
if PUSH!(addr_of_mut!(context), (*document).nodes, *node).ok {
|
||||
return (*document).nodes.top.c_offset_from((*document).nodes.start) as libc::c_int;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
208
src/loader.rs
208
src/loader.rs
|
@ -48,37 +48,35 @@ pub unsafe fn yaml_parser_load(
|
|||
0,
|
||||
size_of::<yaml_document_t>() as libc::c_ulong,
|
||||
);
|
||||
if STACK_INIT!(parser, (*document).nodes, yaml_node_t).ok {
|
||||
if !(*parser).stream_start_produced {
|
||||
if yaml_parser_parse(parser, event).fail {
|
||||
current_block = 6234624449317607669;
|
||||
} else {
|
||||
__assert!((*event).type_ == YAML_STREAM_START_EVENT);
|
||||
current_block = 7815301370352969686;
|
||||
}
|
||||
STACK_INIT!(parser, (*document).nodes, yaml_node_t);
|
||||
if !(*parser).stream_start_produced {
|
||||
if yaml_parser_parse(parser, event).fail {
|
||||
current_block = 6234624449317607669;
|
||||
} else {
|
||||
__assert!((*event).type_ == YAML_STREAM_START_EVENT);
|
||||
current_block = 7815301370352969686;
|
||||
}
|
||||
match current_block {
|
||||
6234624449317607669 => {}
|
||||
_ => {
|
||||
if (*parser).stream_end_produced {
|
||||
} else {
|
||||
current_block = 7815301370352969686;
|
||||
}
|
||||
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;
|
||||
}
|
||||
if yaml_parser_parse(parser, event).ok {
|
||||
if (*event).type_ == YAML_STREAM_END_EVENT {
|
||||
return OK;
|
||||
}
|
||||
if STACK_INIT!(parser, (*parser).aliases, yaml_alias_data_t).ok {
|
||||
let fresh6 = addr_of_mut!((*parser).document);
|
||||
*fresh6 = document;
|
||||
if yaml_parser_load_document(parser, event).ok {
|
||||
yaml_parser_delete_aliases(parser);
|
||||
let fresh7 = addr_of_mut!((*parser).document);
|
||||
*fresh7 = ptr::null_mut::<yaml_document_t>();
|
||||
return OK;
|
||||
}
|
||||
}
|
||||
STACK_INIT!(parser, (*parser).aliases, yaml_alias_data_t);
|
||||
let fresh6 = addr_of_mut!((*parser).document);
|
||||
*fresh6 = document;
|
||||
if yaml_parser_load_document(parser, event).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;
|
||||
(*(*parser).document).start_implicit = (*event).data.document_start.implicit;
|
||||
(*(*parser).document).start_mark = (*event).start_mark;
|
||||
if STACK_INIT!(parser, ctx, libc::c_int).fail {
|
||||
return FAIL;
|
||||
}
|
||||
STACK_INIT!(parser, ctx, libc::c_int);
|
||||
if yaml_parser_load_nodes(parser, addr_of_mut!(ctx)).fail {
|
||||
STACK_DEL!(ctx);
|
||||
return FAIL;
|
||||
|
@ -442,46 +438,45 @@ unsafe fn yaml_parser_load_sequence(
|
|||
match current_block {
|
||||
13474536459355229096 => {}
|
||||
_ => {
|
||||
if STACK_INIT!(parser, items, yaml_node_item_t).ok {
|
||||
memset(
|
||||
node as *mut libc::c_void,
|
||||
0,
|
||||
size_of::<yaml_node_t>() as libc::c_ulong,
|
||||
);
|
||||
(*node).type_ = YAML_SEQUENCE_NODE;
|
||||
(*node).tag = tag;
|
||||
(*node).start_mark = (*event).start_mark;
|
||||
(*node).end_mark = (*event).end_mark;
|
||||
(*node).data.sequence.items.start = items.start;
|
||||
(*node).data.sequence.items.end = items.end;
|
||||
(*node).data.sequence.items.top = items.start;
|
||||
(*node).data.sequence.style = (*event).data.sequence_start.style;
|
||||
if PUSH!(parser, (*(*parser).document).nodes, *node).ok {
|
||||
index = (*(*parser).document)
|
||||
.nodes
|
||||
.top
|
||||
.c_offset_from((*(*parser).document).nodes.start)
|
||||
as libc::c_int;
|
||||
if yaml_parser_register_anchor(
|
||||
parser,
|
||||
index,
|
||||
(*event).data.sequence_start.anchor,
|
||||
)
|
||||
.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;
|
||||
STACK_INIT!(parser, items, yaml_node_item_t);
|
||||
memset(
|
||||
node as *mut libc::c_void,
|
||||
0,
|
||||
size_of::<yaml_node_t>() as libc::c_ulong,
|
||||
);
|
||||
(*node).type_ = YAML_SEQUENCE_NODE;
|
||||
(*node).tag = tag;
|
||||
(*node).start_mark = (*event).start_mark;
|
||||
(*node).end_mark = (*event).end_mark;
|
||||
(*node).data.sequence.items.start = items.start;
|
||||
(*node).data.sequence.items.end = items.end;
|
||||
(*node).data.sequence.items.top = items.start;
|
||||
(*node).data.sequence.style = (*event).data.sequence_start.style;
|
||||
if PUSH!(parser, (*(*parser).document).nodes, *node).ok {
|
||||
index = (*(*parser).document)
|
||||
.nodes
|
||||
.top
|
||||
.c_offset_from((*(*parser).document).nodes.start)
|
||||
as libc::c_int;
|
||||
if yaml_parser_register_anchor(
|
||||
parser,
|
||||
index,
|
||||
(*event).data.sequence_start.anchor,
|
||||
)
|
||||
.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -553,46 +548,45 @@ unsafe fn yaml_parser_load_mapping(
|
|||
match current_block {
|
||||
13635467803606088781 => {}
|
||||
_ => {
|
||||
if STACK_INIT!(parser, pairs, yaml_node_pair_t).ok {
|
||||
memset(
|
||||
node as *mut libc::c_void,
|
||||
0,
|
||||
size_of::<yaml_node_t>() as libc::c_ulong,
|
||||
);
|
||||
(*node).type_ = YAML_MAPPING_NODE;
|
||||
(*node).tag = tag;
|
||||
(*node).start_mark = (*event).start_mark;
|
||||
(*node).end_mark = (*event).end_mark;
|
||||
(*node).data.mapping.pairs.start = pairs.start;
|
||||
(*node).data.mapping.pairs.end = pairs.end;
|
||||
(*node).data.mapping.pairs.top = pairs.start;
|
||||
(*node).data.mapping.style = (*event).data.mapping_start.style;
|
||||
if PUSH!(parser, (*(*parser).document).nodes, *node).ok {
|
||||
index = (*(*parser).document)
|
||||
.nodes
|
||||
.top
|
||||
.c_offset_from((*(*parser).document).nodes.start)
|
||||
as libc::c_int;
|
||||
if yaml_parser_register_anchor(
|
||||
parser,
|
||||
index,
|
||||
(*event).data.mapping_start.anchor,
|
||||
)
|
||||
.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;
|
||||
STACK_INIT!(parser, pairs, yaml_node_pair_t);
|
||||
memset(
|
||||
node as *mut libc::c_void,
|
||||
0,
|
||||
size_of::<yaml_node_t>() as libc::c_ulong,
|
||||
);
|
||||
(*node).type_ = YAML_MAPPING_NODE;
|
||||
(*node).tag = tag;
|
||||
(*node).start_mark = (*event).start_mark;
|
||||
(*node).end_mark = (*event).end_mark;
|
||||
(*node).data.mapping.pairs.start = pairs.start;
|
||||
(*node).data.mapping.pairs.end = pairs.end;
|
||||
(*node).data.mapping.pairs.top = pairs.start;
|
||||
(*node).data.mapping.style = (*event).data.mapping_start.style;
|
||||
if PUSH!(parser, (*(*parser).document).nodes, *node).ok {
|
||||
index = (*(*parser).document)
|
||||
.nodes
|
||||
.top
|
||||
.c_offset_from((*(*parser).document).nodes.start)
|
||||
as libc::c_int;
|
||||
if yaml_parser_register_anchor(
|
||||
parser,
|
||||
index,
|
||||
(*event).data.mapping_start.anchor,
|
||||
)
|
||||
.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -365,7 +365,6 @@ macro_rules! STACK_INIT {
|
|||
$stack.start = yaml_malloc(16 * size_of::<$type>() as libc::c_ulong) as *mut $type;
|
||||
$stack.top = $stack.start;
|
||||
$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>(),
|
||||
};
|
||||
let mut token: *mut yaml_token_t;
|
||||
if STACK_INIT!(parser, tag_directives, yaml_tag_directive_t).ok {
|
||||
token = PEEK_TOKEN(parser);
|
||||
if !token.is_null() {
|
||||
loop {
|
||||
if !((*token).type_ == YAML_VERSION_DIRECTIVE_TOKEN
|
||||
|| (*token).type_ == YAML_TAG_DIRECTIVE_TOKEN)
|
||||
STACK_INIT!(parser, tag_directives, yaml_tag_directive_t);
|
||||
token = PEEK_TOKEN(parser);
|
||||
if !token.is_null() {
|
||||
loop {
|
||||
if !((*token).type_ == YAML_VERSION_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;
|
||||
}
|
||||
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
|
||||
{
|
||||
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() {
|
||||
if PUSH!(parser, tag_directives, value).fail {
|
||||
current_block = 17143798186130252483;
|
||||
break;
|
||||
}
|
||||
}
|
||||
match current_block {
|
||||
17143798186130252483 => {}
|
||||
_ => {
|
||||
default_tag_directive = default_tag_directives.as_mut_ptr();
|
||||
loop {
|
||||
if (*default_tag_directive).handle.is_null() {
|
||||
current_block = 18377268871191777778;
|
||||
break;
|
||||
}
|
||||
if yaml_parser_append_tag_directive(
|
||||
parser,
|
||||
*default_tag_directive,
|
||||
true,
|
||||
(*token).start_mark,
|
||||
)
|
||||
.fail
|
||||
{
|
||||
current_block = 17143798186130252483;
|
||||
break;
|
||||
}
|
||||
default_tag_directive = default_tag_directive.wrapping_offset(1);
|
||||
SKIP_TOKEN(parser);
|
||||
token = PEEK_TOKEN(parser);
|
||||
if token.is_null() {
|
||||
current_block = 17143798186130252483;
|
||||
break;
|
||||
}
|
||||
}
|
||||
match current_block {
|
||||
17143798186130252483 => {}
|
||||
_ => {
|
||||
default_tag_directive = default_tag_directives.as_mut_ptr();
|
||||
loop {
|
||||
if (*default_tag_directive).handle.is_null() {
|
||||
current_block = 18377268871191777778;
|
||||
break;
|
||||
}
|
||||
match current_block {
|
||||
17143798186130252483 => {}
|
||||
_ => {
|
||||
if !version_directive_ref.is_null() {
|
||||
*version_directive_ref = version_directive;
|
||||
}
|
||||
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;
|
||||
if yaml_parser_append_tag_directive(
|
||||
parser,
|
||||
*default_tag_directive,
|
||||
true,
|
||||
(*token).start_mark,
|
||||
)
|
||||
.fail
|
||||
{
|
||||
current_block = 17143798186130252483;
|
||||
break;
|
||||
}
|
||||
default_tag_directive = default_tag_directive.wrapping_offset(1);
|
||||
}
|
||||
match current_block {
|
||||
17143798186130252483 => {}
|
||||
_ => {
|
||||
if !version_directive_ref.is_null() {
|
||||
*version_directive_ref = version_directive;
|
||||
}
|
||||
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…
Reference in a new issue