mirror of
https://github.com/uutils/coreutils
synced 2024-12-15 15:52:42 +00:00
Fix nightly build
This commit is contained in:
parent
545549f5ab
commit
d167674ba7
2 changed files with 10 additions and 2 deletions
|
@ -1,4 +1,6 @@
|
||||||
#![crate_name = "expand"]
|
#![crate_name = "expand"]
|
||||||
|
#![feature(unicode)]
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This file is part of the uutils coreutils package.
|
* This file is part of the uutils coreutils package.
|
||||||
*
|
*
|
||||||
|
@ -12,12 +14,14 @@
|
||||||
|
|
||||||
extern crate getopts;
|
extern crate getopts;
|
||||||
extern crate libc;
|
extern crate libc;
|
||||||
|
extern crate rustc_unicode;
|
||||||
extern crate unicode_width;
|
extern crate unicode_width;
|
||||||
|
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::{stdin, stdout, BufRead, BufReader, BufWriter, Read, Write};
|
use std::io::{stdin, stdout, BufRead, BufReader, BufWriter, Read, Write};
|
||||||
use std::iter::repeat;
|
use std::iter::repeat;
|
||||||
use std::str::from_utf8;
|
use std::str::from_utf8;
|
||||||
|
use rustc_unicode::str::utf8_char_width;
|
||||||
use unicode_width::UnicodeWidthChar;
|
use unicode_width::UnicodeWidthChar;
|
||||||
|
|
||||||
#[path = "../common/util.rs"]
|
#[path = "../common/util.rs"]
|
||||||
|
@ -173,7 +177,7 @@ fn expand(options: Options) {
|
||||||
|
|
||||||
while byte < buf.len() {
|
while byte < buf.len() {
|
||||||
let (ctype, cwidth, nbytes) = if options.uflag {
|
let (ctype, cwidth, nbytes) = if options.uflag {
|
||||||
let nbytes = UnicodeWidthChar::width(buf[byte] as char).unwrap_or(0);
|
let nbytes = utf8_char_width(buf[byte]);
|
||||||
|
|
||||||
if byte + nbytes > buf.len() {
|
if byte + nbytes > buf.len() {
|
||||||
// don't overrun buffer because of invalid UTF-8
|
// don't overrun buffer because of invalid UTF-8
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
#![crate_name = "unexpand"]
|
#![crate_name = "unexpand"]
|
||||||
|
#![feature(unicode)]
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This file is part of the uutils coreutils package.
|
* This file is part of the uutils coreutils package.
|
||||||
*
|
*
|
||||||
|
@ -12,11 +14,13 @@
|
||||||
|
|
||||||
extern crate getopts;
|
extern crate getopts;
|
||||||
extern crate libc;
|
extern crate libc;
|
||||||
|
extern crate rustc_unicode;
|
||||||
extern crate unicode_width;
|
extern crate unicode_width;
|
||||||
|
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::{stdin, stdout, BufRead, BufReader, BufWriter, Read, Stdout, Write};
|
use std::io::{stdin, stdout, BufRead, BufReader, BufWriter, Read, Stdout, Write};
|
||||||
use std::str::from_utf8;
|
use std::str::from_utf8;
|
||||||
|
use rustc_unicode::str::utf8_char_width;
|
||||||
use unicode_width::UnicodeWidthChar;
|
use unicode_width::UnicodeWidthChar;
|
||||||
|
|
||||||
#[path = "../common/util.rs"]
|
#[path = "../common/util.rs"]
|
||||||
|
@ -206,7 +210,7 @@ fn unexpand(options: Options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
let (ctype, cwidth, nbytes) = if options.uflag {
|
let (ctype, cwidth, nbytes) = if options.uflag {
|
||||||
let nbytes = UnicodeWidthChar::width(buf[byte] as char).unwrap_or(0);
|
let nbytes = utf8_char_width(buf[byte]);
|
||||||
|
|
||||||
// figure out how big the next char is, if it's UTF-8
|
// figure out how big the next char is, if it's UTF-8
|
||||||
if byte + nbytes > buf.len() {
|
if byte + nbytes > buf.len() {
|
||||||
|
|
Loading…
Reference in a new issue