Skip to content

Commit 8b04829

Browse files
committed
Merge pull request chris-morgan#13 from metajack/rust-up
Upgrade to latest Rust.
2 parents a72a8e4 + 1f8a919 commit 8b04829

File tree

3 files changed

+42
-39
lines changed

3 files changed

+42
-39
lines changed

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
RUST=rust
2-
RUSTC=rustc
3-
RUSTFLAGS=-O -Z debug-info
1+
RUST ?= rust
2+
RUSTC ?= rustc
3+
RUSTFLAGS ?= -O -Z debug-info
44
VERSION=0.1-pre
55

66
libhttp_so=build/libhttp-20af9b1d3441fe5a-$(VERSION).so

src/libhttp/codegen/branchify.rs

Lines changed: 38 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -86,55 +86,58 @@ pub fn generate_branchified_method(
8686
valid: &str,
8787
unknown: &str) {
8888

89-
// Write Formatted
90-
macro_rules! wf(($($x:tt)*) => ({
91-
let s = fmt!($($x)*);
92-
writer.write(indentstr.as_bytes());
93-
writer.write(s.as_bytes());
94-
writer.write(bytes!("\n"));
95-
}))
96-
9789
fn r(writer: @Writer, branch: &ParseBranch, prefix: &str, indent: uint, read_call: &str,
9890
end: &str, max_len: &str, valid: &str, unknown: &str) {
9991
let indentstr = " ".repeat(indent * 4);
92+
let w = |s: &str| {
93+
writer.write(indentstr.as_bytes());
94+
writer.write(s.as_bytes());
95+
writer.write(bytes!("\n"));
96+
};
10097
for &c in branch.matches.iter() {
10198
let next_prefix = fmt!("%s%c", prefix, c as char);
102-
wf!("Some(b) if b == '%c' as u8 => match %s {", c as char, read_call);
99+
w(fmt!("Some(b) if b == '%c' as u8 => match %s {", c as char, read_call));
103100
for b in branch.children.iter() {
104101
r(writer, b, next_prefix, indent + 1, read_call, end, max_len, valid, unknown);
105102
}
106103
match branch.result {
107-
Some(ref result) => wf!(" Some(b) if b == SP => return Some(%s),", *result),
108-
None => wf!(" Some(b) if b == SP => return Some(%s),",
109-
unknown.replace("%s", fmt!("~\"%s\"", next_prefix))),
104+
Some(ref result) => w(fmt!(" Some(b) if b == SP => return Some(%s),", *result)),
105+
None => w(fmt!(" Some(b) if b == SP => return Some(%s),",
106+
unknown.replace("%s", fmt!("~\"%s\"", next_prefix)))),
110107
}
111-
wf!(" Some(b) if %s => (\"%s\", b),", valid, next_prefix);
112-
wf!(" _ => return None,");
113-
wf!("},");
108+
w(fmt!(" Some(b) if %s => (\"%s\", b),", valid, next_prefix));
109+
w(fmt!(" _ => return None,"));
110+
w(fmt!("},"));
114111
}
115112
}
116113
let indentstr = " ".repeat(indent * 4);
117-
wf!("let (s, next_byte) = match %s {", read_call);
114+
let w = |s: &str| {
115+
writer.write(indentstr.as_bytes());
116+
writer.write(s.as_bytes());
117+
writer.write(bytes!("\n"));
118+
};
119+
120+
w(fmt!("let (s, next_byte) = match %s {", read_call));
118121
for b in branches.iter() {
119122
r(writer, b, "", indent + 1, read_call, end, max_len, valid, unknown);
120123
}
121-
wf!(" Some(b) if %s => (\"\", b),", valid);
122-
wf!(" _ => return None,");
123-
wf!("};");
124-
wf!("// OK, that didn't pan out. Let's read the rest and see what we get.");
125-
wf!("let mut s = s.to_owned();");
126-
wf!("s.push_char(next_byte as char);");
127-
wf!("loop {");
128-
wf!(" match %s {", read_call);
129-
wf!(" Some(b) if b == %s => return Some(%s),", end, unknown.replace("%s", "s"));
130-
wf!(" Some(b) if %s => {", valid);
131-
wf!(" if s.len() == %s {", max_len);
132-
wf!(" // Too long; bad request");
133-
wf!(" return None;");
134-
wf!(" }");
135-
wf!(" s.push_char(b as char);");
136-
wf!(" },");
137-
wf!(" _ => return None,");
138-
wf!(" }");
139-
wf!("}");
124+
w(fmt!(" Some(b) if %s => (\"\", b),", valid));
125+
w(fmt!(" _ => return None,"));
126+
w(fmt!("};"));
127+
w(fmt!("// OK, that didn't pan out. Let's read the rest and see what we get."));
128+
w(fmt!("let mut s = s.to_owned();"));
129+
w(fmt!("s.push_char(next_byte as char);"));
130+
w(fmt!("loop {"));
131+
w(fmt!(" match %s {", read_call));
132+
w(fmt!(" Some(b) if b == %s => return Some(%s),", end, unknown.replace("%s", "s")));
133+
w(fmt!(" Some(b) if %s => {", valid));
134+
w(fmt!(" if s.len() == %s {", max_len));
135+
w(fmt!(" // Too long; bad request"));
136+
w(fmt!(" return None;"));
137+
w(fmt!(" }"));
138+
w(fmt!(" s.push_char(b as char);"));
139+
w(fmt!(" },"));
140+
w(fmt!(" _ => return None,"));
141+
w(fmt!(" }"));
142+
w(fmt!("}"));
140143
}

src/libhttp/headers/serialization_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ pub fn comma_split(value: &str) -> ~[~str] {
5050
}
5151

5252
pub fn comma_split_iter<'a>(value: &'a str)
53-
-> ::std::iterator::Map<'a, &'a str, &'a str, ::std::str::CharSplitIterator<'a, char>> {
53+
-> ::std::iter::Map<'a, &'a str, &'a str, ::std::str::CharSplitIterator<'a, char>> {
5454
value.split_iter(',').map(|w| w.trim_left())
5555
}
5656

0 commit comments

Comments
 (0)