head: handle multibyte numeric utf-8 chars

This commit is contained in:
snobee
2022-02-03 21:42:22 +08:00
committed by Hanif Ariffin
parent 2d3b8db9ed
commit ee721ebf4e
2 changed files with 5 additions and 1 deletions
+1 -1
View File
@@ -20,7 +20,7 @@ pub fn parse_obsolete(src: &str) -> Option<Result<impl Iterator<Item = OsString>
let mut has_num = false;
let mut last_char = 0 as char;
for (n, c) in &mut chars {
if c.is_numeric() {
if c.is_digit(10) {
has_num = true;
num_end = n;
} else {
+4
View File
@@ -306,6 +306,10 @@ fn test_head_invalid_num() {
));
}
}
new_ucmd!()
.args(&["-c", ""])
.fails()
.stderr_is("head: invalid number of bytes: '³'");
}
#[test]