Factor out AS_DIGIT macro

This commit is contained in:
David Tolnay 2022-07-22 17:26:29 -07:00
parent ff255cac45
commit e776070311
No known key found for this signature in database
GPG key ID: F9BA143B95FF6D82
2 changed files with 6 additions and 12 deletions

View file

@ -149,12 +149,10 @@ macro_rules! IS_DIGIT {
}; };
} }
macro_rules! AS_DIGIT_AT {
() => {}; // TODO
}
macro_rules! AS_DIGIT { macro_rules! AS_DIGIT {
() => {}; // TODO ($string:expr) => {
*$string.pointer as libc::c_int - '0' as i32 as yaml_char_t as libc::c_int
};
} }
macro_rules! IS_HEX_AT { macro_rules! IS_HEX_AT {

View file

@ -1532,9 +1532,7 @@ unsafe fn yaml_parser_scan_version_directive_number(
b"found extremely long version number\0" as *const u8 as *const libc::c_char, b"found extremely long version number\0" as *const u8 as *const libc::c_char,
); );
} }
value = value * 10_i32 value = value * 10_i32 + AS_DIGIT!((*parser).buffer);
+ (*((*parser).buffer.pointer) as libc::c_int
- '0' as i32 as yaml_char_t as libc::c_int);
SKIP!(parser); SKIP!(parser);
if CACHE!(parser, 1_u64) == 0 { if CACHE!(parser, 1_u64) == 0 {
return 0_i32; return 0_i32;
@ -2323,8 +2321,7 @@ unsafe fn yaml_parser_scan_block_scalar(
); );
current_block = 14984465786483313892; current_block = 14984465786483313892;
} else { } else {
increment = *((*parser).buffer.pointer) as libc::c_int increment = AS_DIGIT!((*parser).buffer);
- '0' as i32 as yaml_char_t as libc::c_int;
SKIP!(parser); SKIP!(parser);
current_block = 11913429853522160501; current_block = 11913429853522160501;
} }
@ -2345,8 +2342,7 @@ unsafe fn yaml_parser_scan_block_scalar(
); );
current_block = 14984465786483313892; current_block = 14984465786483313892;
} else { } else {
increment = *((*parser).buffer.pointer) as libc::c_int increment = AS_DIGIT!((*parser).buffer);
- '0' as i32 as yaml_char_t as libc::c_int;
SKIP!(parser); SKIP!(parser);
if CACHE!(parser, 1_u64) == 0 { if CACHE!(parser, 1_u64) == 0 {
current_block = 14984465786483313892; current_block = 14984465786483313892;