mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-08-01 13:37:48 +00:00
Merge pull request #481 from skv-headless/fix_char_len_warning
fix char_len warnings
This commit is contained in:
commit
e04c09a8ba
5 changed files with 10 additions and 10 deletions
|
@ -518,7 +518,7 @@ pub fn uumain(args: Vec<String>) -> int {
|
||||||
|
|
||||||
match matches.opt_str("delimiter") {
|
match matches.opt_str("delimiter") {
|
||||||
Some(delim) => {
|
Some(delim) => {
|
||||||
if delim.as_slice().char_len() != 1 {
|
if delim.as_slice().chars().count() != 1 {
|
||||||
Err("the delimiter must be a single character".to_string())
|
Err("the delimiter must be a single character".to_string())
|
||||||
} else {
|
} else {
|
||||||
Ok(Mode::Fields(ranges,
|
Ok(Mode::Fields(ranges,
|
||||||
|
|
|
@ -136,7 +136,7 @@ fn fold_file<T: io::Reader>(file: BufferedReader<T>, bytes: bool, spaces: bool,
|
||||||
i += slice.len();
|
i += slice.len();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let mut len = line.char_len();
|
let mut len = line.chars().count();
|
||||||
let newline = line.ends_with("\n");
|
let newline = line.ends_with("\n");
|
||||||
if newline {
|
if newline {
|
||||||
if len == 1 {
|
if len == 1 {
|
||||||
|
@ -156,7 +156,7 @@ fn fold_file<T: io::Reader>(file: BufferedReader<T>, bytes: bool, spaces: bool,
|
||||||
if spaces && i + 1 < len {
|
if spaces && i + 1 < len {
|
||||||
match rfind_whitespace(slice) {
|
match rfind_whitespace(slice) {
|
||||||
Some(m) => {
|
Some(m) => {
|
||||||
let routput = slice.slice_chars(m + 1, slice.char_len());
|
let routput = slice.slice_chars(m + 1, slice.chars().count());
|
||||||
let ncount = routput.chars().fold(0u, |out, ch: char| {
|
let ncount = routput.chars().fold(0u, |out, ch: char| {
|
||||||
out + match ch {
|
out + match ch {
|
||||||
'\t' => 8,
|
'\t' => 8,
|
||||||
|
@ -219,7 +219,7 @@ fn fold_file<T: io::Reader>(file: BufferedReader<T>, bytes: bool, spaces: bool,
|
||||||
fn rfind_whitespace(slice: &str) -> Option<uint> {
|
fn rfind_whitespace(slice: &str) -> Option<uint> {
|
||||||
for (i, ch) in slice.chars().rev().enumerate() {
|
for (i, ch) in slice.chars().rev().enumerate() {
|
||||||
if ch.is_whitespace() {
|
if ch.is_whitespace() {
|
||||||
return Some(slice.char_len() - (i + 1));
|
return Some(slice.chars().count() - (i + 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None
|
None
|
||||||
|
|
|
@ -176,7 +176,7 @@ impl Splitter for ByteSplitter {
|
||||||
|
|
||||||
fn consume(&mut self, control: &mut SplitControl) -> String {
|
fn consume(&mut self, control: &mut SplitControl) -> String {
|
||||||
let line = control.current_line.clone();
|
let line = control.current_line.clone();
|
||||||
let n = std::cmp::min(line.as_slice().char_len(), self.bytes_to_write);
|
let n = std::cmp::min(line.as_slice().chars().count(), self.bytes_to_write);
|
||||||
self.bytes_to_write -= n;
|
self.bytes_to_write -= n;
|
||||||
if n == 0 {
|
if n == 0 {
|
||||||
self.bytes_to_write = self.saved_bytes_to_write;
|
self.bytes_to_write = self.saved_bytes_to_write;
|
||||||
|
@ -244,7 +244,7 @@ fn split(settings: &Settings) -> int {
|
||||||
let mut writer = io::BufferedWriter::new(box io::stdio::stdout_raw() as Box<Writer>);
|
let mut writer = io::BufferedWriter::new(box io::stdio::stdout_raw() as Box<Writer>);
|
||||||
let mut fileno = 0;
|
let mut fileno = 0;
|
||||||
loop {
|
loop {
|
||||||
if control.current_line.as_slice().char_len() == 0 {
|
if control.current_line.as_slice().chars().count() == 0 {
|
||||||
match reader.read_line() {
|
match reader.read_line() {
|
||||||
Ok(a) => { control.current_line = a; }
|
Ok(a) => { control.current_line = a; }
|
||||||
Err(_) => { break; }
|
Err(_) => { break; }
|
||||||
|
@ -270,10 +270,10 @@ fn split(settings: &Settings) -> int {
|
||||||
let consumed = splitter.consume(&mut control);
|
let consumed = splitter.consume(&mut control);
|
||||||
crash_if_err!(1, writer.write_str(consumed.as_slice()));
|
crash_if_err!(1, writer.write_str(consumed.as_slice()));
|
||||||
|
|
||||||
let advance = consumed.as_slice().char_len();
|
let advance = consumed.as_slice().chars().count();
|
||||||
let clone = control.current_line.clone();
|
let clone = control.current_line.clone();
|
||||||
let sl = clone.as_slice();
|
let sl = clone.as_slice();
|
||||||
control.current_line = sl.slice(advance, sl.char_len()).to_string();
|
control.current_line = sl.slice(advance, sl.chars().count()).to_string();
|
||||||
}
|
}
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,7 +161,7 @@ fn parse_date(str: &str) -> u64 {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_timestamp(str: &str) -> u64 {
|
fn parse_timestamp(str: &str) -> u64 {
|
||||||
let format = match str.char_len() {
|
let format = match str.chars().count() {
|
||||||
15 => "%Y%m%d%H%M.%S",
|
15 => "%Y%m%d%H%M.%S",
|
||||||
12 => "%Y%m%d%H%M",
|
12 => "%Y%m%d%H%M",
|
||||||
13 => "%y%m%d%H%M.%S",
|
13 => "%y%m%d%H%M.%S",
|
||||||
|
|
|
@ -130,7 +130,7 @@ pub fn wc(files: Vec<String>, matches: &Matches) -> StdResult<(), int> {
|
||||||
match from_utf8(raw_line.as_slice()) {
|
match from_utf8(raw_line.as_slice()) {
|
||||||
Ok(line) => {
|
Ok(line) => {
|
||||||
word_count += line.words().count();
|
word_count += line.words().count();
|
||||||
current_char_count = line.char_len();
|
current_char_count = line.chars().count();
|
||||||
char_count += current_char_count;
|
char_count += current_char_count;
|
||||||
},
|
},
|
||||||
Err(..) => {
|
Err(..) => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue