mirror of
https://github.com/uutils/coreutils
synced 2024-07-21 18:04:45 +00:00
refactor/splice ~ polish spelling (comments, names, and exceptions)
This commit is contained in:
parent
f8e04c562b
commit
00a2e17c80
|
@ -9,7 +9,7 @@ const BUF_SIZE: usize = 1024 * 16;
|
|||
|
||||
/// This function is called from `write_fast()` on Linux and Android. The
|
||||
/// 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.
|
||||
///
|
||||
/// The `bool` in the result value indicates if we need to fall back to normal
|
||||
|
|
|
@ -13,10 +13,10 @@ use std::{
|
|||
|
||||
mod csplit_error;
|
||||
mod patterns;
|
||||
mod splitname;
|
||||
mod split_name;
|
||||
|
||||
use crate::csplit_error::CsplitError;
|
||||
use crate::splitname::SplitName;
|
||||
use crate::split_name::SplitName;
|
||||
use uucore::InvalidEncodingHandling;
|
||||
|
||||
static VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||
|
@ -77,7 +77,7 @@ impl CsplitOptions {
|
|||
/// # Errors
|
||||
///
|
||||
/// - [`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.
|
||||
/// - [`::CsplitError::LineOutOfRangeOnRepetition`], like previous but after applying the pattern
|
||||
/// more than once.
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
// spell-checker:ignore (regex) SKIPTO UPTO ; (vars) ntimes
|
||||
|
||||
use crate::csplit_error::CsplitError;
|
||||
use regex::Regex;
|
||||
|
||||
|
@ -167,7 +169,7 @@ fn validate_line_numbers(patterns: &[Pattern]) -> Result<(), CsplitError> {
|
|||
.try_fold(0, |prev_ln, ¤t_ln| match (prev_ln, current_ln) {
|
||||
// a line number cannot be zero
|
||||
(_, 0) => Err(CsplitError::LineNumberIsZero),
|
||||
// two consecutifs numbers should not be equal
|
||||
// two consecutive numbers should not be equal
|
||||
(n, m) if n == m => {
|
||||
show_warning!("line number '{}' is the same as preceding line number", n);
|
||||
Ok(n)
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
// spell-checker:ignore (regex) diuox
|
||||
|
||||
use regex::Regex;
|
||||
|
||||
use crate::csplit_error::CsplitError;
|
||||
|
@ -225,6 +227,8 @@ impl SplitName {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
// spell-checker:ignore (path) xxcst
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
|
@ -319,13 +323,13 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn zero_padding_lower_hexa() {
|
||||
fn zero_padding_lower_hex() {
|
||||
let split_name = SplitName::new(None, Some(String::from("cst-%03x-")), None).unwrap();
|
||||
assert_eq!(split_name.get(42), "xxcst-02a-");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn zero_padding_upper_hexa() {
|
||||
fn zero_padding_upper_hex() {
|
||||
let split_name = SplitName::new(None, Some(String::from("cst-%03X-")), None).unwrap();
|
||||
assert_eq!(split_name.get(42), "xxcst-02A-");
|
||||
}
|
||||
|
@ -337,13 +341,13 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn alternate_form_lower_hexa() {
|
||||
fn alternate_form_lower_hex() {
|
||||
let split_name = SplitName::new(None, Some(String::from("cst-%#10x-")), None).unwrap();
|
||||
assert_eq!(split_name.get(42), "xxcst- 0x2a-");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn alternate_form_upper_hexa() {
|
||||
fn alternate_form_upper_hex() {
|
||||
let split_name = SplitName::new(None, Some(String::from("cst-%#10X-")), None).unwrap();
|
||||
assert_eq!(split_name.get(42), "xxcst- 0x2A-");
|
||||
}
|
||||
|
@ -373,13 +377,13 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn left_adjusted_lower_hexa() {
|
||||
fn left_adjusted_lower_hex() {
|
||||
let split_name = SplitName::new(None, Some(String::from("cst-%-10x-")), None).unwrap();
|
||||
assert_eq!(split_name.get(42), "xxcst-0x2a -");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn left_adjusted_upper_hexa() {
|
||||
fn left_adjusted_upper_hex() {
|
||||
let split_name = SplitName::new(None, Some(String::from("cst-%-10X-")), None).unwrap();
|
||||
assert_eq!(split_name.get(42), "xxcst-0x2A -");
|
||||
}
|
Loading…
Reference in a new issue