mirror of
https://github.com/simonask/libyaml-safer
synced 2024-11-23 03:43:03 +00:00
Factor out IS_SPACE_AT macro
This commit is contained in:
parent
fe99a3a5e1
commit
5305f1811a
2 changed files with 10 additions and 14 deletions
|
@ -2017,8 +2017,7 @@ unsafe fn yaml_emitter_write_plain_scalar(
|
|||
if allow_breaks != 0
|
||||
&& spaces == 0
|
||||
&& (*emitter).column > (*emitter).best_width
|
||||
&& !(*string.pointer.wrapping_offset(1_isize) as libc::c_int
|
||||
== ' ' as i32 as yaml_char_t as libc::c_int)
|
||||
&& !IS_SPACE_AT!(string, 1)
|
||||
{
|
||||
if yaml_emitter_write_indent(emitter) == 0 {
|
||||
return 0_i32;
|
||||
|
@ -2086,8 +2085,7 @@ unsafe fn yaml_emitter_write_single_quoted_scalar(
|
|||
&& (*emitter).column > (*emitter).best_width
|
||||
&& string.pointer != string.start
|
||||
&& string.pointer != string.end.wrapping_offset(-(1_isize))
|
||||
&& !(*string.pointer.wrapping_offset(1_isize) as libc::c_int
|
||||
== ' ' as i32 as yaml_char_t as libc::c_int)
|
||||
&& !IS_SPACE_AT!(string, 1)
|
||||
{
|
||||
if yaml_emitter_write_indent(emitter) == 0 {
|
||||
return 0_i32;
|
||||
|
@ -2336,9 +2334,7 @@ unsafe fn yaml_emitter_write_double_quoted_scalar(
|
|||
if yaml_emitter_write_indent(emitter) == 0 {
|
||||
return 0_i32;
|
||||
}
|
||||
if *string.pointer.wrapping_offset(1_isize) as libc::c_int
|
||||
== ' ' as i32 as yaml_char_t as libc::c_int
|
||||
{
|
||||
if IS_SPACE_AT!(string, 1) {
|
||||
if !(PUT!(emitter, '\\')) {
|
||||
return 0_i32;
|
||||
}
|
||||
|
@ -2544,8 +2540,7 @@ unsafe fn yaml_emitter_write_folded_scalar(
|
|||
}
|
||||
if breaks == 0
|
||||
&& IS_SPACE!(string)
|
||||
&& !(*string.pointer.wrapping_offset(1_isize) as libc::c_int
|
||||
== ' ' as i32 as yaml_char_t as libc::c_int)
|
||||
&& !IS_SPACE_AT!(string, 1)
|
||||
&& (*emitter).column > (*emitter).best_width
|
||||
{
|
||||
if yaml_emitter_write_indent(emitter) == 0 {
|
||||
|
|
|
@ -250,12 +250,15 @@ macro_rules! IS_BOM {
|
|||
}
|
||||
|
||||
macro_rules! IS_SPACE_AT {
|
||||
() => {}; // TODO
|
||||
($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
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! IS_SPACE {
|
||||
($string:expr) => {
|
||||
*$string.pointer as libc::c_int == ' ' as i32 as yaml_char_t as libc::c_int
|
||||
IS_SPACE_AT!($string, 0)
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -274,9 +277,7 @@ macro_rules! IS_TAB {
|
|||
|
||||
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
|
||||
|| IS_TAB_AT!($string, $offset)
|
||||
IS_SPACE_AT!($string, $offset) || IS_TAB_AT!($string, $offset)
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue