Factor out IS_SPACE macro

This commit is contained in:
David Tolnay 2022-07-22 18:27:25 -07:00
parent 7415f3bfdf
commit fe99a3a5e1
No known key found for this signature in database
GPG key ID: F9BA143B95FF6D82
3 changed files with 10 additions and 11 deletions

View file

@ -1605,7 +1605,7 @@ unsafe fn yaml_emitter_analyze_scalar(
if IS_BREAK!(string) {
line_breaks = 1_i32;
}
if *string.pointer as libc::c_int == ' ' as i32 as yaml_char_t as libc::c_int {
if IS_SPACE!(string) {
if string.start == string.pointer {
leading_space = 1_i32;
}
@ -2013,7 +2013,7 @@ unsafe fn yaml_emitter_write_plain_scalar(
}
}
while string.pointer != string.end {
if *string.pointer as libc::c_int == ' ' as i32 as yaml_char_t as libc::c_int {
if IS_SPACE!(string) {
if allow_breaks != 0
&& spaces == 0
&& (*emitter).column > (*emitter).best_width
@ -2080,7 +2080,7 @@ unsafe fn yaml_emitter_write_single_quoted_scalar(
return 0_i32;
}
while string.pointer != string.end {
if *string.pointer as libc::c_int == ' ' as i32 as yaml_char_t as libc::c_int {
if IS_SPACE!(string) {
if allow_breaks != 0
&& spaces == 0
&& (*emitter).column > (*emitter).best_width
@ -2326,7 +2326,7 @@ unsafe fn yaml_emitter_write_double_quoted_scalar(
}
}
spaces = 0_i32;
} else if *string.pointer as libc::c_int == ' ' as i32 as yaml_char_t as libc::c_int {
} else if IS_SPACE!(string) {
if allow_breaks != 0
&& spaces == 0
&& (*emitter).column > (*emitter).best_width
@ -2376,9 +2376,7 @@ unsafe fn yaml_emitter_write_block_scalar_hints(
) -> libc::c_int {
let mut indent_hint: [libc::c_char; 2] = [0; 2];
let mut chomp_hint: *const libc::c_char = ptr::null::<libc::c_char>();
if *string.pointer as libc::c_int == ' ' as i32 as yaml_char_t as libc::c_int
|| IS_BREAK!(string)
{
if IS_SPACE!(string) || IS_BREAK!(string) {
indent_hint[0_usize] =
('0' as i32 + (*emitter).best_indent as libc::c_char as libc::c_int) as libc::c_char;
indent_hint[1_usize] = '\0' as libc::c_char;
@ -2545,7 +2543,7 @@ unsafe fn yaml_emitter_write_folded_scalar(
leading_spaces = IS_BLANK!(string) as libc::c_int;
}
if breaks == 0
&& *string.pointer as libc::c_int == ' ' as i32 as yaml_char_t as libc::c_int
&& IS_SPACE!(string)
&& !(*string.pointer.wrapping_offset(1_isize) as libc::c_int
== ' ' as i32 as yaml_char_t as libc::c_int)
&& (*emitter).column > (*emitter).best_width

View file

@ -254,7 +254,9 @@ macro_rules! IS_SPACE_AT {
}
macro_rules! IS_SPACE {
() => {}; // TODO
($string:expr) => {
*$string.pointer as libc::c_int == ' ' as i32 as yaml_char_t as libc::c_int
};
}
macro_rules! IS_TAB_AT {

View file

@ -2396,8 +2396,7 @@ unsafe fn yaml_parser_scan_block_scalar_breaks(
return 0_i32;
}
while (*indent == 0 || ((*parser).mark.column as libc::c_int) < *indent)
&& *((*parser).buffer.pointer) as libc::c_int
== ' ' as i32 as yaml_char_t as libc::c_int
&& IS_SPACE!((*parser).buffer)
{
SKIP!(parser);
if CACHE!(parser, 1_u64) == 0 {