Eliminate return value of string init

This commit is contained in:
David Tolnay 2022-07-30 01:18:40 -07:00
parent e0a86e6089
commit 5c028a3ded
No known key found for this signature in database
GPG key ID: F9BA143B95FF6D82
2 changed files with 1001 additions and 1058 deletions

View file

@ -39,7 +39,6 @@ macro_rules! STRING_INIT {
$string.pointer = $string.start;
$string.end = $string.start.wrapping_add(16);
memset($string.start as *mut libc::c_void, 0, 16);
OK
}};
}

View file

@ -1179,7 +1179,7 @@ unsafe fn yaml_parser_scan_directive_name(
) -> Success {
let current_block: u64;
let mut string = NULL_STRING;
if STRING_INIT!(parser, string).ok {
STRING_INIT!(parser, string);
if CACHE(parser, 1_u64).ok {
loop {
if !IS_ALPHA!((*parser).buffer) {
@ -1221,7 +1221,6 @@ unsafe fn yaml_parser_scan_directive_name(
}
}
}
}
STRING_DEL!(string);
FAIL
}
@ -1414,7 +1413,7 @@ unsafe fn yaml_parser_scan_anchor(
let start_mark: yaml_mark_t;
let end_mark: yaml_mark_t;
let mut string = NULL_STRING;
if STRING_INIT!(parser, string).ok {
STRING_INIT!(parser, string);
start_mark = (*parser).mark;
SKIP(parser);
if CACHE(parser, 1_u64).ok {
@ -1488,7 +1487,6 @@ unsafe fn yaml_parser_scan_anchor(
}
}
}
}
STRING_DEL!(string);
FAIL
}
@ -1633,7 +1631,7 @@ unsafe fn yaml_parser_scan_tag_handle(
) -> Success {
let mut current_block: u64;
let mut string = NULL_STRING;
if STRING_INIT!(parser, string).ok {
STRING_INIT!(parser, string);
if CACHE(parser, 1_u64).ok {
if !CHECK!((*parser).buffer, b'!') {
yaml_parser_set_scanner_error(
@ -1680,8 +1678,7 @@ unsafe fn yaml_parser_scan_tag_handle(
b"while parsing a tag directive\0" as *const u8
as *const libc::c_char,
start_mark,
b"did not find expected '!'\0" as *const u8
as *const libc::c_char,
b"did not find expected '!'\0" as *const u8 as *const libc::c_char,
);
current_block = 1771849829115608806;
} else {
@ -1699,7 +1696,6 @@ unsafe fn yaml_parser_scan_tag_handle(
}
}
}
}
STRING_DEL!(string);
FAIL
}
@ -1719,11 +1715,8 @@ unsafe fn yaml_parser_scan_tag_uri(
0_u64
};
let mut string = NULL_STRING;
if STRING_INIT!(parser, string).fail {
current_block = 15265153392498847348;
} else {
STRING_INIT!(parser, string);
current_block = 14916268686031723178;
}
'c_21953: loop {
match current_block {
15265153392498847348 => {
@ -1933,9 +1926,9 @@ unsafe fn yaml_parser_scan_block_scalar(
let mut indent: libc::c_int = 0;
let mut leading_blank: libc::c_int = 0;
let mut trailing_blank: libc::c_int;
if STRING_INIT!(parser, string).ok {
if STRING_INIT!(parser, leading_break).ok {
if STRING_INIT!(parser, trailing_breaks).ok {
STRING_INIT!(parser, string);
STRING_INIT!(parser, leading_break);
STRING_INIT!(parser, trailing_breaks);
start_mark = (*parser).mark;
SKIP(parser);
if CACHE(parser, 1_u64).ok {
@ -1952,8 +1945,7 @@ unsafe fn yaml_parser_scan_block_scalar(
if CHECK!((*parser).buffer, b'0') {
yaml_parser_set_scanner_error(
parser,
b"while scanning a block scalar\0" as *const u8
as *const libc::c_char,
b"while scanning a block scalar\0" as *const u8 as *const libc::c_char,
start_mark,
b"found an indentation indicator equal to 0\0" as *const u8
as *const libc::c_char,
@ -1971,8 +1963,7 @@ unsafe fn yaml_parser_scan_block_scalar(
if CHECK!((*parser).buffer, b'0') {
yaml_parser_set_scanner_error(
parser,
b"while scanning a block scalar\0" as *const u8
as *const libc::c_char,
b"while scanning a block scalar\0" as *const u8 as *const libc::c_char,
start_mark,
b"found an indentation indicator equal to 0\0" as *const u8
as *const libc::c_char,
@ -1984,8 +1975,7 @@ unsafe fn yaml_parser_scan_block_scalar(
if CACHE(parser, 1_u64).fail {
current_block = 14984465786483313892;
} else {
if CHECK!((*parser).buffer, b'+') || CHECK!((*parser).buffer, b'-')
{
if CHECK!((*parser).buffer, b'+') || CHECK!((*parser).buffer, b'-') {
chomping = if CHECK!((*parser).buffer, b'+') {
1
} else {
@ -2042,7 +2032,8 @@ unsafe fn yaml_parser_scan_block_scalar(
as *const libc::c_char,
start_mark,
b"did not find expected comment or line break\0"
as *const u8 as *const libc::c_char,
as *const u8
as *const libc::c_char,
);
} else {
if IS_BREAK!((*parser).buffer) {
@ -2080,39 +2071,33 @@ unsafe fn yaml_parser_scan_block_scalar(
if !((*parser).mark.column
as libc::c_int
== indent
&& !IS_Z!(
(*parser).buffer
))
&& !IS_Z!((*parser).buffer))
{
current_block =
5793491756164225964;
current_block = 5793491756164225964;
break;
}
trailing_blank = IS_BLANK!(
(*parser).buffer
)
trailing_blank =
IS_BLANK!((*parser).buffer)
as libc::c_int;
if !literal
&& *leading_break.start
== b'\n'
&& *leading_break.start == b'\n'
&& leading_blank == 0
&& trailing_blank == 0
{
if *trailing_breaks
.start
== b'\0'
{
if *trailing_breaks.start == b'\0' {
if STRING_EXTEND!(
parser, string
)
.fail
{
current_block = 14984465786483313892;
current_block =
14984465786483313892;
break;
}
let fresh418 =
string.pointer;
string.pointer = string.pointer.wrapping_offset(1);
let fresh418 = string.pointer;
string.pointer = string
.pointer
.wrapping_offset(1);
*fresh418 = b' ';
}
CLEAR!(leading_break);
@ -2124,7 +2109,8 @@ unsafe fn yaml_parser_scan_block_scalar(
)
.fail
{
current_block = 14984465786483313892;
current_block =
14984465786483313892;
break;
}
CLEAR!(leading_break);
@ -2136,42 +2122,36 @@ unsafe fn yaml_parser_scan_block_scalar(
)
.fail
{
current_block = 14984465786483313892;
current_block =
14984465786483313892;
break;
}
CLEAR!(trailing_breaks);
leading_blank = IS_BLANK!(
(*parser).buffer
)
leading_blank =
IS_BLANK!((*parser).buffer)
as libc::c_int;
while !IS_BREAKZ!(
(*parser).buffer
) {
if READ!(parser, string)
.fail
{
current_block = 14984465786483313892;
while !IS_BREAKZ!((*parser).buffer) {
if READ!(parser, string).fail {
current_block =
14984465786483313892;
break 's_281;
}
if CACHE(parser, 1_u64)
.fail
{
current_block = 14984465786483313892;
if CACHE(parser, 1_u64).fail {
current_block =
14984465786483313892;
break 's_281;
}
}
if CACHE(parser, 2_u64).fail
{
current_block = 14984465786483313892;
if CACHE(parser, 2_u64).fail {
current_block =
14984465786483313892;
break;
}
if READ_LINE!(
parser,
leading_break
)
if READ_LINE!(parser, leading_break)
.fail
{
current_block = 14984465786483313892;
current_block =
14984465786483313892;
break;
}
if yaml_parser_scan_block_scalar_breaks(
@ -2180,9 +2160,11 @@ unsafe fn yaml_parser_scan_block_scalar(
addr_of_mut!(trailing_breaks),
start_mark,
addr_of_mut!(end_mark),
).fail
)
.fail
{
current_block = 14984465786483313892;
current_block =
14984465786483313892;
break;
}
}
@ -2197,18 +2179,27 @@ unsafe fn yaml_parser_scan_block_scalar(
)
.fail
{
current_block = 14984465786483313892;
current_block =
14984465786483313892;
} else {
current_block = 17787701279558130514;
current_block =
17787701279558130514;
}
} else {
current_block = 17787701279558130514;
current_block =
17787701279558130514;
}
match current_block {
14984465786483313892 => {}
_ => {
if chomping == 1 {
if JOIN!(parser, string, trailing_breaks).fail {
if JOIN!(
parser,
string,
trailing_breaks
)
.fail
{
current_block = 14984465786483313892;
} else {
current_block = 14648606000749551097;
@ -2264,9 +2255,6 @@ unsafe fn yaml_parser_scan_block_scalar(
}
}
}
}
}
}
STRING_DEL!(string);
STRING_DEL!(leading_break);
STRING_DEL!(trailing_breaks);
@ -2345,10 +2333,10 @@ unsafe fn yaml_parser_scan_flow_scalar(
let mut trailing_breaks = NULL_STRING;
let mut whitespaces = NULL_STRING;
let mut leading_blanks: libc::c_int;
if STRING_INIT!(parser, string).ok {
if STRING_INIT!(parser, leading_break).ok {
if STRING_INIT!(parser, trailing_breaks).ok {
if STRING_INIT!(parser, whitespaces).ok {
STRING_INIT!(parser, string);
STRING_INIT!(parser, leading_break);
STRING_INIT!(parser, trailing_breaks);
STRING_INIT!(parser, whitespaces);
start_mark = (*parser).mark;
SKIP(parser);
's_58: loop {
@ -2367,22 +2355,18 @@ unsafe fn yaml_parser_scan_flow_scalar(
{
yaml_parser_set_scanner_error(
parser,
b"while scanning a quoted scalar\0" as *const u8
as *const libc::c_char,
b"while scanning a quoted scalar\0" as *const u8 as *const libc::c_char,
start_mark,
b"found unexpected document indicator\0" as *const u8
as *const libc::c_char,
b"found unexpected document indicator\0" as *const u8 as *const libc::c_char,
);
current_block = 8114179180390253173;
break;
} else if IS_Z!((*parser).buffer) {
yaml_parser_set_scanner_error(
parser,
b"while scanning a quoted scalar\0" as *const u8
as *const libc::c_char,
b"while scanning a quoted scalar\0" as *const u8 as *const libc::c_char,
start_mark,
b"found unexpected end of stream\0" as *const u8
as *const libc::c_char,
b"found unexpected end of stream\0" as *const u8 as *const libc::c_char,
);
current_block = 8114179180390253173;
break;
@ -2568,12 +2552,10 @@ unsafe fn yaml_parser_scan_flow_scalar(
if !IS_HEX_AT!((*parser).buffer, k as isize) {
yaml_parser_set_scanner_error(
parser,
b"while parsing a quoted scalar\0"
as *const u8
b"while parsing a quoted scalar\0" as *const u8
as *const libc::c_char,
start_mark,
b"did not find expected hexdecimal number\0"
as *const u8
b"did not find expected hexdecimal number\0" as *const u8
as *const libc::c_char,
);
current_block = 8114179180390253173;
@ -2587,16 +2569,13 @@ unsafe fn yaml_parser_scan_flow_scalar(
k = k.wrapping_add(1);
}
}
if value >= 0xD800 && value <= 0xDFFF
|| value > 0x10FFFF
{
if value >= 0xD800 && value <= 0xDFFF || value > 0x10FFFF {
yaml_parser_set_scanner_error(
parser,
b"while parsing a quoted scalar\0" as *const u8
as *const libc::c_char,
start_mark,
b"found invalid Unicode character escape code\0"
as *const u8
b"found invalid Unicode character escape code\0" as *const u8
as *const libc::c_char,
);
current_block = 8114179180390253173;
@ -2604,60 +2583,41 @@ unsafe fn yaml_parser_scan_flow_scalar(
} else {
if value <= 0x7F {
let fresh573 = string.pointer;
string.pointer =
string.pointer.wrapping_offset(1);
string.pointer = string.pointer.wrapping_offset(1);
*fresh573 = value as yaml_char_t;
} else if value <= 0x7FF {
let fresh574 = string.pointer;
string.pointer =
string.pointer.wrapping_offset(1);
*fresh574 = 0xC0_u32.wrapping_add(value >> 6)
as yaml_char_t;
string.pointer = string.pointer.wrapping_offset(1);
*fresh574 = 0xC0_u32.wrapping_add(value >> 6) as yaml_char_t;
let fresh575 = string.pointer;
string.pointer =
string.pointer.wrapping_offset(1);
*fresh575 = 0x80_u32.wrapping_add(value & 0x3F)
as yaml_char_t;
string.pointer = string.pointer.wrapping_offset(1);
*fresh575 = 0x80_u32.wrapping_add(value & 0x3F) as yaml_char_t;
} else if value <= 0xFFFF {
let fresh576 = string.pointer;
string.pointer =
string.pointer.wrapping_offset(1);
*fresh576 = 0xE0_u32.wrapping_add(value >> 12)
as yaml_char_t;
string.pointer = string.pointer.wrapping_offset(1);
*fresh576 = 0xE0_u32.wrapping_add(value >> 12) as yaml_char_t;
let fresh577 = string.pointer;
string.pointer =
string.pointer.wrapping_offset(1);
*fresh577 = 0x80_u32
.wrapping_add(value >> 6 & 0x3F)
as yaml_char_t;
string.pointer = string.pointer.wrapping_offset(1);
*fresh577 =
0x80_u32.wrapping_add(value >> 6 & 0x3F) as yaml_char_t;
let fresh578 = string.pointer;
string.pointer =
string.pointer.wrapping_offset(1);
*fresh578 = 0x80_u32.wrapping_add(value & 0x3F)
as yaml_char_t;
string.pointer = string.pointer.wrapping_offset(1);
*fresh578 = 0x80_u32.wrapping_add(value & 0x3F) as yaml_char_t;
} else {
let fresh579 = string.pointer;
string.pointer =
string.pointer.wrapping_offset(1);
*fresh579 = 0xF0_u32.wrapping_add(value >> 18)
as yaml_char_t;
string.pointer = string.pointer.wrapping_offset(1);
*fresh579 = 0xF0_u32.wrapping_add(value >> 18) as yaml_char_t;
let fresh580 = string.pointer;
string.pointer =
string.pointer.wrapping_offset(1);
*fresh580 = 0x80_u32
.wrapping_add(value >> 12 & 0x3F)
as yaml_char_t;
string.pointer = string.pointer.wrapping_offset(1);
*fresh580 =
0x80_u32.wrapping_add(value >> 12 & 0x3F) as yaml_char_t;
let fresh581 = string.pointer;
string.pointer =
string.pointer.wrapping_offset(1);
*fresh581 = 0x80_u32
.wrapping_add(value >> 6 & 0x3F)
as yaml_char_t;
string.pointer = string.pointer.wrapping_offset(1);
*fresh581 =
0x80_u32.wrapping_add(value >> 6 & 0x3F) as yaml_char_t;
let fresh582 = string.pointer;
string.pointer =
string.pointer.wrapping_offset(1);
*fresh582 = 0x80_u32.wrapping_add(value & 0x3F)
as yaml_char_t;
string.pointer = string.pointer.wrapping_offset(1);
*fresh582 = 0x80_u32.wrapping_add(value & 0x3F) as yaml_char_t;
}
k = 0_u64;
while k < code_length {
@ -2774,9 +2734,8 @@ unsafe fn yaml_parser_scan_flow_scalar(
(*token).end_mark = end_mark;
let fresh716 = addr_of_mut!((*token).data.scalar.value);
*fresh716 = string.start;
(*token).data.scalar.length = string.pointer.c_offset_from(string.start)
as libc::c_long
as size_t;
(*token).data.scalar.length =
string.pointer.c_offset_from(string.start) as libc::c_long as size_t;
(*token).data.scalar.style = if single {
YAML_SINGLE_QUOTED_SCALAR_STYLE
} else {
@ -2788,10 +2747,6 @@ unsafe fn yaml_parser_scan_flow_scalar(
return OK;
}
}
}
}
}
}
STRING_DEL!(string);
STRING_DEL!(leading_break);
STRING_DEL!(trailing_breaks);
@ -2812,10 +2767,10 @@ unsafe fn yaml_parser_scan_plain_scalar(
let mut whitespaces = NULL_STRING;
let mut leading_blanks: libc::c_int = 0;
let indent: libc::c_int = (*parser).indent + 1;
if STRING_INIT!(parser, string).ok {
if STRING_INIT!(parser, leading_break).ok {
if STRING_INIT!(parser, trailing_breaks).ok {
if STRING_INIT!(parser, whitespaces).ok {
STRING_INIT!(parser, string);
STRING_INIT!(parser, leading_break);
STRING_INIT!(parser, trailing_breaks);
STRING_INIT!(parser, whitespaces);
end_mark = (*parser).mark;
start_mark = end_mark;
's_57: loop {
@ -2851,16 +2806,14 @@ unsafe fn yaml_parser_scan_plain_scalar(
{
yaml_parser_set_scanner_error(
parser,
b"while scanning a plain scalar\0" as *const u8
as *const libc::c_char,
b"while scanning a plain scalar\0" as *const u8 as *const libc::c_char,
start_mark,
b"found unexpected ':'\0" as *const u8 as *const libc::c_char,
);
current_block = 16642808987012640029;
break 's_57;
} else {
if CHECK!((*parser).buffer, b':')
&& IS_BLANKZ_AT!((*parser).buffer, 1)
if CHECK!((*parser).buffer, b':') && IS_BLANKZ_AT!((*parser).buffer, 1)
|| (*parser).flow_level != 0
&& (CHECK!((*parser).buffer, b',')
|| CHECK!((*parser).buffer, b'[')
@ -2937,11 +2890,9 @@ unsafe fn yaml_parser_scan_plain_scalar(
{
yaml_parser_set_scanner_error(
parser,
b"while scanning a plain scalar\0" as *const u8
as *const libc::c_char,
b"while scanning a plain scalar\0" as *const u8 as *const libc::c_char,
start_mark,
b"found a tab character that violates indentation\0"
as *const u8
b"found a tab character that violates indentation\0" as *const u8
as *const libc::c_char,
);
current_block = 16642808987012640029;
@ -2976,9 +2927,7 @@ unsafe fn yaml_parser_scan_plain_scalar(
break 's_57;
}
}
if (*parser).flow_level == 0
&& ((*parser).mark.column as libc::c_int) < indent
{
if (*parser).flow_level == 0 && ((*parser).mark.column as libc::c_int) < indent {
current_block = 6281126495347172768;
break;
}
@ -2996,9 +2945,8 @@ unsafe fn yaml_parser_scan_plain_scalar(
(*token).end_mark = end_mark;
let fresh842 = addr_of_mut!((*token).data.scalar.value);
*fresh842 = string.start;
(*token).data.scalar.length = string.pointer.c_offset_from(string.start)
as libc::c_long
as size_t;
(*token).data.scalar.length =
string.pointer.c_offset_from(string.start) as libc::c_long as size_t;
(*token).data.scalar.style = YAML_PLAIN_SCALAR_STYLE;
if leading_blanks != 0 {
(*parser).simple_key_allowed = true;
@ -3009,10 +2957,6 @@ unsafe fn yaml_parser_scan_plain_scalar(
return OK;
}
}
}
}
}
}
STRING_DEL!(string);
STRING_DEL!(leading_break);
STRING_DEL!(trailing_breaks);