Skip to content
Merged
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
4 changes: 2 additions & 2 deletions file/dd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,15 @@ fn convert_swab(data: &mut [u8]) {
fn convert_lcase(data: &mut [u8]) {
for byte in data.iter_mut() {
if *byte >= b'A' && *byte <= b'Z' {
*byte = *byte + 32;
*byte += 32;
}
}
}

fn convert_ucase(data: &mut [u8]) {
for byte in data.iter_mut() {
if *byte >= b'a' && *byte <= b'z' {
*byte = *byte - 32;
*byte -= 32;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion file/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ impl RawMagicFileLine {
let mut tf_val = u64::from_be_bytes(array_buf);

if let Some(mask) = mask {
tf_val = mask & tf_val;
tf_val &= mask;
}

match &self.value {
Expand Down
6 changes: 3 additions & 3 deletions file/split.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ impl OutputState {
if i == 0 {
break;
}
i = i - 1;
i -= 1;
}

Err("maximum suffix reached")
Expand Down Expand Up @@ -141,7 +141,7 @@ impl OutputState {
}

fn incr_output(&mut self, n: u64) {
self.count = self.count + n;
self.count += n;
assert!(self.count <= self.boundary);

if self.count == self.boundary {
Expand Down Expand Up @@ -170,7 +170,7 @@ impl OutputState {
let slice = &buf[consumed..consumed + wlen];
self.write(slice)?;

consumed = consumed + wlen;
consumed += wlen;

self.incr_output(wlen as u64);
}
Expand Down
11 changes: 2 additions & 9 deletions misc/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,16 +182,9 @@ fn parse_binary_op(s: &str) -> Option<BinOp> {
}
}

fn parse_int(s: &str) -> i64 {
match s.parse::<i64>() {
Ok(i) => i,
Err(_) => 0,
}
}

fn eval_binary_int(op: &BinOp, s1: &str, s2: &str) -> bool {
let i1 = parse_int(s1);
let i2 = parse_int(s2);
let i1: i64 = s1.parse().unwrap_or(0);
let i2: i64 = s2.parse().unwrap_or(0);

match op {
BinOp::IntEq => i1 == i2,
Expand Down
1 change: 1 addition & 0 deletions plib/src/lzw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ impl UnixLZWReader {
}
}

#[allow(clippy::assign_op_pattern)]
fn getcode(&mut self) -> i32 {
if self.clear || self.roffset >= self.size || self.free_ent > self.maxcode {
// as free_ent represents the index of the next available entry that can be made
Expand Down
8 changes: 4 additions & 4 deletions screen/stty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ fn set_ti_flag(

// set flag bits (unless negation)
if !negate {
newflags = newflags | val_set;
newflags |= val_set;
}

// commit flag bits to termio struct, if changed
Expand Down Expand Up @@ -461,7 +461,7 @@ fn stty_set_long(mut ti: Termios, args: &Args) -> io::Result<()> {
if operand.parse::<u64>().is_ok() {
set_ti_speed(&mut ti, &speedmap, true, operand)?;
set_ti_speed(&mut ti, &speedmap, false, operand)?;
idx = idx + 1;
idx += 1;
continue;
}

Expand Down Expand Up @@ -489,7 +489,7 @@ fn stty_set_long(mut ti: Termios, args: &Args) -> io::Result<()> {

let mut op_arg = String::new();
if (flags & PARG) != 0 {
idx = idx + 1;
idx += 1;

if idx == args.operands.len() {
let errstr = format!("Missing operand for {}", operand);
Expand Down Expand Up @@ -530,7 +530,7 @@ fn stty_set_long(mut ti: Termios, args: &Args) -> io::Result<()> {
}
}

idx = idx + 1;
idx += 1;
}

// finally, commit new termio settings (if any)
Expand Down
4 changes: 2 additions & 2 deletions text/asa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ fn asa_file(pathname: &PathBuf) -> io::Result<()> {
let mut state = AsaState::new();

loop {
line_no = line_no + 1;
line_no += 1;

let mut raw_line = String::new();
let n_read = reader.read_line(&mut raw_line)?;
Expand All @@ -90,7 +90,7 @@ fn asa_file(pathname: &PathBuf) -> io::Result<()> {
// exclude first char, and trailing newline
let mut line_len = raw_line.len() - 1;
if raw_line.ends_with('\n') {
line_len = line_len - 1;
line_len -= 1;
}
let line = &raw_line[1..line_len];

Expand Down
8 changes: 4 additions & 4 deletions text/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ fn parse_tablist(tablist: &str) -> Result<TabList, &'static str> {
}

fn space_out(column: &mut usize, writer: &mut BufWriter<dyn Write>) -> io::Result<()> {
*column = *column + 1;
*column += 1;

writer.write_all(b" ")?;

Expand Down Expand Up @@ -89,14 +89,14 @@ fn expand_file(tablist: &TabList, pathname: &PathBuf) -> io::Result<()> {
// backspace
writer.write_all(&[byte])?;
if column > 1 {
column = column - 1;
column -= 1;
}
} else if byte == b'\r' || byte == b'\n' {
writer.write_all(&[byte])?;
column = 1;
} else if byte != b'\t' {
writer.write_all(&[byte])?;
column = column + 1;
column += 1;
} else {
match tablist {
TabList::UniStop(n) => {
Expand All @@ -115,7 +115,7 @@ fn expand_file(tablist: &TabList, pathname: &PathBuf) -> io::Result<()> {
while column < next_tab {
space_out(&mut column, &mut writer)?;
}
cur_stop = cur_stop + 1;
cur_stop += 1;
space_out(&mut column, &mut writer)?;
}
}
Expand Down
4 changes: 2 additions & 2 deletions text/head.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ fn head_file(args: &Args, pathname: &PathBuf, first: bool, want_header: bool) ->
for chv in buf {
// LF character encountered
if *chv == 10 {
nl = nl + 1;
nl += 1;
}

pos = pos + 1;
pos += 1;

// if user-specified limit reached, stop
if nl >= args.n {
Expand Down
12 changes: 4 additions & 8 deletions text/pr_util/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,14 +355,10 @@ impl Parameters {

let (first_page, last_page) = args.pages.unwrap_or((1, None));

let num_columns = {
if args.merge {
args.file.len()
} else if let Some(n) = args.columns {
n
} else {
1
}
let num_columns = if args.merge {
args.file.len()
} else {
args.columns.unwrap_or(1)
};

let form_feed = args.form_feed || args.form_feed_with_pause;
Expand Down
2 changes: 1 addition & 1 deletion text/wc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ fn wc_file_bytes(count: &mut CountInfo, pathname: &PathBuf, chars_mode: bool) ->

if !chars_mode {
// number of bytes read
count.chars = count.chars + n_read;
count.chars += n_read;
} else {
// number of UTF-8 unicode codepoints in this slice of bytes
count.chars += bufslice.iter().filter(|&ch| (ch >> 6) != 0b10).count();
Expand Down
1 change: 1 addition & 0 deletions users/mesg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ fn parse_setting(setting: &str) -> Result<bool, &'static str> {
}
}

#[allow(clippy::assign_op_pattern)]
fn set_mesg(fd: i32, st: libc::stat, setting: &str) -> io::Result<()> {
let res = parse_setting(setting);
if let Err(e) = res {
Expand Down
6 changes: 3 additions & 3 deletions xform/cksum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fn cksum_file(filename: &PathBuf) -> io::Result<()> {
let mut file = plib::io::input_stream(filename, false)?;

let mut buffer = [0; plib::BUFSZ];
let mut n_bytes: u64 = 0;
let mut n_bytes: usize = 0;
let mut crc: u32 = 0;

loop {
Expand All @@ -44,7 +44,7 @@ fn cksum_file(filename: &PathBuf) -> io::Result<()> {
break;
}

n_bytes = n_bytes + n_read as u64;
n_bytes += n_read;
crc = crc32::update(crc, &buffer[0..n_read]);
}

Expand All @@ -57,7 +57,7 @@ fn cksum_file(filename: &PathBuf) -> io::Result<()> {
};
println!(
"{} {}{}{}",
crc32::finalize(crc, n_bytes as usize),
crc32::finalize(crc, n_bytes),
n_bytes,
filename_prefix,
filename.display()
Expand Down
2 changes: 1 addition & 1 deletion xform/crc32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ pub fn finalize(crc_in: u32, n_in: usize) -> u32 {

while n != 0 {
let c = (n & 0o377) as u32;
n = n >> 8;
n >>= 8;
s = (s << 8) ^ CRCTAB[(((s >> 24) ^ c) & 0xff) as usize];
}

Expand Down