Skip to content

Upgrade to latest Rust. #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 27, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ RUST_SRC=$(shell find $(VPATH)/. -type f -name '*.rs') $(COLOR_DATA_RS)
.PHONY: all
all: libcssparser.dummy

libcssparser.dummy: cssparser.rc $(RUST_SRC)
$(RUSTC) $(RUSTFLAGS) $< --out-dir .
libcssparser.dummy: lib.rs $(RUST_SRC)
$(RUSTC) $(RUSTFLAGS) $< --lib --out-dir .
touch $@

cssparser-test: cssparser.rc $(RUST_SRC)
cssparser-test: lib.rs $(RUST_SRC)
$(RUSTC) $(RUSTFLAGS) $< -o $@ --test

.PHONY: check
Expand Down
1 change: 0 additions & 1 deletion cssparser.rc → lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#[link(name = "cssparser", vers = "0.1")];
#[crate_type = "lib"];

extern mod extra;

Expand Down
3 changes: 1 addition & 2 deletions nth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

use std::i32;
use std::ascii::StrAsciiExt;

use ast::*;
Expand Down Expand Up @@ -108,7 +107,7 @@ fn parse_n_dash_digits(string: &str) -> Option<i32> {
&& string.starts_with("n-")
&& string.slice_from(2).iter().all(|c| match c { '0'..'9' => true, _ => false })
{
let result = i32::from_str(string.slice_from(1)); // Include the minus sign
let result = from_str(string.slice_from(1)); // Include the minus sign
assert!(result.is_some());
result
}
Expand Down
20 changes: 10 additions & 10 deletions tokenizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

// http://dev.w3.org/csswg/css3-syntax/#tokenization

use std::{char, str, u32, i64, f64};
use std::{char, str, num};
use std::ascii::StrAsciiExt;

use ast::*;
Expand Down Expand Up @@ -440,12 +440,12 @@ fn consume_numeric(tokenizer: &mut Tokenizer) -> ComponentValue {
int_value: if is_integer { Some(
// Remove any + sign as int::from_str() does not parse them.
if representation[0] != '+' as u8 {
i64::from_str(representation)
from_str(representation)
} else {
i64::from_str(representation.slice_from(1))
from_str(representation.slice_from(1))
}.unwrap()
)} else { None },
value: f64::from_str(representation).unwrap(),
value: from_str(representation).unwrap(),
representation: representation,
};
if !tokenizer.is_eof() && tokenizer.current_char() == '%' {
Expand Down Expand Up @@ -547,10 +547,10 @@ fn consume_unicode_range(tokenizer: &mut Tokenizer) -> ComponentValue {
let start;
let end;
if question_marks > 0 {
start = u32::from_str_radix(hex + "0".repeat(question_marks), 16).unwrap();
end = u32::from_str_radix(hex + "F".repeat(question_marks), 16).unwrap();
start = num::from_str_radix(hex + "0".repeat(question_marks), 16).unwrap();
end = num::from_str_radix(hex + "F".repeat(question_marks), 16).unwrap();
} else {
start = u32::from_str_radix(hex, 16).unwrap();
start = num::from_str_radix(hex, 16).unwrap();
hex = ~"";
if !tokenizer.is_eof() && tokenizer.current_char() == '-' {
tokenizer.position += 1;
Expand All @@ -563,7 +563,7 @@ fn consume_unicode_range(tokenizer: &mut Tokenizer) -> ComponentValue {
}
}
}
end = if hex.len() > 0 { u32::from_str_radix(hex, 16).unwrap() } else { start }
end = if hex.len() > 0 { num::from_str_radix(hex, 16).unwrap() } else { start }
}
UnicodeRange {start: start, end: end}
}
Expand Down Expand Up @@ -594,10 +594,10 @@ fn consume_escape(tokenizer: &mut Tokenizer) -> char {
}
}
static REPLACEMENT_CHAR: char = '\uFFFD';
let c = u32::from_str_radix(hex, 16).unwrap();
let c: u32 = num::from_str_radix(hex, 16).unwrap();
if c != 0 {
let c = char::from_u32(c);
c.unwrap_or_default(REPLACEMENT_CHAR)
c.unwrap_or(REPLACEMENT_CHAR)
} else {
REPLACEMENT_CHAR
}
Expand Down