Skip to content

Commit e5a7555

Browse files
committed
Merge pull request #18 from metajack/rustup2
Upgrade to latest Rust.
2 parents 6678671 + 49f71df commit e5a7555

File tree

4 files changed

+14
-16
lines changed

4 files changed

+14
-16
lines changed

Makefile.in

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ RUST_SRC=$(shell find $(VPATH)/. -type f -name '*.rs') $(COLOR_DATA_RS)
1313
.PHONY: all
1414
all: libcssparser.dummy
1515

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

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

2323
.PHONY: check

cssparser.rc renamed to lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44

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

87
extern mod extra;
98

nth.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
* License, v. 2.0. If a copy of the MPL was not distributed with this
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44

5-
use std::i32;
65
use std::ascii::StrAsciiExt;
76

87
use ast::*;
@@ -108,7 +107,7 @@ fn parse_n_dash_digits(string: &str) -> Option<i32> {
108107
&& string.starts_with("n-")
109108
&& string.slice_from(2).iter().all(|c| match c { '0'..'9' => true, _ => false })
110109
{
111-
let result = i32::from_str(string.slice_from(1)); // Include the minus sign
110+
let result = from_str(string.slice_from(1)); // Include the minus sign
112111
assert!(result.is_some());
113112
result
114113
}

tokenizer.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

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

7-
use std::{char, str, u32, i64, f64};
7+
use std::{char, str, num};
88
use std::ascii::StrAsciiExt;
99

1010
use ast::*;
@@ -440,12 +440,12 @@ fn consume_numeric(tokenizer: &mut Tokenizer) -> ComponentValue {
440440
int_value: if is_integer { Some(
441441
// Remove any + sign as int::from_str() does not parse them.
442442
if representation[0] != '+' as u8 {
443-
i64::from_str(representation)
443+
from_str(representation)
444444
} else {
445-
i64::from_str(representation.slice_from(1))
445+
from_str(representation.slice_from(1))
446446
}.unwrap()
447447
)} else { None },
448-
value: f64::from_str(representation).unwrap(),
448+
value: from_str(representation).unwrap(),
449449
representation: representation,
450450
};
451451
if !tokenizer.is_eof() && tokenizer.current_char() == '%' {
@@ -547,10 +547,10 @@ fn consume_unicode_range(tokenizer: &mut Tokenizer) -> ComponentValue {
547547
let start;
548548
let end;
549549
if question_marks > 0 {
550-
start = u32::from_str_radix(hex + "0".repeat(question_marks), 16).unwrap();
551-
end = u32::from_str_radix(hex + "F".repeat(question_marks), 16).unwrap();
550+
start = num::from_str_radix(hex + "0".repeat(question_marks), 16).unwrap();
551+
end = num::from_str_radix(hex + "F".repeat(question_marks), 16).unwrap();
552552
} else {
553-
start = u32::from_str_radix(hex, 16).unwrap();
553+
start = num::from_str_radix(hex, 16).unwrap();
554554
hex = ~"";
555555
if !tokenizer.is_eof() && tokenizer.current_char() == '-' {
556556
tokenizer.position += 1;
@@ -563,7 +563,7 @@ fn consume_unicode_range(tokenizer: &mut Tokenizer) -> ComponentValue {
563563
}
564564
}
565565
}
566-
end = if hex.len() > 0 { u32::from_str_radix(hex, 16).unwrap() } else { start }
566+
end = if hex.len() > 0 { num::from_str_radix(hex, 16).unwrap() } else { start }
567567
}
568568
UnicodeRange {start: start, end: end}
569569
}
@@ -594,10 +594,10 @@ fn consume_escape(tokenizer: &mut Tokenizer) -> char {
594594
}
595595
}
596596
static REPLACEMENT_CHAR: char = '\uFFFD';
597-
let c = u32::from_str_radix(hex, 16).unwrap();
597+
let c: u32 = num::from_str_radix(hex, 16).unwrap();
598598
if c != 0 {
599599
let c = char::from_u32(c);
600-
c.unwrap_or_default(REPLACEMENT_CHAR)
600+
c.unwrap_or(REPLACEMENT_CHAR)
601601
} else {
602602
REPLACEMENT_CHAR
603603
}

0 commit comments

Comments
 (0)