Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/cat/cat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,11 +452,11 @@ fn write_nonprint_to_end<W: Write>(in_buf: &[u8], writer: &mut W, tab: &[u8]) ->
}
match byte {
9 => writer.write_all(tab),
0...8 | 10...31 => writer.write_all(&[b'^', byte + 64]),
32...126 => writer.write_all(&[byte]),
0..=8 | 10..=31 => writer.write_all(&[b'^', byte + 64]),
32..=126 => writer.write_all(&[byte]),
127 => writer.write_all(&[b'^', byte - 64]),
128...159 => writer.write_all(&[b'M', b'-', b'^', byte - 64]),
160...254 => writer.write_all(&[b'M', b'-', byte - 128]),
128..=159 => writer.write_all(&[b'M', b'-', b'^', byte - 64]),
160..=254 => writer.write_all(&[b'M', b'-', byte - 128]),
_ => writer.write_all(&[b'M', b'-', b'^', 63]),
}.unwrap();
count += 1;
Expand Down
2 changes: 1 addition & 1 deletion src/chmod/chmod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ fn sanitize_input(args: &mut Vec<String>) -> Option<String> {
}
if let Some(second) = args[i].chars().nth(1) {
match second {
'r' | 'w' | 'x' | 'X' | 's' | 't' | 'u' | 'g' | 'o' | '0'...'7' => {
'r' | 'w' | 'x' | 'X' | 's' | 't' | 'u' | 'g' | 'o' | '0'..='7' => {
return Some(args.remove(i));
}
_ => {}
Expand Down
2 changes: 1 addition & 1 deletion src/cksum/cksum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ fn init_byte_array() -> Vec<u8> {

#[cfg(not(windows))]
fn init_byte_array() -> [u8; 1024 * 1024] {
unsafe { mem::uninitialized() }
unsafe { mem::MaybeUninit::uninit().assume_init() }
}

#[inline]
Expand Down
8 changes: 4 additions & 4 deletions src/id/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ macro_rules! cstr2cow {

#[cfg(not(target_os = "linux"))]
mod audit {
pub use std::mem::uninitialized;
use super::libc::{c_int, c_uint, dev_t, pid_t, uid_t, uint64_t};
pub use std::mem::MaybeUninit;
use super::libc::{c_int, c_uint, dev_t, pid_t, uid_t};

pub type au_id_t = uid_t;
pub type au_asid_t = pid_t;
Expand All @@ -58,7 +58,7 @@ mod audit {
pub ai_mask: au_mask_t, // Audit masks.
pub ai_termid: au_tid_addr_t, // Terminal ID.
pub ai_asid: au_asid_t, // Audit session ID.
pub ai_flags: uint64_t, // Audit session flags
pub ai_flags: u64, // Audit session flags
}
pub type c_auditinfo_addr_t = c_auditinfo_addr;

Expand Down Expand Up @@ -278,7 +278,7 @@ fn auditid() {}

#[cfg(not(target_os = "linux"))]
fn auditid() {
let mut auditinfo: audit::c_auditinfo_addr_t = unsafe { audit::uninitialized() };
let mut auditinfo: audit::c_auditinfo_addr_t = unsafe { audit::MaybeUninit::uninit().assume_init() };
let address = &mut auditinfo as *mut audit::c_auditinfo_addr_t;
if unsafe { audit::getaudit(address) } < 0 {
println!("couldn't retrieve information");
Expand Down
6 changes: 3 additions & 3 deletions src/mktemp/mktemp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,9 @@ pub fn dry_exec(mut tmpdir: PathBuf, prefix: &str, rand: usize, suffix: &str) ->
rand::thread_rng().fill(bytes);
for byte in bytes.iter_mut() {
*byte = match *byte % 62 {
v @ 0...9 => (v + '0' as u8),
v @ 10...35 => (v - 10 + 'a' as u8),
v @ 36...61 => (v - 36 + 'A' as u8),
v @ 0..=9 => (v + '0' as u8),
v @ 10..=35 => (v - 10 + 'a' as u8),
v @ 36..=61 => (v - 36 + 'A' as u8),
_ => unreachable!(),
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/numfmt/numfmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ fn parse_suffix(s: String) -> Result<(f64, Option<Suffix>)> {
Some('E') => Ok(Some((RawSuffix::E, with_i))),
Some('Z') => Ok(Some((RawSuffix::Z, with_i))),
Some('Y') => Ok(Some((RawSuffix::Y, with_i))),
Some('0'...'9') => Ok(None),
Some('0'..='9') => Ok(None),
_ => Err("Failed to parse suffix"),
}?;

Expand Down
14 changes: 7 additions & 7 deletions src/printf/tokenize/num_format/formatters/base_conv/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,13 +298,13 @@ impl RadixDef for RadixTen {
}
fn from_char(&self, c: char) -> Option<u8> {
match c {
'0'...'9' => Some(c as u8 - ZERO_ASC),
'0'..='9' => Some(c as u8 - ZERO_ASC),
_ => None,
}
}
fn from_u8(&self, u: u8) -> Option<char> {
match u {
0...9 => Some((ZERO_ASC + u) as char),
0..=9 => Some((ZERO_ASC + u) as char),
_ => None,
}
}
Expand All @@ -316,16 +316,16 @@ impl RadixDef for RadixHex {
}
fn from_char(&self, c: char) -> Option<u8> {
match c {
'0'...'9' => Some(c as u8 - ZERO_ASC),
'A'...'F' => Some(c as u8 + 10 - UPPER_A_ASC),
'a'...'f' => Some(c as u8 + 10 - LOWER_A_ASC),
'0'..='9' => Some(c as u8 - ZERO_ASC),
'A'..='F' => Some(c as u8 + 10 - UPPER_A_ASC),
'a'..='f' => Some(c as u8 + 10 - LOWER_A_ASC),
_ => None,
}
}
fn from_u8(&self, u: u8) -> Option<char> {
match u {
0...9 => Some((ZERO_ASC + u) as char),
10...15 => Some((UPPER_A_ASC + (u - 10)) as char),
0..=9 => Some((ZERO_ASC + u) as char),
10..=15 => Some((UPPER_A_ASC + (u - 10)) as char),
_ => None,
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/printf/tokenize/num_format/formatters/float_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ impl FloatAnalysis {
let mut pos_before_first_nonzero_after_decimal: Option<usize> = None;
while let Some(c) = str_it.next() {
match c {
e @ '0'...'9' | e @ 'A'...'F' | e @ 'a'...'f' => {
e @ '0'..='9' | e @ 'A'..='F' | e @ 'a'..='f' => {
if !hex_input {
match e {
'0'...'9' => {}
'0'..='9' => {}
_ => {
warn_incomplete_conv(str_in);
break;
Expand Down Expand Up @@ -188,7 +188,7 @@ fn round_terminal_digit(
.expect("");
}
match digit_at_pos {
'5'...'9' => {
'5'..='9' => {
let (new_after_dec, finished_in_dec) = _round_str_from(&after_dec, position);
if finished_in_dec {
return (before_dec, new_after_dec);
Expand Down
4 changes: 2 additions & 2 deletions src/printf/tokenize/num_format/formatters/intf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl Intf {
let c_opt = str_it.next();
if let Some(c) = c_opt {
match c {
'0'...'9' | 'a'...'f' | 'A'...'F' => {
'0'..='9' | 'a'..='f' | 'A'..='F' => {
if ret.len_digits == 0 && c == '0' {
ret.is_zero = true;
} else if ret.is_zero {
Expand All @@ -76,7 +76,7 @@ impl Intf {
if ret.len_digits == max_sd_in {
if let Some(next_ch) = str_it.next() {
match next_ch {
'0'...'9' => {
'0'..='9' => {
ret.past_max = true;
}
_ => {
Expand Down
2 changes: 1 addition & 1 deletion src/printf/tokenize/num_format/num_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ fn get_inprefix(str_in: &String, field_type: &FieldType) -> InPrefix {
ret.radix_in = Base::Hex;
do_clean_lead_zeroes = true;
}
e @ '0'...'9' => {
e @ '0'..='9' => {
ret.offset += 1;
match *field_type {
FieldType::Intf => {
Expand Down
2 changes: 1 addition & 1 deletion src/printf/tokenize/sub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ impl SubParser {
while let Some(ch) = it.next() {
self.text_so_far.push(ch);
match ch as char {
'-' | '*' | '0'...'9' => {
'-' | '*' | '0'..='9' => {
if !self.past_decimal {
if self.min_width_is_asterisk || self.specifiers_found {
err_conv(&self.text_so_far);
Expand Down
4 changes: 2 additions & 2 deletions src/printf/tokenize/unescaped_text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,14 @@ impl UnescapedText {
None => '\\',
};
match ch {
'0'...'9' | 'x' => {
'0'..='9' | 'x' => {
let min_len = 1;
let mut max_len = 2;
let mut base = 16;
let ignore = false;
match ch {
'x' => {}
e @ '0'...'9' => {
e @ '0'..='9' => {
max_len = 3;
base = 8;
// in practice, gnu coreutils printf
Expand Down
2 changes: 1 addition & 1 deletion src/split/split.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ impl ByteSplitter {
let mut strategy_param: Vec<char> = settings.strategy_param.chars().collect();
let suffix = strategy_param.pop().unwrap();
let multiplier = match suffix {
'0'...'9' => 1usize,
'0'..='9' => 1usize,
'b' => 512usize,
'k' => 1024usize,
'm' => 1024usize * 1024usize,
Expand Down
6 changes: 3 additions & 3 deletions src/stat/stat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,12 @@ impl ScanUtil for str {
let mut chars = self.chars();
let mut i = 0;
match chars.next() {
Some('-') | Some('+') | Some('0'...'9') => i += 1,
Some('-') | Some('+') | Some('0'..='9') => i += 1,
_ => return None,
}
while let Some(c) = chars.next() {
match c {
'0'...'9' => i += 1,
'0'..='9' => i += 1,
_ => break,
}
}
Expand Down Expand Up @@ -422,7 +422,7 @@ impl Stater {
tokens.push(Token::Char('x'));
}
}
'0'...'7' => {
'0'..='7' => {
let (c, offset) = fmtstr[i..].scan_char(8).unwrap();
tokens.push(Token::Char(c));
i += offset - 1;
Expand Down
4 changes: 2 additions & 2 deletions src/uniq/uniq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ impl Uniq {
// fast path: avoid skipping
if self.ignore_case && slice_start == 0 && slice_stop == len {
return closure(&mut fields_to_check.chars().map(|c| match c {
'a'...'z' => ((c as u8) - 32) as char,
'a'..='z' => ((c as u8) - 32) as char,
_ => c,
}));
}
Expand All @@ -142,7 +142,7 @@ impl Uniq {
.skip(slice_start)
.take(slice_stop)
.map(|c| match c {
'a'...'z' => ((c as u8) - 32) as char,
'a'..='z' => ((c as u8) - 32) as char,
_ => c,
}),
)
Expand Down
4 changes: 2 additions & 2 deletions src/unlink/unlink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ use getopts::Options;
use libc::{S_IFLNK, S_IFMT, S_IFREG};
use libc::{lstat, stat, unlink};
use std::io::{Error, ErrorKind};
use std::mem::uninitialized;
use std::ffi::CString;
use std::mem;

static NAME: &str = "unlink";
static VERSION: &str = env!("CARGO_PKG_VERSION");
Expand Down Expand Up @@ -71,7 +71,7 @@ pub fn uumain(args: Vec<String>) -> i32 {
let c_string = CString::new(matches.free[0].clone()).unwrap(); // unwrap() cannot fail, the string comes from argv so it cannot contain a \0.

let st_mode = {
let mut buf: stat = unsafe { uninitialized() };
let mut buf: stat = unsafe { mem::MaybeUninit::uninit().assume_init() };
let result = unsafe {
lstat(
c_string.as_ptr(),
Expand Down