1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 19:47:45 +00:00

head: handle multibyte numeric utf-8 chars

This commit is contained in:
snobee 2022-02-02 21:22:28 -08:00 committed by Hanif Ariffin
parent 2d3b8db9ed
commit ee721ebf4e
2 changed files with 5 additions and 1 deletions

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 has_num = false;
let mut last_char = 0 as char; let mut last_char = 0 as char;
for (n, c) in &mut chars { for (n, c) in &mut chars {
if c.is_numeric() { if c.is_digit(10) {
has_num = true; has_num = true;
num_end = n; num_end = n;
} else { } else {

View file

@ -306,6 +306,10 @@ fn test_head_invalid_num() {
)); ));
} }
} }
new_ucmd!()
.args(&["-c", ""])
.fails()
.stderr_is("head: invalid number of bytes: '³'");
} }
#[test] #[test]