mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
Merge pull request #3227 from Ms2ger/3208-parse-integer
Correct the iterator adaptors used in parsing integers (fixes #3208); r=jdm+Manishearth
This commit is contained in:
commit
383c754b60
4 changed files with 14 additions and 14 deletions
|
@ -51,10 +51,10 @@ pub fn split_html_space_chars<'a>(s: &'a str) -> Filter<'a, &'a str, CharSplits<
|
||||||
/// <http://www.whatwg.org/html/#rules-for-parsing-integers> or
|
/// <http://www.whatwg.org/html/#rules-for-parsing-integers> or
|
||||||
/// <http://www.whatwg.org/html/#rules-for-parsing-non-negative-integers>.
|
/// <http://www.whatwg.org/html/#rules-for-parsing-non-negative-integers>.
|
||||||
fn do_parse_integer<T: Iterator<char>>(input: T) -> Option<i64> {
|
fn do_parse_integer<T: Iterator<char>>(input: T) -> Option<i64> {
|
||||||
fn as_ascii_digit(c: char) -> Option<i64> {
|
fn is_ascii_digit(c: &char) -> bool {
|
||||||
match c {
|
match *c {
|
||||||
'0'..'9' => Some(c as i64 - '0' as i64),
|
'0'..'9' => true,
|
||||||
_ => None,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,11 +77,13 @@ fn do_parse_integer<T: Iterator<char>>(input: T) -> Option<i64> {
|
||||||
};
|
};
|
||||||
|
|
||||||
match input.peek() {
|
match input.peek() {
|
||||||
Some(&c) if as_ascii_digit(c).is_some() => (),
|
Some(c) if is_ascii_digit(c) => (),
|
||||||
_ => return None,
|
_ => return None,
|
||||||
}
|
}
|
||||||
|
|
||||||
let value = input.filter_map(as_ascii_digit).fuse().fold(Some(0i64), |accumulator, d| {
|
let value = input.take_while(is_ascii_digit).map(|d| {
|
||||||
|
d as i64 - '0' as i64
|
||||||
|
}).fold(Some(0i64), |accumulator, d| {
|
||||||
accumulator.and_then(|accumulator| {
|
accumulator.and_then(|accumulator| {
|
||||||
accumulator.checked_mul(&10)
|
accumulator.checked_mul(&10)
|
||||||
}).and_then(|accumulator| {
|
}).and_then(|accumulator| {
|
||||||
|
|
|
@ -20376,9 +20376,6 @@
|
||||||
[canvas.width: setAttribute() to 4294967295 followed by IDL get]
|
[canvas.width: setAttribute() to 4294967295 followed by IDL get]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[canvas.width: setAttribute() to 1.5 followed by IDL get]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[canvas.width: setAttribute() to object "3" followed by getAttribute()]
|
[canvas.width: setAttribute() to object "3" followed by getAttribute()]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
@ -20391,9 +20388,6 @@
|
||||||
[canvas.height: setAttribute() to 4294967295 followed by IDL get]
|
[canvas.height: setAttribute() to 4294967295 followed by IDL get]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[canvas.height: setAttribute() to 1.5 followed by IDL get]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[canvas.height: setAttribute() to object "3" followed by getAttribute()]
|
[canvas.height: setAttribute() to object "3" followed by getAttribute()]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
[size.attributes.parse.decimal.html]
|
[size.attributes.parse.decimal.html]
|
||||||
type: testharness
|
type: testharness
|
||||||
expected: TIMEOUT
|
[Parsing of non-negative integers]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
[size.attributes.setAttribute.decimal.html]
|
[size.attributes.setAttribute.decimal.html]
|
||||||
type: testharness
|
type: testharness
|
||||||
expected: TIMEOUT
|
[Parsing of non-negative integers in setAttribute]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue