Skip to content

Commit bc5b088

Browse files
author
Tuncer Ayaz
committed
---
yaml --- r: 63631 b: refs/heads/snap-stage3 c: 0a74ffc h: refs/heads/master i: 63629: f78feb2 63627: b779641 63623: d8f247f 63615: d6ba531 v: v3
1 parent f85815b commit bc5b088

File tree

112 files changed

+2047
-1633
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+2047
-1633
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: b94f89fffc0c31a2e9048a824a66ff121c908818
4+
refs/heads/snap-stage3: 0a74ffcf042cfd6d4b1890e2c2b46e3e0ebaacfd
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/RELEASES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ Version 0.7 (July 2013)
7878
* extra: `BigInt`, `BigUint` implement numeric and comparison traits.
7979
* extra: `term` uses terminfo now, is more correct.
8080
* extra: `arc` functions converted to methods.
81+
* extra: Implementation of fixed output size variations of SHA-2.
8182

8283
* Tooling
8384
* `unused_unsafe` lint mode for detecting unnecessary `unsafe` blocks.

branches/snap-stage3/src/etc/vim/syntax/rust.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
" Language: Rust
33
" Maintainer: Patrick Walton <[email protected]>
44
" Maintainer: Ben Blum <[email protected]>
5-
" Last Change: 2012 Jun 14
5+
" Last Change: 2013 Jun 14
66

77
if version < 600
88
syntax clear

branches/snap-stage3/src/libextra/arena.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -39,7 +39,7 @@ use core::prelude::*;
3939
use list::{MutList, MutCons, MutNil};
4040

4141
use core::at_vec;
42-
use core::cast::{transmute, transmute_mut_region};
42+
use core::cast::{transmute, transmute_mut, transmute_mut_region};
4343
use core::cast;
4444
use core::libc::size_t;
4545
use core::ptr;
@@ -74,6 +74,7 @@ struct Chunk {
7474
is_pod: bool,
7575
}
7676

77+
#[mutable]
7778
pub struct Arena {
7879
// The head is separated out from the list as a unbenchmarked
7980
// microoptimization, to avoid needing to case on the list to
@@ -269,23 +270,22 @@ impl Arena {
269270

270271
// The external interface
271272
#[inline]
272-
pub fn alloc<'a, T>(&'a mut self, op: &fn() -> T) -> &'a T {
273+
pub fn alloc<'a, T>(&'a self, op: &fn() -> T) -> &'a T {
273274
unsafe {
274275
// XXX: Borrow check
275-
let this = transmute_mut_region(self);
276-
if !intrinsics::needs_drop::<T>() {
277-
return this.alloc_pod(op);
276+
let this = transmute_mut(self);
277+
if intrinsics::needs_drop::<T>() {
278+
this.alloc_nonpod(op)
279+
} else {
280+
this.alloc_pod(op)
278281
}
279-
// XXX: Borrow check
280-
let this = transmute_mut_region(self);
281-
this.alloc_nonpod(op)
282282
}
283283
}
284284
}
285285

286286
#[test]
287287
fn test_arena_destructors() {
288-
let mut arena = Arena();
288+
let arena = Arena();
289289
for uint::range(0, 10) |i| {
290290
// Arena allocate something with drop glue to make sure it
291291
// doesn't leak.
@@ -300,7 +300,7 @@ fn test_arena_destructors() {
300300
#[should_fail]
301301
#[ignore(cfg(windows))]
302302
fn test_arena_destructors_fail() {
303-
let mut arena = Arena();
303+
let arena = Arena();
304304
// Put some stuff in the arena.
305305
for uint::range(0, 10) |i| {
306306
// Arena allocate something with drop glue to make sure it

branches/snap-stage3/src/libextra/bitv.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -666,12 +666,8 @@ impl BitvSet {
666666
pub fn symmetric_difference_with(&mut self, other: &BitvSet) {
667667
self.other_op(other, |w1, w2| w1 ^ w2);
668668
}
669-
}
670-
671-
impl BaseIter<uint> for BitvSet {
672-
fn size_hint(&self) -> Option<uint> { Some(self.len()) }
673669

674-
fn each(&self, blk: &fn(v: &uint) -> bool) -> bool {
670+
pub fn each(&self, blk: &fn(v: &uint) -> bool) -> bool {
675671
for self.bitv.storage.iter().enumerate().advance |(i, &w)| {
676672
if !iterate_bits(i * uint::bits, w, |b| blk(&b)) {
677673
return false;
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
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.
10+
11+
use core::prelude::*;
12+
13+
use core::uint;
14+
use core::vec;
15+
16+
/**
17+
* The Digest trait specifies an interface common to digest functions, such as SHA-1 and the SHA-2
18+
* family of digest functions.
19+
*/
20+
pub trait Digest {
21+
/**
22+
* Provide message data.
23+
*
24+
* # Arguments
25+
*
26+
* * input - A vector of message data
27+
*/
28+
fn input(&mut self, input: &[u8]);
29+
30+
/**
31+
* Retrieve the digest result. This method may be called multiple times.
32+
*/
33+
fn result(&mut self, out: &mut [u8]);
34+
35+
/**
36+
* Reset the digest. This method must be called after result() and before supplying more
37+
* data.
38+
*/
39+
fn reset(&mut self);
40+
41+
/**
42+
* Get the output size in bits.
43+
*/
44+
fn output_bits(&self) -> uint;
45+
}
46+
47+
fn to_hex(rr: &[u8]) -> ~str {
48+
let mut s = ~"";
49+
for rr.iter().advance() |b| {
50+
let hex = uint::to_str_radix(*b as uint, 16u);
51+
if hex.len() == 1 {
52+
s += "0";
53+
}
54+
s += hex;
55+
}
56+
return s;
57+
}
58+
59+
/// Contains utility methods for Digests.
60+
/// FIXME: #7339: Convert to default methods when issues with them are resolved.
61+
pub trait DigestUtil {
62+
/**
63+
* Convenience functon that feeds a string into a digest
64+
*
65+
* # Arguments
66+
*
67+
* * in The string to feed into the digest
68+
*/
69+
fn input_str(&mut self, in: &str);
70+
71+
/**
72+
* Convenience functon that retrieves the result of a digest as a
73+
* ~str in hexadecimal format.
74+
*/
75+
fn result_str(&mut self) -> ~str;
76+
}
77+
78+
impl<D: Digest> DigestUtil for D {
79+
fn input_str(&mut self, in: &str) {
80+
self.input(in.as_bytes());
81+
}
82+
83+
fn result_str(&mut self) -> ~str {
84+
let mut buf = vec::from_elem((self.output_bits()+7)/8, 0u8);
85+
self.result(buf);
86+
return to_hex(buf);
87+
}
88+
}

0 commit comments

Comments
 (0)