mirror of
https://github.com/simonask/libyaml-safer
synced 2024-11-14 23:57:12 +00:00
Eliminate redundant integer casts
This commit is contained in:
parent
d28ea5887b
commit
a0d51c55f6
10 changed files with 1882 additions and 2524 deletions
287
src/api.rs
287
src/api.rs
|
@ -30,28 +30,13 @@ pub unsafe fn yaml_get_version(
|
|||
*patch = 5_i32;
|
||||
}
|
||||
pub unsafe fn yaml_malloc(size: size_t) -> *mut libc::c_void {
|
||||
malloc(if size != 0 {
|
||||
size
|
||||
} else {
|
||||
1_i32 as libc::c_ulong
|
||||
})
|
||||
malloc(if size != 0 { size } else { 1_u64 })
|
||||
}
|
||||
pub unsafe fn yaml_realloc(ptr: *mut libc::c_void, size: size_t) -> *mut libc::c_void {
|
||||
if !ptr.is_null() {
|
||||
realloc(
|
||||
ptr,
|
||||
if size != 0 {
|
||||
size
|
||||
} else {
|
||||
1_i32 as libc::c_ulong
|
||||
},
|
||||
)
|
||||
realloc(ptr, if size != 0 { size } else { 1_u64 })
|
||||
} else {
|
||||
malloc(if size != 0 {
|
||||
size
|
||||
} else {
|
||||
1_i32 as libc::c_ulong
|
||||
})
|
||||
malloc(if size != 0 { size } else { 1_u64 })
|
||||
}
|
||||
}
|
||||
pub unsafe fn yaml_free(ptr: *mut libc::c_void) {
|
||||
|
@ -72,7 +57,7 @@ pub unsafe fn yaml_string_extend(
|
|||
) -> libc::c_int {
|
||||
let new_start: *mut yaml_char_t = yaml_realloc(
|
||||
*start as *mut libc::c_void,
|
||||
((*end).c_offset_from(*start) as libc::c_long * 2_i32 as libc::c_long) as size_t,
|
||||
((*end).c_offset_from(*start) as libc::c_long * 2_i64) as size_t,
|
||||
) as *mut yaml_char_t;
|
||||
if new_start.is_null() {
|
||||
return 0_i32;
|
||||
|
@ -84,9 +69,8 @@ pub unsafe fn yaml_string_extend(
|
|||
(*end).c_offset_from(*start) as libc::c_long as libc::c_ulong,
|
||||
);
|
||||
*pointer = new_start.wrapping_offset((*pointer).c_offset_from(*start) as libc::c_long as isize);
|
||||
*end = new_start.wrapping_offset(
|
||||
((*end).c_offset_from(*start) as libc::c_long * 2_i32 as libc::c_long) as isize,
|
||||
);
|
||||
*end =
|
||||
new_start.wrapping_offset(((*end).c_offset_from(*start) as libc::c_long * 2_i64) as isize);
|
||||
*start = new_start;
|
||||
1_i32
|
||||
}
|
||||
|
@ -130,7 +114,7 @@ pub unsafe fn yaml_stack_extend(
|
|||
let new_start: *mut libc::c_void = yaml_realloc(
|
||||
*start,
|
||||
((*end as *mut libc::c_char).c_offset_from(*start as *mut libc::c_char) as libc::c_long
|
||||
* 2_i32 as libc::c_long) as size_t,
|
||||
* 2_i64) as size_t,
|
||||
);
|
||||
if new_start.is_null() {
|
||||
return 0_i32;
|
||||
|
@ -141,7 +125,7 @@ pub unsafe fn yaml_stack_extend(
|
|||
) as *mut libc::c_void;
|
||||
*end = (new_start as *mut libc::c_char).wrapping_offset(
|
||||
((*end as *mut libc::c_char).c_offset_from(*start as *mut libc::c_char) as libc::c_long
|
||||
* 2_i32 as libc::c_long) as isize,
|
||||
* 2_i64) as isize,
|
||||
) as *mut libc::c_void;
|
||||
*start = new_start;
|
||||
1_i32
|
||||
|
@ -156,7 +140,7 @@ pub unsafe fn yaml_queue_extend(
|
|||
let new_start: *mut libc::c_void = yaml_realloc(
|
||||
*start,
|
||||
((*end as *mut libc::c_char).c_offset_from(*start as *mut libc::c_char) as libc::c_long
|
||||
* 2_i32 as libc::c_long) as size_t,
|
||||
* 2_i64) as size_t,
|
||||
);
|
||||
if new_start.is_null() {
|
||||
return 0_i32;
|
||||
|
@ -171,7 +155,7 @@ pub unsafe fn yaml_queue_extend(
|
|||
) as *mut libc::c_void;
|
||||
*end = (new_start as *mut libc::c_char).wrapping_offset(
|
||||
((*end as *mut libc::c_char).c_offset_from(*start as *mut libc::c_char) as libc::c_long
|
||||
* 2_i32 as libc::c_long) as isize,
|
||||
* 2_i64) as isize,
|
||||
) as *mut libc::c_void;
|
||||
*start = new_start;
|
||||
}
|
||||
|
@ -200,14 +184,14 @@ pub unsafe fn yaml_parser_initialize(mut parser: *mut yaml_parser_t) -> libc::c_
|
|||
size_of::<yaml_parser_t>() as libc::c_ulong,
|
||||
);
|
||||
let fresh0 = addr_of_mut!((*parser).raw_buffer.start);
|
||||
*fresh0 = yaml_malloc(16384_i32 as size_t) as *mut yaml_char_t;
|
||||
*fresh0 = yaml_malloc(16384_u64) as *mut yaml_char_t;
|
||||
if !(if !(*fresh0).is_null() {
|
||||
let fresh1 = addr_of_mut!((*parser).raw_buffer.pointer);
|
||||
*fresh1 = (*parser).raw_buffer.start;
|
||||
let fresh2 = addr_of_mut!((*parser).raw_buffer.last);
|
||||
*fresh2 = *fresh1;
|
||||
let fresh3 = addr_of_mut!((*parser).raw_buffer.end);
|
||||
*fresh3 = ((*parser).raw_buffer.start).wrapping_offset(16384_i32 as isize);
|
||||
*fresh3 = ((*parser).raw_buffer.start).wrapping_offset(16384_isize);
|
||||
1_i32
|
||||
} else {
|
||||
(*parser).error = YAML_MEMORY_ERROR;
|
||||
|
@ -230,16 +214,15 @@ pub unsafe fn yaml_parser_initialize(mut parser: *mut yaml_parser_t) -> libc::c_
|
|||
} == 0)
|
||||
{
|
||||
let fresh8 = addr_of_mut!((*parser).tokens.start);
|
||||
*fresh8 = yaml_malloc(
|
||||
(16_i32 as libc::c_ulong).wrapping_mul(size_of::<yaml_token_t>() as libc::c_ulong),
|
||||
) as *mut yaml_token_t;
|
||||
*fresh8 = yaml_malloc((16_u64).wrapping_mul(size_of::<yaml_token_t>() as libc::c_ulong))
|
||||
as *mut yaml_token_t;
|
||||
if !(if !(*fresh8).is_null() {
|
||||
let fresh9 = addr_of_mut!((*parser).tokens.tail);
|
||||
*fresh9 = (*parser).tokens.start;
|
||||
let fresh10 = addr_of_mut!((*parser).tokens.head);
|
||||
*fresh10 = *fresh9;
|
||||
let fresh11 = addr_of_mut!((*parser).tokens.end);
|
||||
*fresh11 = ((*parser).tokens.start).wrapping_offset(16_i32 as isize);
|
||||
*fresh11 = ((*parser).tokens.start).wrapping_offset(16_isize);
|
||||
1_i32
|
||||
} else {
|
||||
(*parser).error = YAML_MEMORY_ERROR;
|
||||
|
@ -247,15 +230,14 @@ pub unsafe fn yaml_parser_initialize(mut parser: *mut yaml_parser_t) -> libc::c_
|
|||
} == 0)
|
||||
{
|
||||
let fresh12 = addr_of_mut!((*parser).indents.start);
|
||||
*fresh12 = yaml_malloc(
|
||||
(16_i32 as libc::c_ulong)
|
||||
.wrapping_mul(size_of::<libc::c_int>() as libc::c_ulong),
|
||||
) as *mut libc::c_int;
|
||||
*fresh12 =
|
||||
yaml_malloc((16_u64).wrapping_mul(size_of::<libc::c_int>() as libc::c_ulong))
|
||||
as *mut libc::c_int;
|
||||
if !(if !(*fresh12).is_null() {
|
||||
let fresh13 = addr_of_mut!((*parser).indents.top);
|
||||
*fresh13 = (*parser).indents.start;
|
||||
let fresh14 = addr_of_mut!((*parser).indents.end);
|
||||
*fresh14 = ((*parser).indents.start).wrapping_offset(16_i32 as isize);
|
||||
*fresh14 = ((*parser).indents.start).wrapping_offset(16_isize);
|
||||
1_i32
|
||||
} else {
|
||||
(*parser).error = YAML_MEMORY_ERROR;
|
||||
|
@ -263,16 +245,14 @@ pub unsafe fn yaml_parser_initialize(mut parser: *mut yaml_parser_t) -> libc::c_
|
|||
} == 0)
|
||||
{
|
||||
let fresh15 = addr_of_mut!((*parser).simple_keys.start);
|
||||
*fresh15 = yaml_malloc((16_i32 as libc::c_ulong).wrapping_mul(size_of::<
|
||||
yaml_simple_key_t,
|
||||
>(
|
||||
)
|
||||
as libc::c_ulong)) as *mut yaml_simple_key_t;
|
||||
*fresh15 = yaml_malloc(
|
||||
(16_u64).wrapping_mul(size_of::<yaml_simple_key_t>() as libc::c_ulong),
|
||||
) as *mut yaml_simple_key_t;
|
||||
if !(if !(*fresh15).is_null() {
|
||||
let fresh16 = addr_of_mut!((*parser).simple_keys.top);
|
||||
*fresh16 = (*parser).simple_keys.start;
|
||||
let fresh17 = addr_of_mut!((*parser).simple_keys.end);
|
||||
*fresh17 = ((*parser).simple_keys.start).wrapping_offset(16_i32 as isize);
|
||||
*fresh17 = ((*parser).simple_keys.start).wrapping_offset(16_isize);
|
||||
1_i32
|
||||
} else {
|
||||
(*parser).error = YAML_MEMORY_ERROR;
|
||||
|
@ -280,17 +260,15 @@ pub unsafe fn yaml_parser_initialize(mut parser: *mut yaml_parser_t) -> libc::c_
|
|||
} == 0)
|
||||
{
|
||||
let fresh18 = addr_of_mut!((*parser).states.start);
|
||||
*fresh18 = yaml_malloc((16_i32 as libc::c_ulong).wrapping_mul(size_of::<
|
||||
yaml_parser_state_t,
|
||||
>(
|
||||
)
|
||||
as libc::c_ulong))
|
||||
as *mut yaml_parser_state_t;
|
||||
*fresh18 = yaml_malloc(
|
||||
(16_u64)
|
||||
.wrapping_mul(size_of::<yaml_parser_state_t>() as libc::c_ulong),
|
||||
) as *mut yaml_parser_state_t;
|
||||
if !(if !(*fresh18).is_null() {
|
||||
let fresh19 = addr_of_mut!((*parser).states.top);
|
||||
*fresh19 = (*parser).states.start;
|
||||
let fresh20 = addr_of_mut!((*parser).states.end);
|
||||
*fresh20 = ((*parser).states.start).wrapping_offset(16_i32 as isize);
|
||||
*fresh20 = ((*parser).states.start).wrapping_offset(16_isize);
|
||||
1_i32
|
||||
} else {
|
||||
(*parser).error = YAML_MEMORY_ERROR;
|
||||
|
@ -298,18 +276,14 @@ pub unsafe fn yaml_parser_initialize(mut parser: *mut yaml_parser_t) -> libc::c_
|
|||
} == 0)
|
||||
{
|
||||
let fresh21 = addr_of_mut!((*parser).marks.start);
|
||||
*fresh21 =
|
||||
yaml_malloc((16_i32 as libc::c_ulong).wrapping_mul(size_of::<
|
||||
yaml_mark_t,
|
||||
>(
|
||||
)
|
||||
as libc::c_ulong))
|
||||
as *mut yaml_mark_t;
|
||||
*fresh21 = yaml_malloc(
|
||||
(16_u64).wrapping_mul(size_of::<yaml_mark_t>() as libc::c_ulong),
|
||||
) as *mut yaml_mark_t;
|
||||
if !(if !(*fresh21).is_null() {
|
||||
let fresh22 = addr_of_mut!((*parser).marks.top);
|
||||
*fresh22 = (*parser).marks.start;
|
||||
let fresh23 = addr_of_mut!((*parser).marks.end);
|
||||
*fresh23 = ((*parser).marks.start).wrapping_offset(16_i32 as isize);
|
||||
*fresh23 = ((*parser).marks.start).wrapping_offset(16_isize);
|
||||
1_i32
|
||||
} else {
|
||||
(*parser).error = YAML_MEMORY_ERROR;
|
||||
|
@ -318,18 +292,16 @@ pub unsafe fn yaml_parser_initialize(mut parser: *mut yaml_parser_t) -> libc::c_
|
|||
{
|
||||
let fresh24 = addr_of_mut!((*parser).tag_directives.start);
|
||||
*fresh24 =
|
||||
yaml_malloc((16_i32 as libc::c_ulong).wrapping_mul(size_of::<
|
||||
yaml_tag_directive_t,
|
||||
>(
|
||||
)
|
||||
as libc::c_ulong))
|
||||
yaml_malloc((16_u64).wrapping_mul(
|
||||
size_of::<yaml_tag_directive_t>() as libc::c_ulong,
|
||||
))
|
||||
as *mut yaml_tag_directive_t;
|
||||
if !(if !(*fresh24).is_null() {
|
||||
let fresh25 = addr_of_mut!((*parser).tag_directives.top);
|
||||
*fresh25 = (*parser).tag_directives.start;
|
||||
let fresh26 = addr_of_mut!((*parser).tag_directives.end);
|
||||
*fresh26 = ((*parser).tag_directives.start)
|
||||
.wrapping_offset(16_i32 as isize);
|
||||
*fresh26 =
|
||||
((*parser).tag_directives.start).wrapping_offset(16_isize);
|
||||
1_i32
|
||||
} else {
|
||||
(*parser).error = YAML_MEMORY_ERROR;
|
||||
|
@ -492,7 +464,7 @@ unsafe fn yaml_string_read_handler(
|
|||
) -> libc::c_int {
|
||||
let parser: *mut yaml_parser_t = data as *mut yaml_parser_t;
|
||||
if (*parser).input.string.current == (*parser).input.string.end {
|
||||
*size_read = 0_i32 as size_t;
|
||||
*size_read = 0_u64;
|
||||
return 1_i32;
|
||||
}
|
||||
if size
|
||||
|
@ -560,14 +532,14 @@ pub unsafe fn yaml_emitter_initialize(mut emitter: *mut yaml_emitter_t) -> libc:
|
|||
size_of::<yaml_emitter_t>() as libc::c_ulong,
|
||||
);
|
||||
let fresh91 = addr_of_mut!((*emitter).buffer.start);
|
||||
*fresh91 = yaml_malloc(16384_i32 as size_t) as *mut yaml_char_t;
|
||||
*fresh91 = yaml_malloc(16384_u64) as *mut yaml_char_t;
|
||||
if !(if !(*fresh91).is_null() {
|
||||
let fresh92 = addr_of_mut!((*emitter).buffer.pointer);
|
||||
*fresh92 = (*emitter).buffer.start;
|
||||
let fresh93 = addr_of_mut!((*emitter).buffer.last);
|
||||
*fresh93 = *fresh92;
|
||||
let fresh94 = addr_of_mut!((*emitter).buffer.end);
|
||||
*fresh94 = ((*emitter).buffer.start).wrapping_offset(16384_i32 as isize);
|
||||
*fresh94 = ((*emitter).buffer.start).wrapping_offset(16384_isize);
|
||||
1_i32
|
||||
} else {
|
||||
(*emitter).error = YAML_MEMORY_ERROR;
|
||||
|
@ -592,14 +564,13 @@ pub unsafe fn yaml_emitter_initialize(mut emitter: *mut yaml_emitter_t) -> libc:
|
|||
{
|
||||
let fresh99 = addr_of_mut!((*emitter).states.start);
|
||||
*fresh99 = yaml_malloc(
|
||||
(16_i32 as libc::c_ulong)
|
||||
.wrapping_mul(size_of::<yaml_emitter_state_t>() as libc::c_ulong),
|
||||
(16_u64).wrapping_mul(size_of::<yaml_emitter_state_t>() as libc::c_ulong),
|
||||
) as *mut yaml_emitter_state_t;
|
||||
if !(if !(*fresh99).is_null() {
|
||||
let fresh100 = addr_of_mut!((*emitter).states.top);
|
||||
*fresh100 = (*emitter).states.start;
|
||||
let fresh101 = addr_of_mut!((*emitter).states.end);
|
||||
*fresh101 = ((*emitter).states.start).wrapping_offset(16_i32 as isize);
|
||||
*fresh101 = ((*emitter).states.start).wrapping_offset(16_isize);
|
||||
1_i32
|
||||
} else {
|
||||
(*emitter).error = YAML_MEMORY_ERROR;
|
||||
|
@ -607,17 +578,16 @@ pub unsafe fn yaml_emitter_initialize(mut emitter: *mut yaml_emitter_t) -> libc:
|
|||
} == 0)
|
||||
{
|
||||
let fresh102 = addr_of_mut!((*emitter).events.start);
|
||||
*fresh102 = yaml_malloc(
|
||||
(16_i32 as libc::c_ulong)
|
||||
.wrapping_mul(size_of::<yaml_event_t>() as libc::c_ulong),
|
||||
) as *mut yaml_event_t;
|
||||
*fresh102 =
|
||||
yaml_malloc((16_u64).wrapping_mul(size_of::<yaml_event_t>() as libc::c_ulong))
|
||||
as *mut yaml_event_t;
|
||||
if !(if !(*fresh102).is_null() {
|
||||
let fresh103 = addr_of_mut!((*emitter).events.tail);
|
||||
*fresh103 = (*emitter).events.start;
|
||||
let fresh104 = addr_of_mut!((*emitter).events.head);
|
||||
*fresh104 = *fresh103;
|
||||
let fresh105 = addr_of_mut!((*emitter).events.end);
|
||||
*fresh105 = ((*emitter).events.start).wrapping_offset(16_i32 as isize);
|
||||
*fresh105 = ((*emitter).events.start).wrapping_offset(16_isize);
|
||||
1_i32
|
||||
} else {
|
||||
(*emitter).error = YAML_MEMORY_ERROR;
|
||||
|
@ -625,16 +595,14 @@ pub unsafe fn yaml_emitter_initialize(mut emitter: *mut yaml_emitter_t) -> libc:
|
|||
} == 0)
|
||||
{
|
||||
let fresh106 = addr_of_mut!((*emitter).indents.start);
|
||||
*fresh106 = yaml_malloc((16_i32 as libc::c_ulong).wrapping_mul(size_of::<
|
||||
libc::c_int,
|
||||
>(
|
||||
)
|
||||
as libc::c_ulong)) as *mut libc::c_int;
|
||||
*fresh106 = yaml_malloc(
|
||||
(16_u64).wrapping_mul(size_of::<libc::c_int>() as libc::c_ulong),
|
||||
) as *mut libc::c_int;
|
||||
if !(if !(*fresh106).is_null() {
|
||||
let fresh107 = addr_of_mut!((*emitter).indents.top);
|
||||
*fresh107 = (*emitter).indents.start;
|
||||
let fresh108 = addr_of_mut!((*emitter).indents.end);
|
||||
*fresh108 = ((*emitter).indents.start).wrapping_offset(16_i32 as isize);
|
||||
*fresh108 = ((*emitter).indents.start).wrapping_offset(16_isize);
|
||||
1_i32
|
||||
} else {
|
||||
(*emitter).error = YAML_MEMORY_ERROR;
|
||||
|
@ -642,18 +610,15 @@ pub unsafe fn yaml_emitter_initialize(mut emitter: *mut yaml_emitter_t) -> libc:
|
|||
} == 0)
|
||||
{
|
||||
let fresh109 = addr_of_mut!((*emitter).tag_directives.start);
|
||||
*fresh109 = yaml_malloc((16_i32 as libc::c_ulong).wrapping_mul(size_of::<
|
||||
yaml_tag_directive_t,
|
||||
>(
|
||||
)
|
||||
as libc::c_ulong))
|
||||
as *mut yaml_tag_directive_t;
|
||||
*fresh109 = yaml_malloc(
|
||||
(16_u64)
|
||||
.wrapping_mul(size_of::<yaml_tag_directive_t>() as libc::c_ulong),
|
||||
) as *mut yaml_tag_directive_t;
|
||||
if !(if !(*fresh109).is_null() {
|
||||
let fresh110 = addr_of_mut!((*emitter).tag_directives.top);
|
||||
*fresh110 = (*emitter).tag_directives.start;
|
||||
let fresh111 = addr_of_mut!((*emitter).tag_directives.end);
|
||||
*fresh111 =
|
||||
((*emitter).tag_directives.start).wrapping_offset(16_i32 as isize);
|
||||
*fresh111 = ((*emitter).tag_directives.start).wrapping_offset(16_isize);
|
||||
1_i32
|
||||
} else {
|
||||
(*emitter).error = YAML_MEMORY_ERROR;
|
||||
|
@ -828,7 +793,7 @@ pub unsafe fn yaml_emitter_set_output_string(
|
|||
(*emitter).output.string.size = size;
|
||||
let fresh157 = addr_of_mut!((*emitter).output.string.size_written);
|
||||
*fresh157 = size_written;
|
||||
*size_written = 0_i32 as size_t;
|
||||
*size_written = 0_u64;
|
||||
}
|
||||
pub unsafe fn yaml_emitter_set_output(
|
||||
emitter: *mut yaml_emitter_t,
|
||||
|
@ -910,7 +875,7 @@ unsafe fn yaml_check_utf8(start: *const yaml_char_t, length: size_t) -> libc::c_
|
|||
let mut octet: libc::c_uchar;
|
||||
let mut value: libc::c_uint;
|
||||
let mut k: size_t;
|
||||
octet = *pointer.wrapping_offset(0_i32 as isize);
|
||||
octet = *pointer.wrapping_offset(0_isize);
|
||||
let width: libc::c_uint = (if octet as libc::c_int & 0x80_i32 == 0_i32 {
|
||||
1_i32
|
||||
} else if octet as libc::c_int & 0xe0_i32 == 0xc0_i32 {
|
||||
|
@ -939,7 +904,7 @@ unsafe fn yaml_check_utf8(start: *const yaml_char_t, length: size_t) -> libc::c_
|
|||
if pointer.wrapping_offset(width as isize) > end {
|
||||
return 0_i32;
|
||||
}
|
||||
k = 1_i32 as size_t;
|
||||
k = 1_u64;
|
||||
while k < width as libc::c_ulong {
|
||||
octet = *pointer.wrapping_offset(k as isize);
|
||||
if octet as libc::c_int & 0xc0_i32 != 0x80_i32 {
|
||||
|
@ -949,10 +914,10 @@ unsafe fn yaml_check_utf8(start: *const yaml_char_t, length: size_t) -> libc::c_
|
|||
(value << 6_i32).wrapping_add((octet as libc::c_int & 0x3f_i32) as libc::c_uint);
|
||||
k = k.wrapping_add(1);
|
||||
}
|
||||
if !(width == 1_i32 as libc::c_uint
|
||||
|| width == 2_i32 as libc::c_uint && value >= 0x80_i32 as libc::c_uint
|
||||
|| width == 3_i32 as libc::c_uint && value >= 0x800_i32 as libc::c_uint
|
||||
|| width == 4_i32 as libc::c_uint && value >= 0x10000_i32 as libc::c_uint)
|
||||
if !(width == 1_u32
|
||||
|| width == 2_u32 && value >= 0x80_i32 as libc::c_uint
|
||||
|| width == 3_u32 && value >= 0x800_i32 as libc::c_uint
|
||||
|| width == 4_u32 && value >= 0x10000_i32 as libc::c_uint)
|
||||
{
|
||||
return 0_i32;
|
||||
}
|
||||
|
@ -965,9 +930,9 @@ pub unsafe fn yaml_stream_start_event_initialize(
|
|||
encoding: yaml_encoding_t,
|
||||
) -> libc::c_int {
|
||||
let mark = yaml_mark_t {
|
||||
index: 0_i32 as size_t,
|
||||
line: 0_i32 as size_t,
|
||||
column: 0_i32 as size_t,
|
||||
index: 0_u64,
|
||||
line: 0_u64,
|
||||
column: 0_u64,
|
||||
};
|
||||
__assert!(!event.is_null());
|
||||
memset(
|
||||
|
@ -983,9 +948,9 @@ pub unsafe fn yaml_stream_start_event_initialize(
|
|||
}
|
||||
pub unsafe fn yaml_stream_end_event_initialize(mut event: *mut yaml_event_t) -> libc::c_int {
|
||||
let mark = yaml_mark_t {
|
||||
index: 0_i32 as size_t,
|
||||
line: 0_i32 as size_t,
|
||||
column: 0_i32 as size_t,
|
||||
index: 0_u64,
|
||||
line: 0_u64,
|
||||
column: 0_u64,
|
||||
};
|
||||
__assert!(!event.is_null());
|
||||
memset(
|
||||
|
@ -1010,9 +975,9 @@ pub unsafe fn yaml_document_start_event_initialize(
|
|||
error: YAML_NO_ERROR,
|
||||
};
|
||||
let mark = yaml_mark_t {
|
||||
index: 0_i32 as size_t,
|
||||
line: 0_i32 as size_t,
|
||||
column: 0_i32 as size_t,
|
||||
index: 0_u64,
|
||||
line: 0_u64,
|
||||
column: 0_u64,
|
||||
};
|
||||
let mut version_directive_copy: *mut yaml_version_directive_t =
|
||||
ptr::null_mut::<yaml_version_directive_t>();
|
||||
|
@ -1048,13 +1013,11 @@ pub unsafe fn yaml_document_start_event_initialize(
|
|||
if tag_directives_start != tag_directives_end {
|
||||
let mut tag_directive: *mut yaml_tag_directive_t;
|
||||
tag_directives_copy.start = yaml_malloc(
|
||||
(16_i32 as libc::c_ulong)
|
||||
.wrapping_mul(size_of::<yaml_tag_directive_t>() as libc::c_ulong),
|
||||
(16_u64).wrapping_mul(size_of::<yaml_tag_directive_t>() as libc::c_ulong),
|
||||
) as *mut yaml_tag_directive_t;
|
||||
if if !(tag_directives_copy.start).is_null() {
|
||||
tag_directives_copy.top = tag_directives_copy.start;
|
||||
tag_directives_copy.end =
|
||||
(tag_directives_copy.start).wrapping_offset(16_i32 as isize);
|
||||
tag_directives_copy.end = (tag_directives_copy.start).wrapping_offset(16_isize);
|
||||
1_i32
|
||||
} else {
|
||||
context.error = YAML_MEMORY_ERROR;
|
||||
|
@ -1164,9 +1127,9 @@ pub unsafe fn yaml_document_end_event_initialize(
|
|||
implicit: libc::c_int,
|
||||
) -> libc::c_int {
|
||||
let mark = yaml_mark_t {
|
||||
index: 0_i32 as size_t,
|
||||
line: 0_i32 as size_t,
|
||||
column: 0_i32 as size_t,
|
||||
index: 0_u64,
|
||||
line: 0_u64,
|
||||
column: 0_u64,
|
||||
};
|
||||
__assert!(!event.is_null());
|
||||
memset(
|
||||
|
@ -1185,9 +1148,9 @@ pub unsafe fn yaml_alias_event_initialize(
|
|||
anchor: *const yaml_char_t,
|
||||
) -> libc::c_int {
|
||||
let mark = yaml_mark_t {
|
||||
index: 0_i32 as size_t,
|
||||
line: 0_i32 as size_t,
|
||||
column: 0_i32 as size_t,
|
||||
index: 0_u64,
|
||||
line: 0_u64,
|
||||
column: 0_u64,
|
||||
};
|
||||
__assert!(!event.is_null());
|
||||
__assert!(!anchor.is_null());
|
||||
|
@ -1222,9 +1185,9 @@ pub unsafe fn yaml_scalar_event_initialize(
|
|||
) -> libc::c_int {
|
||||
let mut current_block: u64;
|
||||
let mark = yaml_mark_t {
|
||||
index: 0_i32 as size_t,
|
||||
line: 0_i32 as size_t,
|
||||
column: 0_i32 as size_t,
|
||||
index: 0_u64,
|
||||
line: 0_u64,
|
||||
column: 0_u64,
|
||||
};
|
||||
let mut anchor_copy: *mut yaml_char_t = ptr::null_mut::<yaml_char_t>();
|
||||
let mut tag_copy: *mut yaml_char_t = ptr::null_mut::<yaml_char_t>();
|
||||
|
@ -1317,9 +1280,9 @@ pub unsafe fn yaml_sequence_start_event_initialize(
|
|||
) -> libc::c_int {
|
||||
let mut current_block: u64;
|
||||
let mark = yaml_mark_t {
|
||||
index: 0_i32 as size_t,
|
||||
line: 0_i32 as size_t,
|
||||
column: 0_i32 as size_t,
|
||||
index: 0_u64,
|
||||
line: 0_u64,
|
||||
column: 0_u64,
|
||||
};
|
||||
let mut anchor_copy: *mut yaml_char_t = ptr::null_mut::<yaml_char_t>();
|
||||
let mut tag_copy: *mut yaml_char_t = ptr::null_mut::<yaml_char_t>();
|
||||
|
@ -1383,9 +1346,9 @@ pub unsafe fn yaml_sequence_start_event_initialize(
|
|||
}
|
||||
pub unsafe fn yaml_sequence_end_event_initialize(mut event: *mut yaml_event_t) -> libc::c_int {
|
||||
let mark = yaml_mark_t {
|
||||
index: 0_i32 as size_t,
|
||||
line: 0_i32 as size_t,
|
||||
column: 0_i32 as size_t,
|
||||
index: 0_u64,
|
||||
line: 0_u64,
|
||||
column: 0_u64,
|
||||
};
|
||||
__assert!(!event.is_null());
|
||||
memset(
|
||||
|
@ -1407,9 +1370,9 @@ pub unsafe fn yaml_mapping_start_event_initialize(
|
|||
) -> libc::c_int {
|
||||
let mut current_block: u64;
|
||||
let mark = yaml_mark_t {
|
||||
index: 0_i32 as size_t,
|
||||
line: 0_i32 as size_t,
|
||||
column: 0_i32 as size_t,
|
||||
index: 0_u64,
|
||||
line: 0_u64,
|
||||
column: 0_u64,
|
||||
};
|
||||
let mut anchor_copy: *mut yaml_char_t = ptr::null_mut::<yaml_char_t>();
|
||||
let mut tag_copy: *mut yaml_char_t = ptr::null_mut::<yaml_char_t>();
|
||||
|
@ -1473,9 +1436,9 @@ pub unsafe fn yaml_mapping_start_event_initialize(
|
|||
}
|
||||
pub unsafe fn yaml_mapping_end_event_initialize(mut event: *mut yaml_event_t) -> libc::c_int {
|
||||
let mark = yaml_mark_t {
|
||||
index: 0_i32 as size_t,
|
||||
line: 0_i32 as size_t,
|
||||
column: 0_i32 as size_t,
|
||||
index: 0_u64,
|
||||
line: 0_u64,
|
||||
column: 0_u64,
|
||||
};
|
||||
__assert!(!event.is_null());
|
||||
memset(
|
||||
|
@ -1555,21 +1518,20 @@ pub unsafe fn yaml_document_initialize(
|
|||
prefix: ptr::null_mut::<yaml_char_t>(),
|
||||
};
|
||||
let mark = yaml_mark_t {
|
||||
index: 0_i32 as size_t,
|
||||
line: 0_i32 as size_t,
|
||||
column: 0_i32 as size_t,
|
||||
index: 0_u64,
|
||||
line: 0_u64,
|
||||
column: 0_u64,
|
||||
};
|
||||
__assert!(!document.is_null());
|
||||
__assert!(
|
||||
!tag_directives_start.is_null() && !tag_directives_end.is_null()
|
||||
|| tag_directives_start == tag_directives_end
|
||||
);
|
||||
nodes.start = yaml_malloc(
|
||||
(16_i32 as libc::c_ulong).wrapping_mul(size_of::<yaml_node_t>() as libc::c_ulong),
|
||||
) as *mut yaml_node_t;
|
||||
nodes.start = yaml_malloc((16_u64).wrapping_mul(size_of::<yaml_node_t>() as libc::c_ulong))
|
||||
as *mut yaml_node_t;
|
||||
if !(if !(nodes.start).is_null() {
|
||||
nodes.top = nodes.start;
|
||||
nodes.end = (nodes.start).wrapping_offset(16_i32 as isize);
|
||||
nodes.end = (nodes.start).wrapping_offset(16_isize);
|
||||
1_i32
|
||||
} else {
|
||||
context.error = YAML_MEMORY_ERROR;
|
||||
|
@ -1596,15 +1558,14 @@ pub unsafe fn yaml_document_initialize(
|
|||
if tag_directives_start != tag_directives_end {
|
||||
let mut tag_directive: *mut yaml_tag_directive_t;
|
||||
tag_directives_copy.start =
|
||||
yaml_malloc((16_i32 as libc::c_ulong).wrapping_mul(size_of::<
|
||||
yaml_tag_directive_t,
|
||||
>(
|
||||
)
|
||||
as libc::c_ulong)) as *mut yaml_tag_directive_t;
|
||||
yaml_malloc(
|
||||
(16_u64)
|
||||
.wrapping_mul(size_of::<yaml_tag_directive_t>() as libc::c_ulong),
|
||||
) as *mut yaml_tag_directive_t;
|
||||
if if !(tag_directives_copy.start).is_null() {
|
||||
tag_directives_copy.top = tag_directives_copy.start;
|
||||
tag_directives_copy.end =
|
||||
(tag_directives_copy.start).wrapping_offset(16_i32 as isize);
|
||||
(tag_directives_copy.start).wrapping_offset(16_isize);
|
||||
1_i32
|
||||
} else {
|
||||
context.error = YAML_MEMORY_ERROR;
|
||||
|
@ -1781,7 +1742,7 @@ pub unsafe fn yaml_document_get_node(
|
|||
{
|
||||
return ((*document).nodes.start)
|
||||
.wrapping_offset(index as isize)
|
||||
.wrapping_offset(-(1_i32 as isize));
|
||||
.wrapping_offset(-(1_isize));
|
||||
}
|
||||
ptr::null_mut::<yaml_node_t>()
|
||||
}
|
||||
|
@ -1803,9 +1764,9 @@ pub unsafe fn yaml_document_add_scalar(
|
|||
error: YAML_NO_ERROR,
|
||||
};
|
||||
let mark = yaml_mark_t {
|
||||
index: 0_i32 as size_t,
|
||||
line: 0_i32 as size_t,
|
||||
column: 0_i32 as size_t,
|
||||
index: 0_u64,
|
||||
line: 0_u64,
|
||||
column: 0_u64,
|
||||
};
|
||||
let mut tag_copy: *mut yaml_char_t = ptr::null_mut::<yaml_char_t>();
|
||||
let mut value_copy: *mut yaml_char_t = ptr::null_mut::<yaml_char_t>();
|
||||
|
@ -1899,9 +1860,9 @@ pub unsafe fn yaml_document_add_sequence(
|
|||
error: YAML_NO_ERROR,
|
||||
};
|
||||
let mark = yaml_mark_t {
|
||||
index: 0_i32 as size_t,
|
||||
line: 0_i32 as size_t,
|
||||
column: 0_i32 as size_t,
|
||||
index: 0_u64,
|
||||
line: 0_u64,
|
||||
column: 0_u64,
|
||||
};
|
||||
let mut tag_copy: *mut yaml_char_t = ptr::null_mut::<yaml_char_t>();
|
||||
let mut items: Unnamed_30 = Unnamed_30 {
|
||||
|
@ -1937,13 +1898,12 @@ pub unsafe fn yaml_document_add_sequence(
|
|||
if !(yaml_check_utf8(tag, strlen(tag as *mut libc::c_char)) == 0) {
|
||||
tag_copy = yaml_strdup(tag);
|
||||
if !tag_copy.is_null() {
|
||||
items.start = yaml_malloc(
|
||||
(16_i32 as libc::c_ulong)
|
||||
.wrapping_mul(size_of::<yaml_node_item_t>() as libc::c_ulong),
|
||||
) as *mut yaml_node_item_t;
|
||||
items.start =
|
||||
yaml_malloc((16_u64).wrapping_mul(size_of::<yaml_node_item_t>() as libc::c_ulong))
|
||||
as *mut yaml_node_item_t;
|
||||
if !(if !(items.start).is_null() {
|
||||
items.top = items.start;
|
||||
items.end = (items.start).wrapping_offset(16_i32 as isize);
|
||||
items.end = (items.start).wrapping_offset(16_isize);
|
||||
1_i32
|
||||
} else {
|
||||
context.error = YAML_MEMORY_ERROR;
|
||||
|
@ -2002,9 +1962,9 @@ pub unsafe fn yaml_document_add_mapping(
|
|||
error: YAML_NO_ERROR,
|
||||
};
|
||||
let mark = yaml_mark_t {
|
||||
index: 0_i32 as size_t,
|
||||
line: 0_i32 as size_t,
|
||||
column: 0_i32 as size_t,
|
||||
index: 0_u64,
|
||||
line: 0_u64,
|
||||
column: 0_u64,
|
||||
};
|
||||
let mut tag_copy: *mut yaml_char_t = ptr::null_mut::<yaml_char_t>();
|
||||
let mut pairs: Unnamed_32 = Unnamed_32 {
|
||||
|
@ -2040,13 +2000,12 @@ pub unsafe fn yaml_document_add_mapping(
|
|||
if !(yaml_check_utf8(tag, strlen(tag as *mut libc::c_char)) == 0) {
|
||||
tag_copy = yaml_strdup(tag);
|
||||
if !tag_copy.is_null() {
|
||||
pairs.start = yaml_malloc(
|
||||
(16_i32 as libc::c_ulong)
|
||||
.wrapping_mul(size_of::<yaml_node_pair_t>() as libc::c_ulong),
|
||||
) as *mut yaml_node_pair_t;
|
||||
pairs.start =
|
||||
yaml_malloc((16_u64).wrapping_mul(size_of::<yaml_node_pair_t>() as libc::c_ulong))
|
||||
as *mut yaml_node_pair_t;
|
||||
if !(if !(pairs.start).is_null() {
|
||||
pairs.top = pairs.start;
|
||||
pairs.end = (pairs.start).wrapping_offset(16_i32 as isize);
|
||||
pairs.end = (pairs.start).wrapping_offset(16_isize);
|
||||
1_i32
|
||||
} else {
|
||||
context.error = YAML_MEMORY_ERROR;
|
||||
|
|
|
@ -89,30 +89,15 @@ unsafe fn unsafe_main() -> ExitCode {
|
|||
let mut tag: [libc::c_char; 256] = [0; 256];
|
||||
let implicit: libc::c_int;
|
||||
let style: libc::c_int;
|
||||
if strncmp(
|
||||
line,
|
||||
b"+STR\0" as *const u8 as *const libc::c_char,
|
||||
4_i32 as libc::c_ulong,
|
||||
) == 0_i32
|
||||
{
|
||||
if strncmp(line, b"+STR\0" as *const u8 as *const libc::c_char, 4_u64) == 0_i32 {
|
||||
ok = yaml_stream_start_event_initialize(event, YAML_UTF8_ENCODING);
|
||||
} else if strncmp(
|
||||
line,
|
||||
b"-STR\0" as *const u8 as *const libc::c_char,
|
||||
4_i32 as libc::c_ulong,
|
||||
) == 0_i32
|
||||
{
|
||||
} else if strncmp(line, b"-STR\0" as *const u8 as *const libc::c_char, 4_u64) == 0_i32 {
|
||||
ok = yaml_stream_end_event_initialize(event);
|
||||
} else if strncmp(
|
||||
line,
|
||||
b"+DOC\0" as *const u8 as *const libc::c_char,
|
||||
4_i32 as libc::c_ulong,
|
||||
) == 0_i32
|
||||
{
|
||||
} else if strncmp(line, b"+DOC\0" as *const u8 as *const libc::c_char, 4_u64) == 0_i32 {
|
||||
implicit = (strncmp(
|
||||
line.offset(4_i32 as isize),
|
||||
line.offset(4_isize),
|
||||
b" ---\0" as *const u8 as *const libc::c_char,
|
||||
4_i32 as libc::c_ulong,
|
||||
4_u64,
|
||||
) != 0_i32) as libc::c_int;
|
||||
ok = yaml_document_start_event_initialize(
|
||||
event,
|
||||
|
@ -121,24 +106,14 @@ unsafe fn unsafe_main() -> ExitCode {
|
|||
ptr::null_mut::<yaml_tag_directive_t>(),
|
||||
implicit,
|
||||
);
|
||||
} else if strncmp(
|
||||
line,
|
||||
b"-DOC\0" as *const u8 as *const libc::c_char,
|
||||
4_i32 as libc::c_ulong,
|
||||
) == 0_i32
|
||||
{
|
||||
} else if strncmp(line, b"-DOC\0" as *const u8 as *const libc::c_char, 4_u64) == 0_i32 {
|
||||
implicit = (strncmp(
|
||||
line.offset(4_i32 as isize),
|
||||
line.offset(4_isize),
|
||||
b" ...\0" as *const u8 as *const libc::c_char,
|
||||
4_i32 as libc::c_ulong,
|
||||
4_u64,
|
||||
) != 0_i32) as libc::c_int;
|
||||
ok = yaml_document_end_event_initialize(event, implicit);
|
||||
} else if strncmp(
|
||||
line,
|
||||
b"+MAP\0" as *const u8 as *const libc::c_char,
|
||||
4_i32 as libc::c_ulong,
|
||||
) == 0_i32
|
||||
{
|
||||
} else if strncmp(line, b"+MAP\0" as *const u8 as *const libc::c_char, 4_u64) == 0_i32 {
|
||||
style = YAML_BLOCK_MAPPING_STYLE as libc::c_int;
|
||||
ok = yaml_mapping_start_event_initialize(
|
||||
event,
|
||||
|
@ -148,19 +123,9 @@ unsafe fn unsafe_main() -> ExitCode {
|
|||
0_i32,
|
||||
style as yaml_mapping_style_t,
|
||||
);
|
||||
} else if strncmp(
|
||||
line,
|
||||
b"-MAP\0" as *const u8 as *const libc::c_char,
|
||||
4_i32 as libc::c_ulong,
|
||||
) == 0_i32
|
||||
{
|
||||
} else if strncmp(line, b"-MAP\0" as *const u8 as *const libc::c_char, 4_u64) == 0_i32 {
|
||||
ok = yaml_mapping_end_event_initialize(event);
|
||||
} else if strncmp(
|
||||
line,
|
||||
b"+SEQ\0" as *const u8 as *const libc::c_char,
|
||||
4_i32 as libc::c_ulong,
|
||||
) == 0_i32
|
||||
{
|
||||
} else if strncmp(line, b"+SEQ\0" as *const u8 as *const libc::c_char, 4_u64) == 0_i32 {
|
||||
style = YAML_BLOCK_SEQUENCE_STYLE as libc::c_int;
|
||||
ok = yaml_sequence_start_event_initialize(
|
||||
event,
|
||||
|
@ -170,19 +135,9 @@ unsafe fn unsafe_main() -> ExitCode {
|
|||
0_i32,
|
||||
style as yaml_sequence_style_t,
|
||||
);
|
||||
} else if strncmp(
|
||||
line,
|
||||
b"-SEQ\0" as *const u8 as *const libc::c_char,
|
||||
4_i32 as libc::c_ulong,
|
||||
) == 0_i32
|
||||
{
|
||||
} else if strncmp(line, b"-SEQ\0" as *const u8 as *const libc::c_char, 4_u64) == 0_i32 {
|
||||
ok = yaml_sequence_end_event_initialize(event);
|
||||
} else if strncmp(
|
||||
line,
|
||||
b"=VAL\0" as *const u8 as *const libc::c_char,
|
||||
4_i32 as libc::c_ulong,
|
||||
) == 0_i32
|
||||
{
|
||||
} else if strncmp(line, b"=VAL\0" as *const u8 as *const libc::c_char, 4_u64) == 0_i32 {
|
||||
let mut value: [libc::c_char; 1024] = [0; 1024];
|
||||
let mut style_0: libc::c_int = 0;
|
||||
get_value(line, value.as_mut_ptr(), &mut style_0);
|
||||
|
@ -200,12 +155,7 @@ unsafe fn unsafe_main() -> ExitCode {
|
|||
implicit,
|
||||
style_0 as yaml_scalar_style_t,
|
||||
);
|
||||
} else if strncmp(
|
||||
line,
|
||||
b"=ALI\0" as *const u8 as *const libc::c_char,
|
||||
4_i32 as libc::c_ulong,
|
||||
) == 0_i32
|
||||
{
|
||||
} else if strncmp(line, b"=ALI\0" as *const u8 as *const libc::c_char, 4_u64) == 0_i32 {
|
||||
ok = yaml_alias_event_initialize(
|
||||
event,
|
||||
get_anchor('*' as i32 as libc::c_char, line, anchor.as_mut_ptr())
|
||||
|
@ -350,10 +300,10 @@ pub unsafe fn get_tag(line: *mut libc::c_char, tag: *mut libc::c_char) -> *mut l
|
|||
}
|
||||
memcpy(
|
||||
tag as *mut libc::c_void,
|
||||
start.offset(1_i32 as isize) as *const libc::c_void,
|
||||
(end.offset_from(start) as libc::c_long - 1_i32 as libc::c_long) as libc::c_ulong,
|
||||
start.offset(1_isize) as *const libc::c_void,
|
||||
(end.offset_from(start) as libc::c_long - 1_i64) as libc::c_ulong,
|
||||
);
|
||||
*tag.offset((end.offset_from(start) as libc::c_long - 1_i32 as libc::c_long) as isize) =
|
||||
*tag.offset((end.offset_from(start) as libc::c_long - 1_i64) as isize) =
|
||||
'\0' as i32 as libc::c_char;
|
||||
tag
|
||||
}
|
||||
|
@ -367,10 +317,10 @@ pub unsafe fn get_value(
|
|||
let mut start: *mut libc::c_char = ptr::null_mut::<libc::c_char>();
|
||||
let end: *mut libc::c_char = line.offset(strlen(line) as isize);
|
||||
let mut current_block_8: u64;
|
||||
c = line.offset(4_i32 as isize);
|
||||
c = line.offset(4_isize);
|
||||
while c < end {
|
||||
if *c as libc::c_int == ' ' as i32 {
|
||||
start = c.offset(1_i32 as isize);
|
||||
start = c.offset(1_isize);
|
||||
if *start as libc::c_int == ':' as i32 {
|
||||
*style = YAML_PLAIN_SCALAR_STYLE as libc::c_int;
|
||||
current_block_8 = 17407779659766490442;
|
||||
|
|
|
@ -72,8 +72,8 @@ unsafe fn unsafe_main() -> ExitCode {
|
|||
let _ = writeln!(
|
||||
io::stderr(),
|
||||
"Line: {} Column: {}",
|
||||
((*parser).problem_mark.line).wrapping_add(1_i32 as libc::c_ulong),
|
||||
((*parser).problem_mark.column).wrapping_add(1_i32 as libc::c_ulong),
|
||||
((*parser).problem_mark.line).wrapping_add(1_u64),
|
||||
((*parser).problem_mark.column).wrapping_add(1_u64),
|
||||
);
|
||||
}
|
||||
return ExitCode::FAILURE;
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
use crate::externs::{memset, strcmp};
|
||||
use crate::yaml::{
|
||||
size_t, yaml_anchors_t, yaml_char_t, yaml_document_t, yaml_emitter_t, yaml_event_t,
|
||||
yaml_mark_t, yaml_node_item_t, yaml_node_pair_t, yaml_node_t, YAML_ALIAS_EVENT,
|
||||
YAML_ANY_ENCODING, YAML_DOCUMENT_END_EVENT, YAML_DOCUMENT_START_EVENT, YAML_MAPPING_END_EVENT,
|
||||
YAML_MAPPING_NODE, YAML_MAPPING_START_EVENT, 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_anchors_t, yaml_char_t, yaml_document_t, yaml_emitter_t, yaml_event_t, yaml_mark_t,
|
||||
yaml_node_item_t, yaml_node_pair_t, yaml_node_t, YAML_ALIAS_EVENT, YAML_ANY_ENCODING,
|
||||
YAML_DOCUMENT_END_EVENT, YAML_DOCUMENT_START_EVENT, YAML_MAPPING_END_EVENT, YAML_MAPPING_NODE,
|
||||
YAML_MAPPING_START_EVENT, 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 crate::{libc, yaml_document_delete, yaml_emitter_emit, yaml_free, yaml_malloc, PointerExt};
|
||||
use core::mem::{size_of, MaybeUninit};
|
||||
|
@ -15,9 +14,9 @@ pub unsafe fn yaml_emitter_open(mut emitter: *mut yaml_emitter_t) -> libc::c_int
|
|||
let mut event = MaybeUninit::<yaml_event_t>::uninit();
|
||||
let event = event.as_mut_ptr();
|
||||
let mark = yaml_mark_t {
|
||||
index: 0_i32 as size_t,
|
||||
line: 0_i32 as size_t,
|
||||
column: 0_i32 as size_t,
|
||||
index: 0_u64,
|
||||
line: 0_u64,
|
||||
column: 0_u64,
|
||||
};
|
||||
__assert!(!emitter.is_null());
|
||||
__assert!((*emitter).opened == 0);
|
||||
|
@ -40,9 +39,9 @@ pub unsafe fn yaml_emitter_close(mut emitter: *mut yaml_emitter_t) -> libc::c_in
|
|||
let mut event = MaybeUninit::<yaml_event_t>::uninit();
|
||||
let event = event.as_mut_ptr();
|
||||
let mark = yaml_mark_t {
|
||||
index: 0_i32 as size_t,
|
||||
line: 0_i32 as size_t,
|
||||
column: 0_i32 as size_t,
|
||||
index: 0_u64,
|
||||
line: 0_u64,
|
||||
column: 0_u64,
|
||||
};
|
||||
__assert!(!emitter.is_null());
|
||||
__assert!((*emitter).opened != 0);
|
||||
|
@ -71,9 +70,9 @@ pub unsafe fn yaml_emitter_dump(
|
|||
let mut event = MaybeUninit::<yaml_event_t>::uninit();
|
||||
let event = event.as_mut_ptr();
|
||||
let mark = yaml_mark_t {
|
||||
index: 0_i32 as size_t,
|
||||
line: 0_i32 as size_t,
|
||||
column: 0_i32 as size_t,
|
||||
index: 0_u64,
|
||||
line: 0_u64,
|
||||
column: 0_u64,
|
||||
};
|
||||
__assert!(!emitter.is_null());
|
||||
__assert!(!document.is_null());
|
||||
|
@ -202,7 +201,7 @@ unsafe fn yaml_emitter_delete_document_and_anchors(mut emitter: *mut yaml_emitte
|
|||
unsafe fn yaml_emitter_anchor_node(emitter: *mut yaml_emitter_t, index: libc::c_int) {
|
||||
let node: *mut yaml_node_t = ((*(*emitter).document).nodes.start)
|
||||
.wrapping_offset(index as isize)
|
||||
.wrapping_offset(-(1_i32 as isize));
|
||||
.wrapping_offset(-(1_isize));
|
||||
let mut item: *mut yaml_node_item_t;
|
||||
let mut pair: *mut yaml_node_pair_t;
|
||||
let fresh8 =
|
||||
|
@ -238,7 +237,7 @@ unsafe fn yaml_emitter_generate_anchor(
|
|||
_emitter: *mut yaml_emitter_t,
|
||||
anchor_id: libc::c_int,
|
||||
) -> *mut yaml_char_t {
|
||||
let anchor: *mut yaml_char_t = yaml_malloc(16_i32 as size_t) as *mut yaml_char_t;
|
||||
let anchor: *mut yaml_char_t = yaml_malloc(16_u64) as *mut yaml_char_t;
|
||||
if anchor.is_null() {
|
||||
return ptr::null_mut::<yaml_char_t>();
|
||||
}
|
||||
|
@ -249,7 +248,7 @@ unsafe fn yaml_emitter_generate_anchor(
|
|||
unsafe fn yaml_emitter_dump_node(emitter: *mut yaml_emitter_t, index: libc::c_int) -> libc::c_int {
|
||||
let node: *mut yaml_node_t = ((*(*emitter).document).nodes.start)
|
||||
.wrapping_offset(index as isize)
|
||||
.wrapping_offset(-(1_i32 as isize));
|
||||
.wrapping_offset(-(1_isize));
|
||||
let anchor_id: libc::c_int =
|
||||
(*((*emitter).anchors).wrapping_offset((index - 1_i32) as isize)).anchor;
|
||||
let mut anchor: *mut yaml_char_t = ptr::null_mut::<yaml_char_t>();
|
||||
|
@ -277,9 +276,9 @@ unsafe fn yaml_emitter_dump_alias(
|
|||
let mut event = MaybeUninit::<yaml_event_t>::uninit();
|
||||
let event = event.as_mut_ptr();
|
||||
let mark = yaml_mark_t {
|
||||
index: 0_i32 as size_t,
|
||||
line: 0_i32 as size_t,
|
||||
column: 0_i32 as size_t,
|
||||
index: 0_u64,
|
||||
line: 0_u64,
|
||||
column: 0_u64,
|
||||
};
|
||||
memset(
|
||||
event as *mut libc::c_void,
|
||||
|
@ -300,9 +299,9 @@ unsafe fn yaml_emitter_dump_scalar(
|
|||
let mut event = MaybeUninit::<yaml_event_t>::uninit();
|
||||
let event = event.as_mut_ptr();
|
||||
let mark = yaml_mark_t {
|
||||
index: 0_i32 as size_t,
|
||||
line: 0_i32 as size_t,
|
||||
column: 0_i32 as size_t,
|
||||
index: 0_u64,
|
||||
line: 0_u64,
|
||||
column: 0_u64,
|
||||
};
|
||||
let plain_implicit: libc::c_int = (strcmp(
|
||||
(*node).tag as *mut libc::c_char,
|
||||
|
@ -337,9 +336,9 @@ unsafe fn yaml_emitter_dump_sequence(
|
|||
let mut event = MaybeUninit::<yaml_event_t>::uninit();
|
||||
let event = event.as_mut_ptr();
|
||||
let mark = yaml_mark_t {
|
||||
index: 0_i32 as size_t,
|
||||
line: 0_i32 as size_t,
|
||||
column: 0_i32 as size_t,
|
||||
index: 0_u64,
|
||||
line: 0_u64,
|
||||
column: 0_u64,
|
||||
};
|
||||
let implicit: libc::c_int = (strcmp(
|
||||
(*node).tag as *mut libc::c_char,
|
||||
|
@ -389,9 +388,9 @@ unsafe fn yaml_emitter_dump_mapping(
|
|||
let mut event = MaybeUninit::<yaml_event_t>::uninit();
|
||||
let event = event.as_mut_ptr();
|
||||
let mark = yaml_mark_t {
|
||||
index: 0_i32 as size_t,
|
||||
line: 0_i32 as size_t,
|
||||
column: 0_i32 as size_t,
|
||||
index: 0_u64,
|
||||
line: 0_u64,
|
||||
column: 0_u64,
|
||||
};
|
||||
let implicit: libc::c_int = (strcmp(
|
||||
(*node).tag as *mut libc::c_char,
|
||||
|
|
1121
src/emitter.rs
1121
src/emitter.rs
File diff suppressed because it is too large
Load diff
|
@ -49,14 +49,13 @@ pub unsafe fn yaml_parser_load(
|
|||
size_of::<yaml_document_t>() as libc::c_ulong,
|
||||
);
|
||||
let fresh0 = addr_of_mut!((*document).nodes.start);
|
||||
*fresh0 = yaml_malloc(
|
||||
(16_i32 as libc::c_ulong).wrapping_mul(size_of::<yaml_node_t>() as libc::c_ulong),
|
||||
) as *mut yaml_node_t;
|
||||
*fresh0 = yaml_malloc((16_u64).wrapping_mul(size_of::<yaml_node_t>() as libc::c_ulong))
|
||||
as *mut yaml_node_t;
|
||||
if !(if !(*fresh0).is_null() {
|
||||
let fresh1 = addr_of_mut!((*document).nodes.top);
|
||||
*fresh1 = (*document).nodes.start;
|
||||
let fresh2 = addr_of_mut!((*document).nodes.end);
|
||||
*fresh2 = ((*document).nodes.start).wrapping_offset(16_i32 as isize);
|
||||
*fresh2 = ((*document).nodes.start).wrapping_offset(16_isize);
|
||||
1_i32
|
||||
} else {
|
||||
(*parser).error = YAML_MEMORY_ERROR;
|
||||
|
@ -89,16 +88,14 @@ pub unsafe fn yaml_parser_load(
|
|||
return 1_i32;
|
||||
}
|
||||
let fresh3 = addr_of_mut!((*parser).aliases.start);
|
||||
*fresh3 = yaml_malloc((16_i32 as libc::c_ulong).wrapping_mul(size_of::<
|
||||
yaml_alias_data_t,
|
||||
>(
|
||||
)
|
||||
as libc::c_ulong)) as *mut yaml_alias_data_t;
|
||||
*fresh3 = yaml_malloc(
|
||||
(16_u64).wrapping_mul(size_of::<yaml_alias_data_t>() as libc::c_ulong),
|
||||
) as *mut yaml_alias_data_t;
|
||||
if !(if !(*fresh3).is_null() {
|
||||
let fresh4 = addr_of_mut!((*parser).aliases.top);
|
||||
*fresh4 = (*parser).aliases.start;
|
||||
let fresh5 = addr_of_mut!((*parser).aliases.end);
|
||||
*fresh5 = ((*parser).aliases.start).wrapping_offset(16_i32 as isize);
|
||||
*fresh5 = ((*parser).aliases.start).wrapping_offset(16_isize);
|
||||
1_i32
|
||||
} else {
|
||||
(*parser).error = YAML_MEMORY_ERROR;
|
||||
|
@ -185,12 +182,11 @@ 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;
|
||||
ctx.start = yaml_malloc(
|
||||
(16_i32 as libc::c_ulong).wrapping_mul(size_of::<libc::c_int>() as libc::c_ulong),
|
||||
) as *mut libc::c_int;
|
||||
ctx.start = yaml_malloc((16_u64).wrapping_mul(size_of::<libc::c_int>() as libc::c_ulong))
|
||||
as *mut libc::c_int;
|
||||
if if !(ctx.start).is_null() {
|
||||
ctx.top = ctx.start;
|
||||
ctx.end = (ctx.start).wrapping_offset(16_i32 as isize);
|
||||
ctx.end = (ctx.start).wrapping_offset(16_isize);
|
||||
1_i32
|
||||
} else {
|
||||
(*parser).error = YAML_MEMORY_ERROR;
|
||||
|
@ -338,7 +334,7 @@ unsafe fn yaml_parser_load_node_add(
|
|||
if (*ctx).start == (*ctx).top {
|
||||
return 1_i32;
|
||||
}
|
||||
let parent_index: libc::c_int = *((*ctx).top).wrapping_offset(-(1_i32 as isize));
|
||||
let parent_index: libc::c_int = *((*ctx).top).wrapping_offset(-(1_isize));
|
||||
let parent: *mut yaml_node_t = addr_of_mut!(
|
||||
*((*(*parser).document).nodes.start).wrapping_offset((parent_index - 1_i32) as isize)
|
||||
);
|
||||
|
@ -382,7 +378,7 @@ unsafe fn yaml_parser_load_node_add(
|
|||
let mut pair = yaml_node_pair_t { key: 0, value: 0 };
|
||||
if !((*parent).data.mapping.pairs.start == (*parent).data.mapping.pairs.top) {
|
||||
let mut p: *mut yaml_node_pair_t =
|
||||
((*parent).data.mapping.pairs.top).wrapping_offset(-(1_i32 as isize));
|
||||
((*parent).data.mapping.pairs.top).wrapping_offset(-(1_isize));
|
||||
if (*p).key != 0_i32 && (*p).value == 0_i32 {
|
||||
(*p).value = index;
|
||||
current_block_17 = 11307063007268554308;
|
||||
|
@ -639,12 +635,11 @@ unsafe fn yaml_parser_load_sequence(
|
|||
13474536459355229096 => {}
|
||||
_ => {
|
||||
items.start = yaml_malloc(
|
||||
(16_i32 as libc::c_ulong)
|
||||
.wrapping_mul(size_of::<yaml_node_item_t>() as libc::c_ulong),
|
||||
(16_u64).wrapping_mul(size_of::<yaml_node_item_t>() as libc::c_ulong),
|
||||
) as *mut yaml_node_item_t;
|
||||
if !(if !(items.start).is_null() {
|
||||
items.top = items.start;
|
||||
items.end = (items.start).wrapping_offset(16_i32 as isize);
|
||||
items.end = (items.start).wrapping_offset(16_isize);
|
||||
1_i32
|
||||
} else {
|
||||
(*parser).error = YAML_MEMORY_ERROR;
|
||||
|
@ -741,8 +736,8 @@ unsafe fn yaml_parser_load_sequence_end(
|
|||
event: *mut yaml_event_t,
|
||||
ctx: *mut loader_ctx,
|
||||
) -> libc::c_int {
|
||||
__assert!(((*ctx).top).c_offset_from((*ctx).start) as libc::c_long > 0_i32 as libc::c_long);
|
||||
let index: libc::c_int = *((*ctx).top).wrapping_offset(-(1_i32 as isize));
|
||||
__assert!(((*ctx).top).c_offset_from((*ctx).start) as libc::c_long > 0_i64);
|
||||
let index: libc::c_int = *((*ctx).top).wrapping_offset(-(1_isize));
|
||||
__assert!(
|
||||
(*((*(*parser).document).nodes.start).wrapping_offset((index - 1_i32) as isize)).type_0
|
||||
as libc::c_uint
|
||||
|
@ -820,12 +815,11 @@ unsafe fn yaml_parser_load_mapping(
|
|||
13635467803606088781 => {}
|
||||
_ => {
|
||||
pairs.start = yaml_malloc(
|
||||
(16_i32 as libc::c_ulong)
|
||||
.wrapping_mul(size_of::<yaml_node_pair_t>() as libc::c_ulong),
|
||||
(16_u64).wrapping_mul(size_of::<yaml_node_pair_t>() as libc::c_ulong),
|
||||
) as *mut yaml_node_pair_t;
|
||||
if !(if !(pairs.start).is_null() {
|
||||
pairs.top = pairs.start;
|
||||
pairs.end = (pairs.start).wrapping_offset(16_i32 as isize);
|
||||
pairs.end = (pairs.start).wrapping_offset(16_isize);
|
||||
1_i32
|
||||
} else {
|
||||
(*parser).error = YAML_MEMORY_ERROR;
|
||||
|
@ -922,8 +916,8 @@ unsafe fn yaml_parser_load_mapping_end(
|
|||
event: *mut yaml_event_t,
|
||||
ctx: *mut loader_ctx,
|
||||
) -> libc::c_int {
|
||||
__assert!(((*ctx).top).c_offset_from((*ctx).start) as libc::c_long > 0_i32 as libc::c_long);
|
||||
let index: libc::c_int = *((*ctx).top).wrapping_offset(-(1_i32 as isize));
|
||||
__assert!(((*ctx).top).c_offset_from((*ctx).start) as libc::c_long > 0_i64);
|
||||
let index: libc::c_int = *((*ctx).top).wrapping_offset(-(1_isize));
|
||||
__assert!(
|
||||
(*((*(*parser).document).nodes.start).wrapping_offset((index - 1_i32) as isize)).type_0
|
||||
as libc::c_uint
|
||||
|
|
|
@ -354,12 +354,10 @@ unsafe fn yaml_parser_parse_document_start(
|
|||
yaml_free(version_directive as *mut libc::c_void);
|
||||
while tag_directives.start != tag_directives.end {
|
||||
yaml_free(
|
||||
(*(tag_directives.end).wrapping_offset(-1_i32 as isize)).handle
|
||||
as *mut libc::c_void,
|
||||
(*(tag_directives.end).wrapping_offset(-1_isize)).handle as *mut libc::c_void,
|
||||
);
|
||||
yaml_free(
|
||||
(*(tag_directives.end).wrapping_offset(-1_i32 as isize)).prefix
|
||||
as *mut libc::c_void,
|
||||
(*(tag_directives.end).wrapping_offset(-1_isize)).prefix as *mut libc::c_void,
|
||||
);
|
||||
tag_directives.end = (tag_directives.end).wrapping_offset(-1);
|
||||
}
|
||||
|
@ -647,9 +645,7 @@ unsafe fn yaml_parser_parse_node(
|
|||
strlen((*tag_directive).prefix as *mut libc::c_char);
|
||||
let suffix_len: size_t = strlen(tag_suffix as *mut libc::c_char);
|
||||
tag = yaml_malloc(
|
||||
prefix_len
|
||||
.wrapping_add(suffix_len)
|
||||
.wrapping_add(1_i32 as libc::c_ulong),
|
||||
prefix_len.wrapping_add(suffix_len).wrapping_add(1_u64),
|
||||
) as *mut yaml_char_t;
|
||||
if tag.is_null() {
|
||||
(*parser).error = YAML_MEMORY_ERROR;
|
||||
|
@ -862,12 +858,11 @@ unsafe fn yaml_parser_parse_node(
|
|||
(*event).data.mapping_start.style = YAML_BLOCK_MAPPING_STYLE;
|
||||
return 1_i32;
|
||||
} else if !anchor.is_null() || !tag.is_null() {
|
||||
let value: *mut yaml_char_t =
|
||||
yaml_malloc(1_i32 as size_t) as *mut yaml_char_t;
|
||||
let value: *mut yaml_char_t = yaml_malloc(1_u64) as *mut yaml_char_t;
|
||||
if value.is_null() {
|
||||
(*parser).error = YAML_MEMORY_ERROR;
|
||||
} else {
|
||||
*value.wrapping_offset(0_i32 as isize) = '\0' as i32 as yaml_char_t;
|
||||
*value.wrapping_offset(0_isize) = '\0' as i32 as yaml_char_t;
|
||||
let fresh53 = addr_of_mut!((*parser).states.top);
|
||||
*fresh53 = (*fresh53).wrapping_offset(-1);
|
||||
(*parser).state = **fresh53;
|
||||
|
@ -885,7 +880,7 @@ unsafe fn yaml_parser_parse_node(
|
|||
*fresh55 = tag;
|
||||
let fresh56 = addr_of_mut!((*event).data.scalar.value);
|
||||
*fresh56 = value;
|
||||
(*event).data.scalar.length = 0_i32 as size_t;
|
||||
(*event).data.scalar.length = 0_u64;
|
||||
(*event).data.scalar.plain_implicit = implicit;
|
||||
(*event).data.scalar.quoted_implicit = 0_i32;
|
||||
(*event).data.scalar.style = YAML_PLAIN_SCALAR_STYLE;
|
||||
|
@ -1863,12 +1858,12 @@ unsafe fn yaml_parser_process_empty_scalar(
|
|||
mut event: *mut yaml_event_t,
|
||||
mark: yaml_mark_t,
|
||||
) -> libc::c_int {
|
||||
let value: *mut yaml_char_t = yaml_malloc(1_i32 as size_t) as *mut yaml_char_t;
|
||||
let value: *mut yaml_char_t = yaml_malloc(1_u64) as *mut yaml_char_t;
|
||||
if value.is_null() {
|
||||
(*parser).error = YAML_MEMORY_ERROR;
|
||||
return 0_i32;
|
||||
}
|
||||
*value.wrapping_offset(0_i32 as isize) = '\0' as i32 as yaml_char_t;
|
||||
*value.wrapping_offset(0_isize) = '\0' as i32 as yaml_char_t;
|
||||
memset(
|
||||
event as *mut libc::c_void,
|
||||
0_i32,
|
||||
|
@ -1883,7 +1878,7 @@ unsafe fn yaml_parser_process_empty_scalar(
|
|||
*fresh139 = ptr::null_mut::<yaml_char_t>();
|
||||
let fresh140 = addr_of_mut!((*event).data.scalar.value);
|
||||
*fresh140 = value;
|
||||
(*event).data.scalar.length = 0_i32 as size_t;
|
||||
(*event).data.scalar.length = 0_u64;
|
||||
(*event).data.scalar.plain_implicit = 1_i32;
|
||||
(*event).data.scalar.quoted_implicit = 0_i32;
|
||||
(*event).data.scalar.style = YAML_PLAIN_SCALAR_STYLE;
|
||||
|
@ -1919,12 +1914,12 @@ unsafe fn yaml_parser_process_directives(
|
|||
top: ptr::null_mut::<yaml_tag_directive_t>(),
|
||||
};
|
||||
let mut token: *mut yaml_token_t;
|
||||
tag_directives.start = yaml_malloc(
|
||||
(16_i32 as libc::c_ulong).wrapping_mul(size_of::<yaml_tag_directive_t>() as libc::c_ulong),
|
||||
) as *mut yaml_tag_directive_t;
|
||||
tag_directives.start =
|
||||
yaml_malloc((16_u64).wrapping_mul(size_of::<yaml_tag_directive_t>() as libc::c_ulong))
|
||||
as *mut yaml_tag_directive_t;
|
||||
if !(if !(tag_directives.start).is_null() {
|
||||
tag_directives.top = tag_directives.start;
|
||||
tag_directives.end = (tag_directives.start).wrapping_offset(16_i32 as isize);
|
||||
tag_directives.end = (tag_directives.start).wrapping_offset(16_isize);
|
||||
1_i32
|
||||
} else {
|
||||
(*parser).error = YAML_MEMORY_ERROR;
|
||||
|
|
|
@ -20,63 +20,60 @@ unsafe fn yaml_parser_set_reader_error(
|
|||
unsafe fn yaml_parser_determine_encoding(mut parser: *mut yaml_parser_t) -> libc::c_int {
|
||||
while (*parser).eof == 0
|
||||
&& (((*parser).raw_buffer.last).c_offset_from((*parser).raw_buffer.pointer) as libc::c_long)
|
||||
< 3_i32 as libc::c_long
|
||||
< 3_i64
|
||||
{
|
||||
if yaml_parser_update_raw_buffer(parser) == 0 {
|
||||
return 0_i32;
|
||||
}
|
||||
}
|
||||
if ((*parser).raw_buffer.last).c_offset_from((*parser).raw_buffer.pointer) as libc::c_long
|
||||
>= 2_i32 as libc::c_long
|
||||
>= 2_i64
|
||||
&& memcmp(
|
||||
(*parser).raw_buffer.pointer as *const libc::c_void,
|
||||
b"\xFF\xFE\0" as *const u8 as *const libc::c_char as *const libc::c_void,
|
||||
2_i32 as libc::c_ulong,
|
||||
2_u64,
|
||||
) == 0
|
||||
{
|
||||
(*parser).encoding = YAML_UTF16LE_ENCODING;
|
||||
let fresh1 = addr_of_mut!((*parser).raw_buffer.pointer);
|
||||
*fresh1 = (*fresh1).wrapping_offset(2_i32 as isize);
|
||||
*fresh1 = (*fresh1).wrapping_offset(2_isize);
|
||||
let fresh2 = addr_of_mut!((*parser).offset);
|
||||
*fresh2 =
|
||||
(*fresh2 as libc::c_ulong).wrapping_add(2_i32 as libc::c_ulong) as size_t as size_t;
|
||||
*fresh2 = (*fresh2 as libc::c_ulong).wrapping_add(2_u64) as size_t as size_t;
|
||||
} else if ((*parser).raw_buffer.last).c_offset_from((*parser).raw_buffer.pointer)
|
||||
as libc::c_long
|
||||
>= 2_i32 as libc::c_long
|
||||
>= 2_i64
|
||||
&& memcmp(
|
||||
(*parser).raw_buffer.pointer as *const libc::c_void,
|
||||
b"\xFE\xFF\0" as *const u8 as *const libc::c_char as *const libc::c_void,
|
||||
2_i32 as libc::c_ulong,
|
||||
2_u64,
|
||||
) == 0
|
||||
{
|
||||
(*parser).encoding = YAML_UTF16BE_ENCODING;
|
||||
let fresh3 = addr_of_mut!((*parser).raw_buffer.pointer);
|
||||
*fresh3 = (*fresh3).wrapping_offset(2_i32 as isize);
|
||||
*fresh3 = (*fresh3).wrapping_offset(2_isize);
|
||||
let fresh4 = addr_of_mut!((*parser).offset);
|
||||
*fresh4 =
|
||||
(*fresh4 as libc::c_ulong).wrapping_add(2_i32 as libc::c_ulong) as size_t as size_t;
|
||||
*fresh4 = (*fresh4 as libc::c_ulong).wrapping_add(2_u64) as size_t as size_t;
|
||||
} else if ((*parser).raw_buffer.last).c_offset_from((*parser).raw_buffer.pointer)
|
||||
as libc::c_long
|
||||
>= 3_i32 as libc::c_long
|
||||
>= 3_i64
|
||||
&& memcmp(
|
||||
(*parser).raw_buffer.pointer as *const libc::c_void,
|
||||
b"\xEF\xBB\xBF\0" as *const u8 as *const libc::c_char as *const libc::c_void,
|
||||
3_i32 as libc::c_ulong,
|
||||
3_u64,
|
||||
) == 0
|
||||
{
|
||||
(*parser).encoding = YAML_UTF8_ENCODING;
|
||||
let fresh5 = addr_of_mut!((*parser).raw_buffer.pointer);
|
||||
*fresh5 = (*fresh5).wrapping_offset(3_i32 as isize);
|
||||
*fresh5 = (*fresh5).wrapping_offset(3_isize);
|
||||
let fresh6 = addr_of_mut!((*parser).offset);
|
||||
*fresh6 =
|
||||
(*fresh6 as libc::c_ulong).wrapping_add(3_i32 as libc::c_ulong) as size_t as size_t;
|
||||
*fresh6 = (*fresh6 as libc::c_ulong).wrapping_add(3_u64) as size_t as size_t;
|
||||
} else {
|
||||
(*parser).encoding = YAML_UTF8_ENCODING;
|
||||
}
|
||||
1_i32
|
||||
}
|
||||
unsafe fn yaml_parser_update_raw_buffer(mut parser: *mut yaml_parser_t) -> libc::c_int {
|
||||
let mut size_read: size_t = 0_i32 as size_t;
|
||||
let mut size_read: size_t = 0_u64;
|
||||
if (*parser).raw_buffer.start == (*parser).raw_buffer.pointer
|
||||
&& (*parser).raw_buffer.last == (*parser).raw_buffer.end
|
||||
{
|
||||
|
@ -166,11 +163,11 @@ pub unsafe fn yaml_parser_update_buffer(parser: *mut yaml_parser_t, length: size
|
|||
}
|
||||
first = 0_i32;
|
||||
while (*parser).raw_buffer.pointer != (*parser).raw_buffer.last {
|
||||
let mut value: libc::c_uint = 0_i32 as libc::c_uint;
|
||||
let mut value: libc::c_uint = 0_u32;
|
||||
let value2: libc::c_uint;
|
||||
let mut incomplete: libc::c_int = 0_i32;
|
||||
let mut octet: libc::c_uchar;
|
||||
let mut width: libc::c_uint = 0_i32 as libc::c_uint;
|
||||
let mut width: libc::c_uint = 0_u32;
|
||||
let low: libc::c_int;
|
||||
let high: libc::c_int;
|
||||
let mut k: size_t;
|
||||
|
@ -179,7 +176,7 @@ pub unsafe fn yaml_parser_update_buffer(parser: *mut yaml_parser_t, length: size
|
|||
as libc::c_long as size_t;
|
||||
match (*parser).encoding as libc::c_uint {
|
||||
1 => {
|
||||
octet = *((*parser).raw_buffer.pointer).wrapping_offset(0_i32 as isize);
|
||||
octet = *((*parser).raw_buffer.pointer).wrapping_offset(0_isize);
|
||||
width = (if octet as libc::c_int & 0x80_i32 == 0_i32 {
|
||||
1_i32
|
||||
} else if octet as libc::c_int & 0xe0_i32 == 0xc0_i32 {
|
||||
|
@ -222,7 +219,7 @@ pub unsafe fn yaml_parser_update_buffer(parser: *mut yaml_parser_t, length: size
|
|||
} else {
|
||||
0_i32
|
||||
}) as libc::c_uint;
|
||||
k = 1_i32 as size_t;
|
||||
k = 1_u64;
|
||||
while k < width as libc::c_ulong {
|
||||
octet = *((*parser).raw_buffer.pointer).wrapping_offset(k as isize);
|
||||
if octet as libc::c_int & 0xc0_i32 != 0x80_i32 {
|
||||
|
@ -238,11 +235,10 @@ pub unsafe fn yaml_parser_update_buffer(parser: *mut yaml_parser_t, length: size
|
|||
.wrapping_add((octet as libc::c_int & 0x3f_i32) as libc::c_uint);
|
||||
k = k.wrapping_add(1);
|
||||
}
|
||||
if !(width == 1_i32 as libc::c_uint
|
||||
|| width == 2_i32 as libc::c_uint && value >= 0x80_i32 as libc::c_uint
|
||||
|| width == 3_i32 as libc::c_uint && value >= 0x800_i32 as libc::c_uint
|
||||
|| width == 4_i32 as libc::c_uint
|
||||
&& value >= 0x10000_i32 as libc::c_uint)
|
||||
if !(width == 1_u32
|
||||
|| width == 2_u32 && value >= 0x80_i32 as libc::c_uint
|
||||
|| width == 3_u32 && value >= 0x800_i32 as libc::c_uint
|
||||
|| width == 4_u32 && value >= 0x10000_i32 as libc::c_uint)
|
||||
{
|
||||
return yaml_parser_set_reader_error(
|
||||
parser,
|
||||
|
@ -280,7 +276,7 @@ pub unsafe fn yaml_parser_update_buffer(parser: *mut yaml_parser_t, length: size
|
|||
} else {
|
||||
0_i32
|
||||
};
|
||||
if raw_unread < 2_i32 as libc::c_ulong {
|
||||
if raw_unread < 2_u64 {
|
||||
if (*parser).eof != 0 {
|
||||
return yaml_parser_set_reader_error(
|
||||
parser,
|
||||
|
@ -307,8 +303,8 @@ pub unsafe fn yaml_parser_update_buffer(parser: *mut yaml_parser_t, length: size
|
|||
);
|
||||
}
|
||||
if value & 0xfc00_i32 as libc::c_uint == 0xd800_i32 as libc::c_uint {
|
||||
width = 4_i32 as libc::c_uint;
|
||||
if raw_unread < 4_i32 as libc::c_ulong {
|
||||
width = 4_u32;
|
||||
if raw_unread < 4_u64 {
|
||||
if (*parser).eof != 0 {
|
||||
return yaml_parser_set_reader_error(
|
||||
parser,
|
||||
|
@ -334,7 +330,7 @@ pub unsafe fn yaml_parser_update_buffer(parser: *mut yaml_parser_t, length: size
|
|||
parser,
|
||||
b"expected low surrogate area\0" as *const u8
|
||||
as *const libc::c_char,
|
||||
((*parser).offset).wrapping_add(2_i32 as libc::c_ulong),
|
||||
((*parser).offset).wrapping_add(2_u64),
|
||||
value2 as libc::c_int,
|
||||
);
|
||||
}
|
||||
|
@ -343,7 +339,7 @@ pub unsafe fn yaml_parser_update_buffer(parser: *mut yaml_parser_t, length: size
|
|||
.wrapping_add(value2 & 0x3ff_i32 as libc::c_uint);
|
||||
}
|
||||
} else {
|
||||
width = 2_i32 as libc::c_uint;
|
||||
width = 2_u32;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -440,7 +436,7 @@ pub unsafe fn yaml_parser_update_buffer(parser: *mut yaml_parser_t, length: size
|
|||
return 1_i32;
|
||||
}
|
||||
}
|
||||
if (*parser).offset >= (!(0_i32 as size_t)).wrapping_div(2_i32 as libc::c_ulong) {
|
||||
if (*parser).offset >= (!(0_u64)).wrapping_div(2_u64) {
|
||||
return yaml_parser_set_reader_error(
|
||||
parser,
|
||||
b"input is too long\0" as *const u8 as *const libc::c_char,
|
||||
|
|
2702
src/scanner.rs
2702
src/scanner.rs
File diff suppressed because it is too large
Load diff
|
@ -61,7 +61,7 @@ pub unsafe fn yaml_emitter_flush(emitter: *mut yaml_emitter_t) -> libc::c_int {
|
|||
let mut octet: libc::c_uchar;
|
||||
let mut value: libc::c_uint;
|
||||
let mut k: size_t;
|
||||
octet = *((*emitter).buffer.pointer).wrapping_offset(0_i32 as isize);
|
||||
octet = *((*emitter).buffer.pointer).wrapping_offset(0_isize);
|
||||
let width: libc::c_uint = (if octet as libc::c_int & 0x80_i32 == 0_i32 {
|
||||
1_i32
|
||||
} else if octet as libc::c_int & 0xe0_i32 == 0xc0_i32 {
|
||||
|
@ -84,7 +84,7 @@ pub unsafe fn yaml_emitter_flush(emitter: *mut yaml_emitter_t) -> libc::c_int {
|
|||
} else {
|
||||
0_i32
|
||||
}) as libc::c_uint;
|
||||
k = 1_i32 as size_t;
|
||||
k = 1_u64;
|
||||
while k < width as libc::c_ulong {
|
||||
octet = *((*emitter).buffer.pointer).wrapping_offset(k as isize);
|
||||
value =
|
||||
|
@ -99,7 +99,7 @@ pub unsafe fn yaml_emitter_flush(emitter: *mut yaml_emitter_t) -> libc::c_int {
|
|||
*((*emitter).raw_buffer.last).wrapping_offset(low as isize) =
|
||||
(value & 0xff_i32 as libc::c_uint) as libc::c_uchar;
|
||||
let fresh6 = addr_of_mut!((*emitter).raw_buffer.last);
|
||||
*fresh6 = (*fresh6).wrapping_offset(2_i32 as isize);
|
||||
*fresh6 = (*fresh6).wrapping_offset(2_isize);
|
||||
} else {
|
||||
value = value.wrapping_sub(0x10000_i32 as libc::c_uint);
|
||||
*((*emitter).raw_buffer.last).wrapping_offset(high as isize) =
|
||||
|
@ -112,7 +112,7 @@ pub unsafe fn yaml_emitter_flush(emitter: *mut yaml_emitter_t) -> libc::c_int {
|
|||
*((*emitter).raw_buffer.last).wrapping_offset((low + 2_i32) as isize) =
|
||||
(value & 0xff_i32 as libc::c_uint) as libc::c_uchar;
|
||||
let fresh7 = addr_of_mut!((*emitter).raw_buffer.last);
|
||||
*fresh7 = (*fresh7).wrapping_offset(4_i32 as isize);
|
||||
*fresh7 = (*fresh7).wrapping_offset(4_isize);
|
||||
}
|
||||
}
|
||||
if ((*emitter).write_handler).expect("non-null function pointer")(
|
||||
|
|
Loading…
Reference in a new issue