mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-31 21:17:46 +00:00
Use new array syntax
This commit is contained in:
parent
074a58eafd
commit
7d8053561e
14 changed files with 47 additions and 47 deletions
|
@ -99,8 +99,8 @@ fn write_lines(files: Vec<String>, number: NumberingMode, squeeze_blank: bool,
|
|||
None => continue,
|
||||
};
|
||||
|
||||
let mut in_buf = [0, .. 1024 * 31];
|
||||
let mut out_buf = [0, .. 1024 * 64];
|
||||
let mut in_buf = [0; 1024 * 31];
|
||||
let mut out_buf = [0; 1024 * 64];
|
||||
let mut writer = UnsafeWriter::new(out_buf.as_mut_slice(), stdout_raw());
|
||||
let mut at_line_start = true;
|
||||
loop {
|
||||
|
@ -175,8 +175,8 @@ fn write_bytes(files: Vec<String>, number: NumberingMode, squeeze_blank: bool,
|
|||
// Flush all 1024 iterations.
|
||||
let mut flush_counter = range(0u, 1024);
|
||||
|
||||
let mut in_buf = [0, .. 1024 * 32];
|
||||
let mut out_buf = [0, .. 1024 * 64];
|
||||
let mut in_buf = [0; 1024 * 32];
|
||||
let mut out_buf = [0; 1024 * 64];
|
||||
let mut writer = UnsafeWriter::new(out_buf.as_mut_slice(), stdout_raw());
|
||||
let mut at_line_start = true;
|
||||
loop {
|
||||
|
@ -242,7 +242,7 @@ fn write_bytes(files: Vec<String>, number: NumberingMode, squeeze_blank: bool,
|
|||
|
||||
fn write_fast(files: Vec<String>) {
|
||||
let mut writer = stdout_raw();
|
||||
let mut in_buf = [0, .. 1024 * 64];
|
||||
let mut in_buf = [0; 1024 * 64];
|
||||
|
||||
for path in files.iter() {
|
||||
let (mut reader, _) = match open(path.as_slice()) {
|
||||
|
|
|
@ -59,7 +59,7 @@ fn cksum(fname: &str) -> IoResult<(u32, uint)> {
|
|||
}
|
||||
};
|
||||
|
||||
let mut bytes: [u8, ..1024 * 1024] = unsafe { mem::uninitialized() };
|
||||
let mut bytes: [u8; 1024 * 1024] = unsafe { mem::uninitialized() };
|
||||
loop {
|
||||
match rd.read(&mut bytes) {
|
||||
Ok(num_bytes) => {
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
/* auto-generated (DO NOT EDIT) */
|
||||
|
||||
pub static CRC_TABLE: [u32, ..256] = [0, 79764919, 159529838, 222504665, 319059676, 398814059, 445009330, 507990021, 638119352, 583659535, 797628118, 726387553, 890018660, 835552979, 1015980042, 944750013, 1276238704, 1221641927, 1167319070, 1095957929, 1595256236, 1540665371, 1452775106, 1381403509, 1780037320, 1859660671, 1671105958, 1733955601, 2031960084, 2111593891, 1889500026, 1952343757, 2552477408, 2632100695, 2443283854, 2506133561, 2334638140, 2414271883, 2191915858, 2254759653, 3190512472, 3135915759, 3081330742, 3009969537, 2905550212, 2850959411, 2762807018, 2691435357, 3560074640, 3505614887, 3719321342, 3648080713, 3342211916, 3287746299, 3467911202, 3396681109, 4063920168, 4143685023, 4223187782, 4286162673, 3779000052, 3858754371, 3904687514, 3967668269, 881225847, 809987520, 1023691545, 969234094, 662832811, 591600412, 771767749, 717299826, 311336399, 374308984, 453813921, 533576470, 25881363, 88864420, 134795389, 214552010, 2023205639, 2086057648, 1897238633, 1976864222, 1804852699, 1867694188, 1645340341, 1724971778, 1587496639, 1516133128, 1461550545, 1406951526, 1302016099, 1230646740, 1142491917, 1087903418, 2896545431, 2825181984, 2770861561, 2716262478, 3215044683, 3143675388, 3055782693, 3001194130, 2326604591, 2389456536, 2200899649, 2280525302, 2578013683, 2640855108, 2418763421, 2498394922, 3769900519, 3832873040, 3912640137, 3992402750, 4088425275, 4151408268, 4197601365, 4277358050, 3334271071, 3263032808, 3476998961, 3422541446, 3585640067, 3514407732, 3694837229, 3640369242, 1762451694, 1842216281, 1619975040, 1682949687, 2047383090, 2127137669, 1938468188, 2001449195, 1325665622, 1271206113, 1183200824, 1111960463, 1543535498, 1489069629, 1434599652, 1363369299, 622672798, 568075817, 748617968, 677256519, 907627842, 853037301, 1067152940, 995781531, 51762726, 131386257, 177728840, 240578815, 269590778, 349224269, 429104020, 491947555, 4046411278, 4126034873, 4172115296, 4234965207, 3794477266, 3874110821, 3953728444, 4016571915, 3609705398, 3555108353, 3735388376, 3664026991, 3290680682, 3236090077, 3449943556, 3378572211, 3174993278, 3120533705, 3032266256, 2961025959, 2923101090, 2868635157, 2813903052, 2742672763, 2604032198, 2683796849, 2461293480, 2524268063, 2284983834, 2364738477, 2175806836, 2238787779, 1569362073, 1498123566, 1409854455, 1355396672, 1317987909, 1246755826, 1192025387, 1137557660, 2072149281, 2135122070, 1912620623, 1992383480, 1753615357, 1816598090, 1627664531, 1707420964, 295390185, 358241886, 404320391, 483945776, 43990325, 106832002, 186451547, 266083308, 932423249, 861060070, 1041341759, 986742920, 613929101, 542559546, 756411363, 701822548, 3316196985, 3244833742, 3425377559, 3370778784, 3601682597, 3530312978, 3744426955, 3689838204, 3819031489, 3881883254, 3928223919, 4007849240, 4037393693, 4100235434, 4180117107, 4259748804, 2310601993, 2373574846, 2151335527, 2231098320, 2596047829, 2659030626, 2470359227, 2550115596, 2947551409, 2876312838, 2788305887, 2733848168, 3165939309, 3094707162, 3040238851, 2985771188];
|
||||
pub static CRC_TABLE: [u32; 256] = [0, 79764919, 159529838, 222504665, 319059676, 398814059, 445009330, 507990021, 638119352, 583659535, 797628118, 726387553, 890018660, 835552979, 1015980042, 944750013, 1276238704, 1221641927, 1167319070, 1095957929, 1595256236, 1540665371, 1452775106, 1381403509, 1780037320, 1859660671, 1671105958, 1733955601, 2031960084, 2111593891, 1889500026, 1952343757, 2552477408, 2632100695, 2443283854, 2506133561, 2334638140, 2414271883, 2191915858, 2254759653, 3190512472, 3135915759, 3081330742, 3009969537, 2905550212, 2850959411, 2762807018, 2691435357, 3560074640, 3505614887, 3719321342, 3648080713, 3342211916, 3287746299, 3467911202, 3396681109, 4063920168, 4143685023, 4223187782, 4286162673, 3779000052, 3858754371, 3904687514, 3967668269, 881225847, 809987520, 1023691545, 969234094, 662832811, 591600412, 771767749, 717299826, 311336399, 374308984, 453813921, 533576470, 25881363, 88864420, 134795389, 214552010, 2023205639, 2086057648, 1897238633, 1976864222, 1804852699, 1867694188, 1645340341, 1724971778, 1587496639, 1516133128, 1461550545, 1406951526, 1302016099, 1230646740, 1142491917, 1087903418, 2896545431, 2825181984, 2770861561, 2716262478, 3215044683, 3143675388, 3055782693, 3001194130, 2326604591, 2389456536, 2200899649, 2280525302, 2578013683, 2640855108, 2418763421, 2498394922, 3769900519, 3832873040, 3912640137, 3992402750, 4088425275, 4151408268, 4197601365, 4277358050, 3334271071, 3263032808, 3476998961, 3422541446, 3585640067, 3514407732, 3694837229, 3640369242, 1762451694, 1842216281, 1619975040, 1682949687, 2047383090, 2127137669, 1938468188, 2001449195, 1325665622, 1271206113, 1183200824, 1111960463, 1543535498, 1489069629, 1434599652, 1363369299, 622672798, 568075817, 748617968, 677256519, 907627842, 853037301, 1067152940, 995781531, 51762726, 131386257, 177728840, 240578815, 269590778, 349224269, 429104020, 491947555, 4046411278, 4126034873, 4172115296, 4234965207, 3794477266, 3874110821, 3953728444, 4016571915, 3609705398, 3555108353, 3735388376, 3664026991, 3290680682, 3236090077, 3449943556, 3378572211, 3174993278, 3120533705, 3032266256, 2961025959, 2923101090, 2868635157, 2813903052, 2742672763, 2604032198, 2683796849, 2461293480, 2524268063, 2284983834, 2364738477, 2175806836, 2238787779, 1569362073, 1498123566, 1409854455, 1355396672, 1317987909, 1246755826, 1192025387, 1137557660, 2072149281, 2135122070, 1912620623, 1992383480, 1753615357, 1816598090, 1627664531, 1707420964, 295390185, 358241886, 404320391, 483945776, 43990325, 106832002, 186451547, 266083308, 932423249, 861060070, 1041341759, 986742920, 613929101, 542559546, 756411363, 701822548, 3316196985, 3244833742, 3425377559, 3370778784, 3601682597, 3530312978, 3744426955, 3689838204, 3819031489, 3881883254, 3928223919, 4007849240, 4037393693, 4100235434, 4180117107, 4259748804, 2310601993, 2373574846, 2151335527, 2231098320, 2596047829, 2659030626, 2470359227, 2550115596, 2947551409, 2876312838, 2788305887, 2733848168, 3165939309, 3094707162, 3040238851, 2985771188];
|
||||
|
|
|
@ -20,7 +20,7 @@ fn main() {
|
|||
let mut file = io::File::open_mode(&Path::new("crc_table.rs"), io::Truncate, io::Write).unwrap();
|
||||
let output = format!("/* auto-generated (DO NOT EDIT) */
|
||||
|
||||
pub static CRC_TABLE: [u32, ..{}] = {};", CRC_TABLE_LEN, table);
|
||||
pub static CRC_TABLE: [u32; {}] = {};", CRC_TABLE_LEN, table);
|
||||
file.write_line(output.as_slice()).unwrap();
|
||||
}
|
||||
|
||||
|
|
|
@ -52,22 +52,22 @@ impl Copy for c_passwd {}
|
|||
#[cfg(any(target_os = "macos", target_os = "freebsd"))]
|
||||
#[repr(C)]
|
||||
pub struct utsname {
|
||||
pub sysname: [c_char, ..256],
|
||||
pub nodename: [c_char, ..256],
|
||||
pub release: [c_char, ..256],
|
||||
pub version: [c_char, ..256],
|
||||
pub machine: [c_char, ..256]
|
||||
pub sysname: [c_char; 256],
|
||||
pub nodename: [c_char; 256],
|
||||
pub release: [c_char; 256],
|
||||
pub version: [c_char; 256],
|
||||
pub machine: [c_char; 256]
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
#[repr(C)]
|
||||
pub struct utsname {
|
||||
pub sysname: [c_char, ..65],
|
||||
pub nodename: [c_char, ..65],
|
||||
pub release: [c_char, ..65],
|
||||
pub version: [c_char, ..65],
|
||||
pub machine: [c_char, ..65],
|
||||
pub domainame: [c_char, ..65]
|
||||
pub sysname: [c_char; 65],
|
||||
pub nodename: [c_char; 65],
|
||||
pub release: [c_char; 65],
|
||||
pub version: [c_char; 65],
|
||||
pub machine: [c_char; 65],
|
||||
pub domainame: [c_char; 65]
|
||||
}
|
||||
|
||||
impl Copy for utsname {}
|
||||
|
|
|
@ -28,7 +28,7 @@ Linux Programmer's Manual
|
|||
*/
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
pub static ALL_SIGNALS:[Signal<'static>, ..31] = [
|
||||
pub static ALL_SIGNALS:[Signal<'static>; 31] = [
|
||||
Signal{ name: "HUP", value:1 },
|
||||
Signal{ name: "INT", value:2 },
|
||||
Signal{ name: "QUIT", value:3 },
|
||||
|
@ -105,7 +105,7 @@ No Name Default Action Description
|
|||
*/
|
||||
|
||||
#[cfg(any(target_os = "macos", target_os = "freebsd"))]
|
||||
pub static ALL_SIGNALS:[Signal<'static>, ..31] = [
|
||||
pub static ALL_SIGNALS:[Signal<'static>; 31] = [
|
||||
Signal{ name: "HUP", value:1 },
|
||||
Signal{ name: "INT", value:2 },
|
||||
Signal{ name: "QUIT", value:3 },
|
||||
|
|
|
@ -36,17 +36,17 @@ mod utmpx {
|
|||
pub struct c_utmp {
|
||||
pub ut_type: libc::c_short,
|
||||
pub ut_pid: libc::pid_t,
|
||||
pub ut_line: [libc::c_char, ..UT_LINESIZE],
|
||||
pub ut_id: [libc::c_char, ..UT_IDSIZE],
|
||||
pub ut_line: [libc::c_char; UT_LINESIZE],
|
||||
pub ut_id: [libc::c_char; UT_IDSIZE],
|
||||
|
||||
pub ut_user: [libc::c_char, ..UT_NAMESIZE],
|
||||
pub ut_host: [libc::c_char, ..UT_HOSTSIZE],
|
||||
pub ut_user: [libc::c_char; UT_NAMESIZE],
|
||||
pub ut_host: [libc::c_char; UT_HOSTSIZE],
|
||||
pub ut_exit: c_exit_status,
|
||||
pub ut_session: libc::c_long,
|
||||
pub ut_tv: libc::timeval,
|
||||
|
||||
pub ut_addr_v6: [libc::int32_t, ..4],
|
||||
pub __unused: [libc::c_char, ..20],
|
||||
pub ut_addr_v6: [libc::int32_t; 4],
|
||||
pub __unused: [libc::c_char; 20],
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -80,14 +80,14 @@ mod utmpx {
|
|||
|
||||
#[repr(C)]
|
||||
pub struct c_utmp {
|
||||
pub ut_user: [libc::c_char, ..UT_NAMESIZE],
|
||||
pub ut_id: [libc::c_char, ..UT_IDSIZE],
|
||||
pub ut_line: [libc::c_char, ..UT_LINESIZE],
|
||||
pub ut_user: [libc::c_char; UT_NAMESIZE],
|
||||
pub ut_id: [libc::c_char; UT_IDSIZE],
|
||||
pub ut_line: [libc::c_char; UT_LINESIZE],
|
||||
pub ut_pid: libc::pid_t,
|
||||
pub ut_type: libc::c_short,
|
||||
pub ut_tv: libc::timeval,
|
||||
pub ut_host: [libc::c_char, ..UT_HOSTSIZE],
|
||||
pub __unused: [libc::c_char, ..16]
|
||||
pub ut_host: [libc::c_char; UT_HOSTSIZE],
|
||||
pub __unused: [libc::c_char; 16]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -116,11 +116,11 @@ mod utmpx {
|
|||
pub struct c_utmp {
|
||||
pub ut_type : libc::c_short,
|
||||
pub ut_tv : libc::timeval,
|
||||
pub ut_id : [libc::c_char, ..UT_IDSIZE],
|
||||
pub ut_id : [libc::c_char; UT_IDSIZE],
|
||||
pub ut_pid : libc::pid_t,
|
||||
pub ut_user : [libc::c_char, ..UT_NAMESIZE],
|
||||
pub ut_line : [libc::c_char, ..UT_LINESIZE],
|
||||
pub ut_host : [libc::c_char, ..UT_HOSTSIZE],
|
||||
pub ut_spare : [libc::c_char, ..64],
|
||||
pub ut_user : [libc::c_char; UT_NAMESIZE],
|
||||
pub ut_line : [libc::c_char; UT_LINESIZE],
|
||||
pub ut_host : [libc::c_char; UT_HOSTSIZE],
|
||||
pub ut_spare : [libc::c_char; 64],
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::io::{IoResult, IoError};
|
|||
|
||||
pub struct BufReader<R> {
|
||||
reader: R,
|
||||
buffer: [u8, ..4096],
|
||||
buffer: [u8; 4096],
|
||||
start: uint,
|
||||
end: uint, // exclusive
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ pub mod Bytes {
|
|||
impl<R: Reader> BufReader<R> {
|
||||
pub fn new(reader: R) -> BufReader<R> {
|
||||
let empty_buffer = unsafe {
|
||||
std::mem::uninitialized::<[u8, ..4096]>()
|
||||
std::mem::uninitialized::<[u8; 4096]>()
|
||||
};
|
||||
|
||||
BufReader {
|
||||
|
|
|
@ -274,7 +274,7 @@ fn digest_reader(digest: &mut Box<Digest>, reader: &mut Reader, binary: bool) ->
|
|||
|
||||
// Digest file, do not hold too much in memory at any given moment
|
||||
let windows = cfg!(windows);
|
||||
let mut buffer = [0, ..524288];
|
||||
let mut buffer = [0; 524288];
|
||||
let mut vec = Vec::with_capacity(524288);
|
||||
let mut looking_for_newline = false;
|
||||
loop {
|
||||
|
|
|
@ -37,7 +37,7 @@ struct Settings {
|
|||
body_numbering: NumberingStyle,
|
||||
footer_numbering: NumberingStyle,
|
||||
// The variable corresponding to -d
|
||||
section_delimiter: [char, ..2],
|
||||
section_delimiter: [char; 2],
|
||||
// The variables corresponding to the options -v, -i, -l, -w.
|
||||
starting_line_number: u64,
|
||||
line_increment: u64,
|
||||
|
|
|
@ -23,7 +23,7 @@ static VERSION: &'static str = "1.0.0";
|
|||
static NAME: &'static str = "sum";
|
||||
|
||||
fn bsd_sum(mut reader: Box<Reader>) -> (uint, u16) {
|
||||
let mut buf = [0, .. 1024];
|
||||
let mut buf = [0; 1024];
|
||||
let mut blocks_read = 0;
|
||||
let mut checksum: u16 = 0;
|
||||
loop {
|
||||
|
@ -43,7 +43,7 @@ fn bsd_sum(mut reader: Box<Reader>) -> (uint, u16) {
|
|||
}
|
||||
|
||||
fn sysv_sum(mut reader: Box<Reader>) -> (uint, u16) {
|
||||
let mut buf = [0, .. 512];
|
||||
let mut buf = [0; 512];
|
||||
let mut blocks_read = 0;
|
||||
let mut ret = 0;
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ mod platform {
|
|||
|
||||
#[allow(unused_unsafe)]
|
||||
unsafe fn find_first_volume() -> (String, *const libc::c_void) {
|
||||
let mut name: [libc::c_char, ..260] = mem::uninitialized(); // MAX_PATH
|
||||
let mut name: [libc::c_char; 260] = mem::uninitialized(); // MAX_PATH
|
||||
match FindFirstVolumeA(name.as_mut_ptr(),
|
||||
name.len() as libc::uint32_t) {
|
||||
_x if _x == -1 as *const libc::c_void => { // INVALID_HANDLE_VALUE
|
||||
|
@ -104,7 +104,7 @@ mod platform {
|
|||
(first_volume, next_volume_handle) => {
|
||||
let mut volumes = Vec::from_elem(1, first_volume);
|
||||
loop {
|
||||
let mut name: [libc::c_char, ..260] = mem::uninitialized(); // MAX_PATH
|
||||
let mut name: [libc::c_char; 260] = mem::uninitialized(); // MAX_PATH
|
||||
match FindNextVolumeA(next_volume_handle,
|
||||
name.as_mut_ptr(),
|
||||
name.len() as libc::uint32_t) {
|
||||
|
|
|
@ -88,7 +88,7 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
}
|
||||
|
||||
fn print_loadavg() {
|
||||
let mut avg: [c_double, ..3] = [0.0, ..3];
|
||||
let mut avg: [c_double; 3] = [0.0; 3];
|
||||
let loads: i32 = unsafe { transmute(getloadavg(avg.as_mut_ptr(), 3)) };
|
||||
|
||||
if loads == -1 {
|
||||
|
|
|
@ -52,7 +52,7 @@ mod platform {
|
|||
|
||||
#[allow(unused_unsafe)]
|
||||
pub unsafe fn getusername() -> String {
|
||||
let mut buffer: [libc::c_char, ..2048] = mem::uninitialized(); // XXX: it may be possible that this isn't long enough. I don't know
|
||||
let mut buffer: [libc::c_char; 2048] = mem::uninitialized(); // XXX: it may be possible that this isn't long enough. I don't know
|
||||
if !GetUserNameA(buffer.as_mut_ptr(), &mut (buffer.len() as libc::uint32_t)) == 0 {
|
||||
crash!(1, "username is too long");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue