Skip to content

Commit

Permalink
make in and foreach get treated as keywords
Browse files Browse the repository at this point in the history
  • Loading branch information
thestinger committed Aug 1, 2013
1 parent c47be69 commit dabd476
Show file tree
Hide file tree
Showing 30 changed files with 184 additions and 184 deletions.
6 changes: 3 additions & 3 deletions src/libextra/crypto/digest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub trait DigestUtil {
*
* * in The string to feed into the digest
*/
fn input_str(&mut self, in: &str);
fn input_str(&mut self, input: &str);

/**
* Convenience functon that retrieves the result of a digest as a
Expand All @@ -75,8 +75,8 @@ pub trait DigestUtil {
}

impl<D: Digest> DigestUtil for D {
fn input_str(&mut self, in: &str) {
self.input(in.as_bytes());
fn input_str(&mut self, input: &str) {
self.input(input.as_bytes());
}

fn result_str(&mut self) -> ~str {
Expand Down
100 changes: 50 additions & 50 deletions src/libextra/crypto/sha2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,34 +66,34 @@ struct Engine512 {
}

// Convert a [u8] to a u64 in big-endian format
fn to_u64(in: &[u8]) -> u64 {
(in[0] as u64) << 56 |
(in[1] as u64) << 48 |
(in[2] as u64) << 40 |
(in[3] as u64) << 32 |
(in[4] as u64) << 24 |
(in[5] as u64) << 16 |
(in[6] as u64) << 8 |
(in[7] as u64)
fn to_u64(input: &[u8]) -> u64 {
(input[0] as u64) << 56 |
(input[1] as u64) << 48 |
(input[2] as u64) << 40 |
(input[3] as u64) << 32 |
(input[4] as u64) << 24 |
(input[5] as u64) << 16 |
(input[6] as u64) << 8 |
(input[7] as u64)
}

// Convert a u64 to a [u8] in big endian format
fn from_u64(in: u64, out: &mut [u8]) {
out[0] = (in >> 56) as u8;
out[1] = (in >> 48) as u8;
out[2] = (in >> 40) as u8;
out[3] = (in >> 32) as u8;
out[4] = (in >> 24) as u8;
out[5] = (in >> 16) as u8;
out[6] = (in >> 8) as u8;
out[7] = in as u8;
fn from_u64(input: u64, out: &mut [u8]) {
out[0] = (input >> 56) as u8;
out[1] = (input >> 48) as u8;
out[2] = (input >> 40) as u8;
out[3] = (input >> 32) as u8;
out[4] = (input >> 24) as u8;
out[5] = (input >> 16) as u8;
out[6] = (input >> 8) as u8;
out[7] = input as u8;
}

impl Engine512 {
fn input_byte(&mut self, in: u8) {
fn input_byte(&mut self, input: u8) {
assert!(!self.finished)

self.input_buffer[self.input_buffer_idx] = in;
self.input_buffer[self.input_buffer_idx] = input;
self.input_buffer_idx += 1;

if (self.input_buffer_idx == 8) {
Expand All @@ -105,25 +105,25 @@ impl Engine512 {
self.bit_counter.add_bytes(1);
}

fn input_vec(&mut self, in: &[u8]) {
fn input_vec(&mut self, input: &[u8]) {
assert!(!self.finished)

let mut i = 0;

while i < in.len() && self.input_buffer_idx != 0 {
self.input_byte(in[i]);
while i < input.len() && self.input_buffer_idx != 0 {
self.input_byte(input[i]);
i += 1;
}

while in.len() - i >= 8 {
let w = to_u64(in.slice(i, i + 8));
while input.len() - i >= 8 {
let w = to_u64(input.slice(i, i + 8));
self.process_word(w);
self.bit_counter.add_bytes(8);
i += 8;
}

while i < in.len() {
self.input_byte(in[i]);
while i < input.len() {
self.input_byte(input[i]);
i += 1;
}
}
Expand All @@ -135,8 +135,8 @@ impl Engine512 {
self.W_idx = 0;
}

fn process_word(&mut self, in: u64) {
self.W[self.W_idx] = in;
fn process_word(&mut self, input: u64) {
self.W[self.W_idx] = input;
self.W_idx += 1;
if (self.W_idx == 16) {
self.W_idx = 0;
Expand Down Expand Up @@ -356,26 +356,26 @@ struct Engine256 {
}

// Convert a [u8] to a u32 in big endian format
fn to_u32(in: &[u8]) -> u32 {
(in[0] as u32) << 24 |
(in[1] as u32) << 16 |
(in[2] as u32) << 8 |
(in[3] as u32)
fn to_u32(input: &[u8]) -> u32 {
(input[0] as u32) << 24 |
(input[1] as u32) << 16 |
(input[2] as u32) << 8 |
(input[3] as u32)
}

// Convert a u32 to a [u8] in big endian format
fn from_u32(in: u32, out: &mut [u8]) {
out[0] = (in >> 24) as u8;
out[1] = (in >> 16) as u8;
out[2] = (in >> 8) as u8;
out[3] = in as u8;
fn from_u32(input: u32, out: &mut [u8]) {
out[0] = (input >> 24) as u8;
out[1] = (input >> 16) as u8;
out[2] = (input >> 8) as u8;
out[3] = input as u8;
}

impl Engine256 {
fn input_byte(&mut self, in: u8) {
fn input_byte(&mut self, input: u8) {
assert!(!self.finished)

self.input_buffer[self.input_buffer_idx] = in;
self.input_buffer[self.input_buffer_idx] = input;
self.input_buffer_idx += 1;

if (self.input_buffer_idx == 4) {
Expand All @@ -387,25 +387,25 @@ impl Engine256 {
self.length_bytes += 1;
}

fn input_vec(&mut self, in: &[u8]) {
fn input_vec(&mut self, input: &[u8]) {
assert!(!self.finished)

let mut i = 0;

while i < in.len() && self.input_buffer_idx != 0 {
self.input_byte(in[i]);
while i < input.len() && self.input_buffer_idx != 0 {
self.input_byte(input[i]);
i += 1;
}

while in.len() - i >= 4 {
let w = to_u32(in.slice(i, i + 4));
while input.len() - i >= 4 {
let w = to_u32(input.slice(i, i + 4));
self.process_word(w);
self.length_bytes += 4;
i += 4;
}

while i < in.len() {
self.input_byte(in[i]);
while i < input.len() {
self.input_byte(input[i]);
i += 1;
}

Expand All @@ -418,8 +418,8 @@ impl Engine256 {
self.W_idx = 0;
}

fn process_word(&mut self, in: u32) {
self.W[self.W_idx] = in;
fn process_word(&mut self, input: u32) {
self.W[self.W_idx] = input;
self.W_idx += 1;
if (self.W_idx == 16) {
self.W_idx = 0;
Expand Down
22 changes: 11 additions & 11 deletions src/libextra/fileinput.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ input, skips the current file and then numbers the remaining lines
(where the numbers are from the start of each file, rather than the
total line count).
let in = FileInput::from_vec(pathify([~"a.txt", ~"b.txt", ~"c.txt"],
let input = FileInput::from_vec(pathify([~"a.txt", ~"b.txt", ~"c.txt"],
true));
for in.each_line |line| {
for input.each_line |line| {
if line.is_empty() {
break
}
Expand All @@ -85,9 +85,9 @@ total line count).
io::println("Continue?");
if io::stdin().read_line() == ~"yes" {
in.next_file(); // skip!
input.next_file(); // skip!
for in.each_line_state |line, state| {
for input.each_line_state |line, state| {
io::println(fmt!("%u: %s", state.line_num_file,
line))
}
Expand Down Expand Up @@ -589,29 +589,29 @@ mod test {
make_file(filename.get_ref(), contents);
}

let in = FileInput::from_vec(filenames);
let input = FileInput::from_vec(filenames);

// read once from 0
assert_eq!(in.read_line(), ~"0 1");
in.next_file(); // skip the rest of 1
assert_eq!(input.read_line(), ~"0 1");
input.next_file(); // skip the rest of 1

// read all lines from 1 (but don't read any from 2),
for uint::range(1, 4) |i| {
assert_eq!(in.read_line(), fmt!("1 %u", i));
assert_eq!(input.read_line(), fmt!("1 %u", i));
}
// 1 is finished, but 2 hasn't been started yet, so this will
// just "skip" to the beginning of 2 (Python's fileinput does
// the same)
in.next_file();
input.next_file();

assert_eq!(in.read_line(), ~"2 1");
assert_eq!(input.read_line(), ~"2 1");
}

#[test]
#[should_fail]
fn test_input_vec_missing_file() {
for input_vec(pathify([~"this/file/doesnt/exist"], true)) |line| {
io::println(line);
println(line);
}
}
}
14 changes: 7 additions & 7 deletions src/libextra/flate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,18 @@ mod tests {
words.push(r.gen_bytes(range));
}
for 20.times {
let mut in = ~[];
let mut input = ~[];
for 2000.times {
in.push_all(r.choose(words));
input.push_all(r.choose(words));
}
debug!("de/inflate of %u bytes of random word-sequences",
in.len());
let cmp = deflate_bytes(in);
input.len());
let cmp = deflate_bytes(input);
let out = inflate_bytes(cmp);
debug!("%u bytes deflated to %u (%.1f%% size)",
in.len(), cmp.len(),
100.0 * ((cmp.len() as float) / (in.len() as float)));
assert_eq!(in, out);
input.len(), cmp.len(),
100.0 * ((cmp.len() as float) / (input.len() as float)));
assert_eq!(input, out);
}
}
}
2 changes: 1 addition & 1 deletion src/libextra/semver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ pub fn parse(s: &str) -> Option<Version> {
}
let s = s.trim();
let mut bad = false;
do bad_parse::cond.trap(|_| { debug!("bad"); bad = true }).in {
do bad_parse::cond.trap(|_| { debug!("bad"); bad = true }).inside {
do io::with_str_reader(s) |rdr| {
let v = parse_reader(rdr);
if bad || v.to_str() != s.to_owned() {
Expand Down
22 changes: 11 additions & 11 deletions src/libextra/url.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ fn get_authority(rawurl: &str) ->

let len = rawurl.len();
let mut st = Start;
let mut in = Digit; // most restricted, start here.
let mut input = Digit; // most restricted, start here.

let mut userinfo = None;
let mut host = ~"";
Expand All @@ -425,13 +425,13 @@ fn get_authority(rawurl: &str) ->
match c {
'0' .. '9' => (),
'A' .. 'F' | 'a' .. 'f' => {
if in == Digit {
in = Hex;
if input == Digit {
input = Hex;
}
}
'G' .. 'Z' | 'g' .. 'z' | '-' | '.' | '_' | '~' | '%' |
'&' |'\'' | '(' | ')' | '+' | '!' | '*' | ',' | ';' | '=' => {
in = Unreserved;
input = Unreserved;
}
':' | '@' | '?' | '#' | '/' => {
// separators, don't change anything
Expand All @@ -452,7 +452,7 @@ fn get_authority(rawurl: &str) ->
}
PassHostPort => {
// multiple colons means ipv6 address.
if in == Unreserved {
if input == Unreserved {
return Err(
~"Illegal characters in IPv6 address.");
}
Expand All @@ -461,13 +461,13 @@ fn get_authority(rawurl: &str) ->
InHost => {
pos = i;
// can't be sure whether this is an ipv6 address or a port
if in == Unreserved {
if input == Unreserved {
return Err(~"Illegal characters in authority.");
}
st = Ip6Port;
}
Ip6Port => {
if in == Unreserved {
if input == Unreserved {
return Err(~"Illegal characters in authority.");
}
st = Ip6Host;
Expand All @@ -483,11 +483,11 @@ fn get_authority(rawurl: &str) ->
return Err(~"Invalid ':' in authority.");
}
}
in = Digit; // reset input class
input = Digit; // reset input class
}

'@' => {
in = Digit; // reset input class
input = Digit; // reset input class
colon_count = 0; // reset count
match st {
Start => {
Expand Down Expand Up @@ -535,7 +535,7 @@ fn get_authority(rawurl: &str) ->
}
}
PassHostPort | Ip6Port => {
if in != Digit {
if input != Digit {
return Err(~"Non-digit characters in port.");
}
host = rawurl.slice(begin, pos).to_owned();
Expand All @@ -545,7 +545,7 @@ fn get_authority(rawurl: &str) ->
host = rawurl.slice(begin, end).to_owned();
}
InPort => {
if in != Digit {
if input != Digit {
return Err(~"Non-digit characters in port.");
}
port = Some(rawurl.slice(pos+1, end).to_owned());
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -706,8 +706,8 @@ fn check_item_ctypes(cx: &Context, it: &ast::item) {
}

fn check_foreign_fn(cx: &Context, decl: &ast::fn_decl) {
for decl.inputs.iter().advance |in| {
check_ty(cx, &in.ty);
for decl.inputs.iter().advance |input| {
check_ty(cx, &input.ty);
}
check_ty(cx, &decl.output)
}
Expand Down
Loading

0 comments on commit dabd476

Please sign in to comment.