1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-08-02 14:07:46 +00:00

refactor/splice ~ polish spelling (comments, names, and exceptions)

This commit is contained in:
Roy Ivy III 2021-05-30 00:07:01 -05:00
parent f8e04c562b
commit 00a2e17c80
4 changed files with 17 additions and 11 deletions

View file

@ -9,7 +9,7 @@ const BUF_SIZE: usize = 1024 * 16;
/// This function is called from `write_fast()` on Linux and Android. The /// This function is called from `write_fast()` on Linux and Android. The
/// function `splice()` is used to move data between two file descriptors /// function `splice()` is used to move data between two file descriptors
/// without copying between kernel- and userspace. This results in a large /// without copying between kernel and user spaces. This results in a large
/// speedup. /// speedup.
/// ///
/// The `bool` in the result value indicates if we need to fall back to normal /// The `bool` in the result value indicates if we need to fall back to normal

View file

@ -13,10 +13,10 @@ use std::{
mod csplit_error; mod csplit_error;
mod patterns; mod patterns;
mod splitname; mod split_name;
use crate::csplit_error::CsplitError; use crate::csplit_error::CsplitError;
use crate::splitname::SplitName; use crate::split_name::SplitName;
use uucore::InvalidEncodingHandling; use uucore::InvalidEncodingHandling;
static VERSION: &str = env!("CARGO_PKG_VERSION"); static VERSION: &str = env!("CARGO_PKG_VERSION");
@ -77,7 +77,7 @@ impl CsplitOptions {
/// # Errors /// # Errors
/// ///
/// - [`io::Error`] if there is some problem reading/writing from/to a file. /// - [`io::Error`] if there is some problem reading/writing from/to a file.
/// - [`::CsplitError::LineOutOfRange`] if the linenum pattern is larger than the number of input /// - [`::CsplitError::LineOutOfRange`] if the line number pattern is larger than the number of input
/// lines. /// lines.
/// - [`::CsplitError::LineOutOfRangeOnRepetition`], like previous but after applying the pattern /// - [`::CsplitError::LineOutOfRangeOnRepetition`], like previous but after applying the pattern
/// more than once. /// more than once.

View file

@ -1,3 +1,5 @@
// spell-checker:ignore (regex) SKIPTO UPTO ; (vars) ntimes
use crate::csplit_error::CsplitError; use crate::csplit_error::CsplitError;
use regex::Regex; use regex::Regex;
@ -167,7 +169,7 @@ fn validate_line_numbers(patterns: &[Pattern]) -> Result<(), CsplitError> {
.try_fold(0, |prev_ln, &current_ln| match (prev_ln, current_ln) { .try_fold(0, |prev_ln, &current_ln| match (prev_ln, current_ln) {
// a line number cannot be zero // a line number cannot be zero
(_, 0) => Err(CsplitError::LineNumberIsZero), (_, 0) => Err(CsplitError::LineNumberIsZero),
// two consecutifs numbers should not be equal // two consecutive numbers should not be equal
(n, m) if n == m => { (n, m) if n == m => {
show_warning!("line number '{}' is the same as preceding line number", n); show_warning!("line number '{}' is the same as preceding line number", n);
Ok(n) Ok(n)

View file

@ -1,3 +1,5 @@
// spell-checker:ignore (regex) diuox
use regex::Regex; use regex::Regex;
use crate::csplit_error::CsplitError; use crate::csplit_error::CsplitError;
@ -225,6 +227,8 @@ impl SplitName {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
// spell-checker:ignore (path) xxcst
use super::*; use super::*;
#[test] #[test]
@ -319,13 +323,13 @@ mod tests {
} }
#[test] #[test]
fn zero_padding_lower_hexa() { fn zero_padding_lower_hex() {
let split_name = SplitName::new(None, Some(String::from("cst-%03x-")), None).unwrap(); let split_name = SplitName::new(None, Some(String::from("cst-%03x-")), None).unwrap();
assert_eq!(split_name.get(42), "xxcst-02a-"); assert_eq!(split_name.get(42), "xxcst-02a-");
} }
#[test] #[test]
fn zero_padding_upper_hexa() { fn zero_padding_upper_hex() {
let split_name = SplitName::new(None, Some(String::from("cst-%03X-")), None).unwrap(); let split_name = SplitName::new(None, Some(String::from("cst-%03X-")), None).unwrap();
assert_eq!(split_name.get(42), "xxcst-02A-"); assert_eq!(split_name.get(42), "xxcst-02A-");
} }
@ -337,13 +341,13 @@ mod tests {
} }
#[test] #[test]
fn alternate_form_lower_hexa() { fn alternate_form_lower_hex() {
let split_name = SplitName::new(None, Some(String::from("cst-%#10x-")), None).unwrap(); let split_name = SplitName::new(None, Some(String::from("cst-%#10x-")), None).unwrap();
assert_eq!(split_name.get(42), "xxcst- 0x2a-"); assert_eq!(split_name.get(42), "xxcst- 0x2a-");
} }
#[test] #[test]
fn alternate_form_upper_hexa() { fn alternate_form_upper_hex() {
let split_name = SplitName::new(None, Some(String::from("cst-%#10X-")), None).unwrap(); let split_name = SplitName::new(None, Some(String::from("cst-%#10X-")), None).unwrap();
assert_eq!(split_name.get(42), "xxcst- 0x2A-"); assert_eq!(split_name.get(42), "xxcst- 0x2A-");
} }
@ -373,13 +377,13 @@ mod tests {
} }
#[test] #[test]
fn left_adjusted_lower_hexa() { fn left_adjusted_lower_hex() {
let split_name = SplitName::new(None, Some(String::from("cst-%-10x-")), None).unwrap(); let split_name = SplitName::new(None, Some(String::from("cst-%-10x-")), None).unwrap();
assert_eq!(split_name.get(42), "xxcst-0x2a -"); assert_eq!(split_name.get(42), "xxcst-0x2a -");
} }
#[test] #[test]
fn left_adjusted_upper_hexa() { fn left_adjusted_upper_hex() {
let split_name = SplitName::new(None, Some(String::from("cst-%-10X-")), None).unwrap(); let split_name = SplitName::new(None, Some(String::from("cst-%-10X-")), None).unwrap();
assert_eq!(split_name.get(42), "xxcst-0x2A -"); assert_eq!(split_name.get(42), "xxcst-0x2A -");
} }