1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-30 20:47:46 +00:00

Merge pull request #704 from ebfe/fix-build

Fix nightly build
This commit is contained in:
Heather 2015-10-05 13:17:18 +03:00
commit 39f1851791
2 changed files with 10 additions and 2 deletions

View file

@ -1,4 +1,6 @@
#![crate_name = "expand"]
#![feature(unicode)]
/*
* This file is part of the uutils coreutils package.
*
@ -12,12 +14,14 @@
extern crate getopts;
extern crate libc;
extern crate rustc_unicode;
extern crate unicode_width;
use std::fs::File;
use std::io::{stdin, stdout, BufRead, BufReader, BufWriter, Read, Write};
use std::iter::repeat;
use std::str::from_utf8;
use rustc_unicode::str::utf8_char_width;
use unicode_width::UnicodeWidthChar;
#[path = "../common/util.rs"]
@ -173,7 +177,7 @@ fn expand(options: Options) {
while byte < buf.len() {
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() {
// don't overrun buffer because of invalid UTF-8

View file

@ -1,4 +1,6 @@
#![crate_name = "unexpand"]
#![feature(unicode)]
/*
* This file is part of the uutils coreutils package.
*
@ -12,11 +14,13 @@
extern crate getopts;
extern crate libc;
extern crate rustc_unicode;
extern crate unicode_width;
use std::fs::File;
use std::io::{stdin, stdout, BufRead, BufReader, BufWriter, Read, Stdout, Write};
use std::str::from_utf8;
use rustc_unicode::str::utf8_char_width;
use unicode_width::UnicodeWidthChar;
#[path = "../common/util.rs"]
@ -206,7 +210,7 @@ fn unexpand(options: Options) {
}
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
if byte + nbytes > buf.len() {