-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Closed
Labels
A-FFIArea: Foreign function interface (FFI)Area: Foreign function interface (FFI)A-testsuiteArea: The testsuite used to check the correctness of rustcArea: The testsuite used to check the correctness of rustc
Description
The FFI tutorial for 0.5 (http://static.rust-lang.org/doc/0.5/tutorial-ffi.html) contains this code, busted in two places:
extern mod std;
use libc::c_uint;
extern mod crypto {
fn SHA1(src: *u8, sz: c_uint, out: *u8) -> *u8;
}
fn as_hex(data: ~[u8]) -> ~str {
let mut acc = ~"";
for data.each |byte| { acc += fmt!("%02x", byte as uint); }
return acc;
}
fn sha1(data: ~str) -> ~str unsafe {
let bytes = str::to_bytes(data);
let hash = crypto::SHA1(vec::raw::to_ptr(bytes),
vec::len(bytes) as c_uint, ptr::null());
return as_hex(vec::from_buf(hash, 20));
}
fn main(args: ~[~str]) {
io::println(sha1(args[1]));
}
(See for data.each |byte|
and fn main(args ~[~str])
.)
I thus conclude that it isn't being tested automatically like the other docs are.
Metadata
Metadata
Assignees
Labels
A-FFIArea: Foreign function interface (FFI)Area: Foreign function interface (FFI)A-testsuiteArea: The testsuite used to check the correctness of rustcArea: The testsuite used to check the correctness of rustc