Factor out IS_BLANK_AT macro

This commit is contained in:
David Tolnay 2022-07-21 00:49:07 -07:00
parent f3bd6b6376
commit ee0a40afc5
No known key found for this signature in database
GPG key ID: F9BA143B95FF6D82
2 changed files with 13 additions and 11 deletions

View file

@ -1,16 +1,21 @@
macro_rules! IS_BLANK_AT {
($string:expr, $offset:expr) => {
*$string.pointer.wrapping_offset($offset as isize) as libc::c_int
== ' ' as i32 as yaml_char_t as libc::c_int
|| *$string.pointer.wrapping_offset($offset as isize) as libc::c_int
== '\t' as i32 as yaml_char_t as libc::c_int
};
}
macro_rules! IS_BLANK {
($string:expr) => {
*$string.pointer as libc::c_int == ' ' as i32 as yaml_char_t as libc::c_int
|| *$string.pointer as libc::c_int == '\t' as i32 as yaml_char_t as libc::c_int
IS_BLANK_AT!($string, 0)
};
}
macro_rules! IS_BLANKZ_AT {
($string:expr, $offset:expr) => {
(*$string.pointer.wrapping_offset($offset as isize) as libc::c_int
== ' ' as i32 as yaml_char_t as libc::c_int
|| *$string.pointer.wrapping_offset($offset as isize) as libc::c_int
== '\t' as i32 as yaml_char_t as libc::c_int
IS_BLANK_AT!($string, $offset)
|| (*$string.pointer.wrapping_offset($offset as isize) as libc::c_int
== '\r' as i32 as yaml_char_t as libc::c_int
|| *$string.pointer.wrapping_offset($offset as isize) as libc::c_int
@ -32,7 +37,7 @@ macro_rules! IS_BLANKZ_AT {
&& *$string.pointer.wrapping_offset($offset as isize + 2) as libc::c_int
== -87i32 as yaml_char_t as libc::c_int
|| *$string.pointer.wrapping_offset($offset as isize) as libc::c_int
== '\0' as i32 as yaml_char_t as libc::c_int))
== '\0' as i32 as yaml_char_t as libc::c_int)
};
}

View file

@ -476,10 +476,7 @@ unsafe fn yaml_parser_fetch_next_token(parser: *mut yaml_parser_t) -> libc::c_in
|| *((*parser).buffer.pointer) as libc::c_int == '@' as i32 as yaml_char_t as libc::c_int
|| *((*parser).buffer.pointer) as libc::c_int == '`' as i32 as yaml_char_t as libc::c_int)
|| *((*parser).buffer.pointer) as libc::c_int == '-' as i32 as yaml_char_t as libc::c_int
&& !(*((*parser).buffer.pointer).wrapping_offset(1_isize) as libc::c_int
== ' ' as i32 as yaml_char_t as libc::c_int
|| *((*parser).buffer.pointer).wrapping_offset(1_isize) as libc::c_int
== '\t' as i32 as yaml_char_t as libc::c_int)
&& !IS_BLANK_AT!((*parser).buffer, 1)
|| (*parser).flow_level == 0
&& (*((*parser).buffer.pointer) as libc::c_int
== '?' as i32 as yaml_char_t as libc::c_int