Skip to content

Commit 5998319

Browse files
committed
---
yaml --- r: 146671 b: refs/heads/try2 c: 5d466ff h: refs/heads/master i: 146669: a36f71b 146667: 2088ef5 146663: f97b760 146655: 8315cdc v: v3
1 parent 422f6c2 commit 5998319

File tree

4 files changed

+73
-74
lines changed

4 files changed

+73
-74
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 2c9e56f0ed96a7ebc9d6a854f64397f715069feb
8+
refs/heads/try2: 5d466ff96ece2e050424a11771ce003488dc2d24
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libextra/url.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -364,16 +364,6 @@ fn query_from_str(rawquery: &str) -> Query {
364364
return query;
365365
}
366366

367-
/**
368-
* Converts an instance of a URI `Query` type to a string.
369-
*
370-
* # Example
371-
*
372-
* ```rust
373-
* let query = ~[(~"title", ~"The Village"), (~"north", ~"52.91"), (~"west", ~"4.10")];
374-
* println(query_to_str(&query)); // title=The%20Village&north=52.91&west=4.10
375-
* ```
376-
*/
377367
pub fn query_to_str(query: &Query) -> ~str {
378368
let mut strvec = ~[];
379369
for kv in query.iter() {
Lines changed: 48 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,64 @@
1-
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
2-
// file at the top-level directory of this distribution and at
3-
// http://rust-lang.org/COPYRIGHT.
4-
//
5-
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6-
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7-
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8-
// option. This file may not be copied, modified, or distributed
9-
// except according to those terms.
1+
// xfail-test reading from os::args()[1] - bogus!
102

11-
use std::io::buffered::BufferedWriter;
3+
use std::cast::transmute;
4+
use std::from_str::FromStr;
5+
use std::libc::{STDOUT_FILENO, c_int, fdopen, fputc};
6+
use std::os;
127

13-
struct DummyWriter;
14-
impl Writer for DummyWriter {
15-
fn write(&mut self, _: &[u8]) {}
16-
}
17-
18-
static ITER: int = 50;
8+
static ITER: uint = 50;
199
static LIMIT: f64 = 2.0;
2010

2111
fn main() {
22-
let args = std::os::args();
23-
let (w, mut out) = if args.len() < 2 {
24-
println("Test mode: do not dump the image because it's not utf8, \
25-
which interferes with the test runner.");
26-
(1000, ~DummyWriter as ~Writer)
27-
} else {
28-
(from_str(args[1]).unwrap(),
29-
~BufferedWriter::new(std::io::stdout()) as ~Writer)
30-
};
31-
let h = w;
32-
let mut byte_acc = 0u8;
33-
let mut bit_num = 0;
12+
unsafe {
13+
let w: i32 = FromStr::from_str(os::args()[1]).unwrap();
14+
let h = w;
15+
let mut byte_acc: i8 = 0;
16+
let mut bit_num: i32 = 0;
3417

35-
writeln!(out, "P4\n{} {}", w, h);
18+
println!("P4\n{} {}", w, h);
3619

37-
for y in range(0, h) {
38-
let y = y as f64;
39-
for x in range(0, w) {
40-
let mut z_r = 0f64;
41-
let mut z_i = 0f64;
42-
let mut t_r = 0f64;
43-
let mut t_i = 0f64;
44-
let c_r = 2.0 * (x as f64) / (w as f64) - 1.5;
45-
let c_i = 2.0 * (y as f64) / (h as f64) - 1.0;
20+
let mode = "w";
21+
let stdout = fdopen(STDOUT_FILENO as c_int, transmute(&mode[0]));
4622

47-
for _ in range(0, ITER) {
48-
if t_r + t_i > LIMIT * LIMIT {
49-
break;
50-
}
23+
for y in range(0i32, h) {
24+
let y = y as f64;
25+
for x in range(0i32, w) {
26+
let mut Zr = 0f64;
27+
let mut Zi = 0f64;
28+
let mut Tr = 0f64;
29+
let mut Ti = 0f64;
30+
let Cr = 2.0 * (x as f64) / (w as f64) - 1.5;
31+
let Ci = 2.0 * (y as f64) / (h as f64) - 1.0;
5132

52-
z_i = 2.0 * z_r * z_i + c_i;
53-
z_r = t_r - t_i + c_r;
54-
t_r = z_r * z_r;
55-
t_i = z_i * z_i;
56-
}
33+
for _ in range(0i32, ITER as i32) {
34+
if Tr + Ti > LIMIT * LIMIT {
35+
break;
36+
}
5737

58-
byte_acc <<= 1;
59-
if t_r + t_i <= LIMIT * LIMIT {
60-
byte_acc |= 1;
61-
}
38+
Zi = 2.0*Zr*Zi + Ci;
39+
Zr = Tr - Ti + Cr;
40+
Tr = Zr * Zr;
41+
Ti = Zi * Zi;
42+
}
43+
44+
byte_acc <<= 1;
45+
if Tr + Ti <= LIMIT * LIMIT {
46+
byte_acc |= 1;
47+
}
6248

63-
bit_num += 1;
49+
bit_num += 1;
6450

65-
if bit_num == 8 {
66-
out.write_u8(byte_acc);
67-
byte_acc = 0;
68-
bit_num = 0;
69-
} else if x == w - 1 {
70-
byte_acc <<= 8 - w % 8;
71-
out.write_u8(byte_acc);
72-
byte_acc = 0;
73-
bit_num = 0;
51+
if bit_num == 8 {
52+
fputc(byte_acc as c_int, stdout);
53+
byte_acc = 0;
54+
bit_num = 0;
55+
} else if x == w - 1 {
56+
byte_acc <<= 8 - w%8;
57+
fputc(byte_acc as c_int, stdout);
58+
byte_acc = 0;
59+
bit_num = 0;
60+
}
7461
}
7562
}
7663
}
77-
78-
out.flush();
7964
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#[feature(macro_rules)];
12+
13+
macro_rules! define_vec (
14+
() => (
15+
mod foo {
16+
#[deriving(Eq)]
17+
pub struct bar;
18+
}
19+
)
20+
)
21+
22+
define_vec!()
23+
24+
pub fn main() {}

0 commit comments

Comments
 (0)