Factor out IS_ASCII macro

This commit is contained in:
David Tolnay 2022-07-22 17:37:38 -07:00
parent c968eba61d
commit 7b299dfb83
No known key found for this signature in database
GPG key ID: F9BA143B95FF6D82
2 changed files with 5 additions and 10 deletions

View file

@ -1615,8 +1615,7 @@ unsafe fn yaml_emitter_analyze_scalar(
&& !(*string.pointer.wrapping_offset(1_isize) as libc::c_int == 0xbf_i32
&& (*string.pointer.wrapping_offset(2_isize) as libc::c_int == 0xbe_i32
|| *string.pointer.wrapping_offset(2_isize) as libc::c_int == 0xbf_i32)))
|| !(*string.pointer as libc::c_int <= '\u{7f}' as i32 as yaml_char_t as libc::c_int)
&& (*emitter).unicode == 0
|| !IS_ASCII!(string) && (*emitter).unicode == 0
{
special_characters = 1_i32;
}
@ -2262,9 +2261,7 @@ unsafe fn yaml_emitter_write_double_quoted_scalar(
&& !(*string.pointer.wrapping_offset(1_isize) as libc::c_int == 0xbf_i32
&& (*string.pointer.wrapping_offset(2_isize) as libc::c_int == 0xbe_i32
|| *string.pointer.wrapping_offset(2_isize) as libc::c_int == 0xbf_i32)))
|| (*emitter).unicode == 0
&& !(*string.pointer as libc::c_int
<= '\u{7f}' as i32 as yaml_char_t as libc::c_int)
|| (*emitter).unicode == 0 && !IS_ASCII!(string)
|| *string.pointer as libc::c_int == -17i32 as yaml_char_t as libc::c_int
&& *string.pointer.wrapping_offset(1_isize) as libc::c_int
== -69i32 as yaml_char_t as libc::c_int

View file

@ -197,12 +197,10 @@ macro_rules! AS_HEX_AT {
};
}
macro_rules! IS_ASCII_AT {
() => {}; // TODO
}
macro_rules! IS_ASCII {
() => {}; // TODO
($string:expr) => {
*$string.pointer as libc::c_int <= '\u{7f}' as i32 as yaml_char_t as libc::c_int
};
}
macro_rules! IS_PRINTABLE_AT {