Camel case more std types
This commit is contained in:
@@ -23,7 +23,7 @@
|
|||||||
export sha1;
|
export sha1;
|
||||||
|
|
||||||
/// The SHA-1 interface
|
/// The SHA-1 interface
|
||||||
trait sha1 {
|
trait Sha1 {
|
||||||
/// Provide message input as bytes
|
/// Provide message input as bytes
|
||||||
fn input((&[u8]));
|
fn input((&[u8]));
|
||||||
/// Provide message input as string
|
/// Provide message input as string
|
||||||
@@ -53,8 +53,8 @@ const k3: u32 = 0xCA62C1D6u32;
|
|||||||
|
|
||||||
|
|
||||||
/// Construct a `sha` object
|
/// Construct a `sha` object
|
||||||
fn sha1() -> sha1 {
|
fn sha1() -> Sha1 {
|
||||||
type sha1state =
|
type Sha1State =
|
||||||
{h: ~[mut u32],
|
{h: ~[mut u32],
|
||||||
mut len_low: u32,
|
mut len_low: u32,
|
||||||
mut len_high: u32,
|
mut len_high: u32,
|
||||||
@@ -63,7 +63,7 @@ fn sha1() -> sha1 {
|
|||||||
mut computed: bool,
|
mut computed: bool,
|
||||||
work_buf: @~[mut u32]};
|
work_buf: @~[mut u32]};
|
||||||
|
|
||||||
fn add_input(st: &sha1state, msg: &[u8]) {
|
fn add_input(st: &Sha1State, msg: &[u8]) {
|
||||||
assert (!st.computed);
|
assert (!st.computed);
|
||||||
for vec::each(msg) |element| {
|
for vec::each(msg) |element| {
|
||||||
st.msg_block[st.msg_block_idx] = element;
|
st.msg_block[st.msg_block_idx] = element;
|
||||||
@@ -79,7 +79,7 @@ fn sha1() -> sha1 {
|
|||||||
if st.msg_block_idx == msg_block_len { process_msg_block(st); }
|
if st.msg_block_idx == msg_block_len { process_msg_block(st); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn process_msg_block(st: &sha1state) {
|
fn process_msg_block(st: &Sha1State) {
|
||||||
assert (vec::len(st.h) == digest_buf_len);
|
assert (vec::len(st.h) == digest_buf_len);
|
||||||
assert (vec::len(*st.work_buf) == work_buf_len);
|
assert (vec::len(*st.work_buf) == work_buf_len);
|
||||||
let mut t: int; // Loop counter
|
let mut t: int; // Loop counter
|
||||||
@@ -158,7 +158,7 @@ fn sha1() -> sha1 {
|
|||||||
fn circular_shift(bits: u32, word: u32) -> u32 {
|
fn circular_shift(bits: u32, word: u32) -> u32 {
|
||||||
return word << bits | word >> 32u32 - bits;
|
return word << bits | word >> 32u32 - bits;
|
||||||
}
|
}
|
||||||
fn mk_result(st: &sha1state) -> ~[u8] {
|
fn mk_result(st: &Sha1State) -> ~[u8] {
|
||||||
if !(*st).computed { pad_msg(st); (*st).computed = true; }
|
if !(*st).computed { pad_msg(st); (*st).computed = true; }
|
||||||
let mut rs: ~[u8] = ~[];
|
let mut rs: ~[u8] = ~[];
|
||||||
for vec::each_mut((*st).h) |ptr_hpart| {
|
for vec::each_mut((*st).h) |ptr_hpart| {
|
||||||
@@ -181,7 +181,7 @@ fn sha1() -> sha1 {
|
|||||||
* call process_msg_block() appropriately. When it returns, it
|
* call process_msg_block() appropriately. When it returns, it
|
||||||
* can be assumed that the message digest has been computed.
|
* can be assumed that the message digest has been computed.
|
||||||
*/
|
*/
|
||||||
fn pad_msg(st: &sha1state) {
|
fn pad_msg(st: &Sha1State) {
|
||||||
assert (vec::len((*st).msg_block) == msg_block_len);
|
assert (vec::len((*st).msg_block) == msg_block_len);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -218,7 +218,7 @@ fn sha1() -> sha1 {
|
|||||||
process_msg_block(st);
|
process_msg_block(st);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl sha1state: sha1 {
|
impl Sha1State: Sha1 {
|
||||||
fn reset() {
|
fn reset() {
|
||||||
assert (vec::len(self.h) == digest_buf_len);
|
assert (vec::len(self.h) == digest_buf_len);
|
||||||
self.len_low = 0u32;
|
self.len_low = 0u32;
|
||||||
@@ -253,7 +253,7 @@ fn sha1() -> sha1 {
|
|||||||
mut computed: false,
|
mut computed: false,
|
||||||
work_buf: @vec::to_mut(vec::from_elem(work_buf_len, 0u32))
|
work_buf: @vec::to_mut(vec::from_elem(work_buf_len, 0u32))
|
||||||
};
|
};
|
||||||
let sh = st as sha1;
|
let sh = st as Sha1;
|
||||||
sh.reset();
|
sh.reset();
|
||||||
return sh;
|
return sh;
|
||||||
}
|
}
|
||||||
@@ -263,7 +263,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test() unsafe {
|
fn test() unsafe {
|
||||||
type test = {input: ~str, output: ~[u8]};
|
type Test = {input: ~str, output: ~[u8]};
|
||||||
|
|
||||||
fn a_million_letter_a() -> ~str {
|
fn a_million_letter_a() -> ~str {
|
||||||
let mut i = 0;
|
let mut i = 0;
|
||||||
@@ -273,7 +273,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
// Test messages from FIPS 180-1
|
// Test messages from FIPS 180-1
|
||||||
|
|
||||||
let fips_180_1_tests: ~[test] =
|
let fips_180_1_tests: ~[Test] =
|
||||||
~[{input: ~"abc",
|
~[{input: ~"abc",
|
||||||
output:
|
output:
|
||||||
~[0xA9u8, 0x99u8, 0x3Eu8, 0x36u8,
|
~[0xA9u8, 0x99u8, 0x3Eu8, 0x36u8,
|
||||||
@@ -299,7 +299,7 @@ mod tests {
|
|||||||
0x65u8, 0x34u8, 0x01u8, 0x6Fu8]}];
|
0x65u8, 0x34u8, 0x01u8, 0x6Fu8]}];
|
||||||
// Examples from wikipedia
|
// Examples from wikipedia
|
||||||
|
|
||||||
let wikipedia_tests: ~[test] =
|
let wikipedia_tests: ~[Test] =
|
||||||
~[{input: ~"The quick brown fox jumps over the lazy dog",
|
~[{input: ~"The quick brown fox jumps over the lazy dog",
|
||||||
output:
|
output:
|
||||||
~[0x2fu8, 0xd4u8, 0xe1u8, 0xc6u8,
|
~[0x2fu8, 0xd4u8, 0xe1u8, 0xc6u8,
|
||||||
|
|||||||
@@ -70,19 +70,33 @@ mod treemap;
|
|||||||
|
|
||||||
// And ... other stuff
|
// And ... other stuff
|
||||||
|
|
||||||
|
#[warn(non_camel_case_types)]
|
||||||
mod ebml;
|
mod ebml;
|
||||||
|
#[warn(non_camel_case_types)]
|
||||||
mod dbg;
|
mod dbg;
|
||||||
|
#[warn(non_camel_case_types)]
|
||||||
mod getopts;
|
mod getopts;
|
||||||
|
#[warn(non_camel_case_types)]
|
||||||
mod json;
|
mod json;
|
||||||
|
#[warn(non_camel_case_types)]
|
||||||
mod sha1;
|
mod sha1;
|
||||||
|
#[warn(non_camel_case_types)]
|
||||||
mod md4;
|
mod md4;
|
||||||
|
#[warn(non_camel_case_types)]
|
||||||
mod tempfile;
|
mod tempfile;
|
||||||
|
#[warn(non_camel_case_types)]
|
||||||
mod term;
|
mod term;
|
||||||
|
#[warn(non_camel_case_types)]
|
||||||
mod time;
|
mod time;
|
||||||
|
#[warn(non_camel_case_types)]
|
||||||
mod prettyprint;
|
mod prettyprint;
|
||||||
|
#[warn(non_camel_case_types)]
|
||||||
mod arena;
|
mod arena;
|
||||||
|
#[warn(non_camel_case_types)]
|
||||||
mod par;
|
mod par;
|
||||||
|
#[warn(non_camel_case_types)]
|
||||||
mod cmp;
|
mod cmp;
|
||||||
|
#[warn(non_camel_case_types)]
|
||||||
mod base64;
|
mod base64;
|
||||||
|
|
||||||
#[cfg(unicode)]
|
#[cfg(unicode)]
|
||||||
|
|||||||
@@ -6,12 +6,12 @@ import io::Reader;
|
|||||||
import result::{Result, Ok, Err};
|
import result::{Result, Ok, Err};
|
||||||
|
|
||||||
export
|
export
|
||||||
timespec,
|
Timespec,
|
||||||
get_time,
|
get_time,
|
||||||
precise_time_ns,
|
precise_time_ns,
|
||||||
precise_time_s,
|
precise_time_s,
|
||||||
tzset,
|
tzset,
|
||||||
tm,
|
Tm,
|
||||||
empty_tm,
|
empty_tm,
|
||||||
now,
|
now,
|
||||||
at,
|
at,
|
||||||
@@ -26,20 +26,20 @@ extern mod rustrt {
|
|||||||
|
|
||||||
fn rust_tzset();
|
fn rust_tzset();
|
||||||
// FIXME: The i64 values can be passed by-val when #2064 is fixed.
|
// FIXME: The i64 values can be passed by-val when #2064 is fixed.
|
||||||
fn rust_gmtime(&&sec: i64, &&nsec: i32, &&result: tm);
|
fn rust_gmtime(&&sec: i64, &&nsec: i32, &&result: Tm);
|
||||||
fn rust_localtime(&&sec: i64, &&nsec: i32, &&result: tm);
|
fn rust_localtime(&&sec: i64, &&nsec: i32, &&result: Tm);
|
||||||
fn rust_timegm(&&tm: tm, &sec: i64);
|
fn rust_timegm(&&tm: Tm, &sec: i64);
|
||||||
fn rust_mktime(&&tm: tm, &sec: i64);
|
fn rust_mktime(&&tm: Tm, &sec: i64);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A record specifying a time value in seconds and nanoseconds.
|
/// A record specifying a time value in seconds and nanoseconds.
|
||||||
type timespec = {sec: i64, nsec: i32};
|
type Timespec = {sec: i64, nsec: i32};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the current time as a `timespec` containing the seconds and
|
* Returns the current time as a `timespec` containing the seconds and
|
||||||
* nanoseconds since 1970-01-01T00:00:00Z.
|
* nanoseconds since 1970-01-01T00:00:00Z.
|
||||||
*/
|
*/
|
||||||
fn get_time() -> timespec {
|
fn get_time() -> Timespec {
|
||||||
let mut sec = 0i64;
|
let mut sec = 0i64;
|
||||||
let mut nsec = 0i32;
|
let mut nsec = 0i32;
|
||||||
rustrt::get_time(sec, nsec);
|
rustrt::get_time(sec, nsec);
|
||||||
@@ -68,7 +68,7 @@ fn tzset() {
|
|||||||
rustrt::rust_tzset();
|
rustrt::rust_tzset();
|
||||||
}
|
}
|
||||||
|
|
||||||
type tm_ = {
|
type Tm_ = {
|
||||||
tm_sec: i32, // seconds after the minute ~[0-60]
|
tm_sec: i32, // seconds after the minute ~[0-60]
|
||||||
tm_min: i32, // minutes after the hour ~[0-59]
|
tm_min: i32, // minutes after the hour ~[0-59]
|
||||||
tm_hour: i32, // hours after midnight ~[0-23]
|
tm_hour: i32, // hours after midnight ~[0-23]
|
||||||
@@ -83,12 +83,12 @@ type tm_ = {
|
|||||||
tm_nsec: i32, // nanoseconds
|
tm_nsec: i32, // nanoseconds
|
||||||
};
|
};
|
||||||
|
|
||||||
enum tm {
|
enum Tm {
|
||||||
tm_(tm_)
|
Tm_(Tm_)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn empty_tm() -> tm {
|
fn empty_tm() -> Tm {
|
||||||
tm_({
|
Tm_({
|
||||||
tm_sec: 0_i32,
|
tm_sec: 0_i32,
|
||||||
tm_min: 0_i32,
|
tm_min: 0_i32,
|
||||||
tm_hour: 0_i32,
|
tm_hour: 0_i32,
|
||||||
@@ -105,7 +105,7 @@ fn empty_tm() -> tm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the specified time in UTC
|
/// Returns the specified time in UTC
|
||||||
fn at_utc(clock: timespec) -> tm {
|
fn at_utc(clock: Timespec) -> Tm {
|
||||||
let mut {sec, nsec} = clock;
|
let mut {sec, nsec} = clock;
|
||||||
let mut tm = empty_tm();
|
let mut tm = empty_tm();
|
||||||
rustrt::rust_gmtime(sec, nsec, tm);
|
rustrt::rust_gmtime(sec, nsec, tm);
|
||||||
@@ -113,12 +113,12 @@ fn at_utc(clock: timespec) -> tm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the current time in UTC
|
/// Returns the current time in UTC
|
||||||
fn now_utc() -> tm {
|
fn now_utc() -> Tm {
|
||||||
at_utc(get_time())
|
at_utc(get_time())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the specified time in the local timezone
|
/// Returns the specified time in the local timezone
|
||||||
fn at(clock: timespec) -> tm {
|
fn at(clock: Timespec) -> Tm {
|
||||||
let mut {sec, nsec} = clock;
|
let mut {sec, nsec} = clock;
|
||||||
let mut tm = empty_tm();
|
let mut tm = empty_tm();
|
||||||
rustrt::rust_localtime(sec, nsec, tm);
|
rustrt::rust_localtime(sec, nsec, tm);
|
||||||
@@ -126,13 +126,13 @@ fn at(clock: timespec) -> tm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the current time in the local timezone
|
/// Returns the current time in the local timezone
|
||||||
fn now() -> tm {
|
fn now() -> Tm {
|
||||||
at(get_time())
|
at(get_time())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Parses the time from the string according to the format string.
|
/// Parses the time from the string according to the format string.
|
||||||
fn strptime(s: &str, format: &str) -> Result<tm, ~str> {
|
fn strptime(s: &str, format: &str) -> Result<Tm, ~str> {
|
||||||
type tm_mut = {
|
type TmMut = {
|
||||||
mut tm_sec: i32,
|
mut tm_sec: i32,
|
||||||
mut tm_min: i32,
|
mut tm_min: i32,
|
||||||
mut tm_hour: i32,
|
mut tm_hour: i32,
|
||||||
@@ -209,7 +209,7 @@ fn strptime(s: &str, format: &str) -> Result<tm, ~str> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_type(s: &str, pos: uint, ch: char, tm: &tm_mut)
|
fn parse_type(s: &str, pos: uint, ch: char, tm: &TmMut)
|
||||||
-> Result<uint, ~str> {
|
-> Result<uint, ~str> {
|
||||||
match ch {
|
match ch {
|
||||||
'A' => match match_strs(s, pos, ~[
|
'A' => match match_strs(s, pos, ~[
|
||||||
@@ -554,7 +554,7 @@ fn strptime(s: &str, format: &str) -> Result<tm, ~str> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if pos == len && rdr.eof() {
|
if pos == len && rdr.eof() {
|
||||||
Ok(tm_({
|
Ok(Tm_({
|
||||||
tm_sec: tm.tm_sec,
|
tm_sec: tm.tm_sec,
|
||||||
tm_min: tm.tm_min,
|
tm_min: tm.tm_min,
|
||||||
tm_hour: tm.tm_hour,
|
tm_hour: tm.tm_hour,
|
||||||
@@ -572,8 +572,8 @@ fn strptime(s: &str, format: &str) -> Result<tm, ~str> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn strftime(format: &str, +tm: tm) -> ~str {
|
fn strftime(format: &str, +tm: Tm) -> ~str {
|
||||||
fn parse_type(ch: char, tm: &tm) -> ~str {
|
fn parse_type(ch: char, tm: &Tm) -> ~str {
|
||||||
//FIXME (#2350): Implement missing types.
|
//FIXME (#2350): Implement missing types.
|
||||||
let die = || #fmt("strftime: can't understand this format %c ",
|
let die = || #fmt("strftime: can't understand this format %c ",
|
||||||
ch);
|
ch);
|
||||||
@@ -740,9 +740,9 @@ fn strftime(format: &str, +tm: tm) -> ~str {
|
|||||||
buf
|
buf
|
||||||
}
|
}
|
||||||
|
|
||||||
impl tm {
|
impl Tm {
|
||||||
/// Convert time to the seconds from January 1, 1970
|
/// Convert time to the seconds from January 1, 1970
|
||||||
fn to_timespec() -> timespec {
|
fn to_timespec() -> Timespec {
|
||||||
let mut sec = 0i64;
|
let mut sec = 0i64;
|
||||||
if self.tm_gmtoff == 0_i32 {
|
if self.tm_gmtoff == 0_i32 {
|
||||||
rustrt::rust_timegm(self, sec);
|
rustrt::rust_timegm(self, sec);
|
||||||
@@ -753,12 +753,12 @@ impl tm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Convert time to the local timezone
|
/// Convert time to the local timezone
|
||||||
fn to_local() -> tm {
|
fn to_local() -> Tm {
|
||||||
at(self.to_timespec())
|
at(self.to_timespec())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convert time to the UTC
|
/// Convert time to the UTC
|
||||||
fn to_utc() -> tm {
|
fn to_utc() -> Tm {
|
||||||
at_utc(self.to_timespec())
|
at_utc(self.to_timespec())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -168,8 +168,8 @@ fn get_dest_addr(dest: dest) -> ValueRef {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn log_fn_time(ccx: @crate_ctxt, name: ~str, start: time::timespec,
|
fn log_fn_time(ccx: @crate_ctxt, name: ~str, start: time::Timespec,
|
||||||
end: time::timespec) {
|
end: time::Timespec) {
|
||||||
let elapsed = 1000 * ((end.sec - start.sec) as int) +
|
let elapsed = 1000 * ((end.sec - start.sec) as int) +
|
||||||
((end.nsec as int) - (start.nsec as int)) / 1000000;
|
((end.nsec as int) - (start.nsec as int)) / 1000000;
|
||||||
vec::push(*ccx.stats.fn_times, {ident: name, time: elapsed});
|
vec::push(*ccx.stats.fn_times, {ident: name, time: elapsed});
|
||||||
|
|||||||
Reference in New Issue
Block a user