Skip to content

Commit a5e6f8f

Browse files
HeatherHeather
Heather
authored and
Heather
committed
Merge pull request #691 from steveklabnik/stable
Stable
2 parents b18a212 + 0c117eb commit a5e6f8f

File tree

6 files changed

+9
-19
lines changed

6 files changed

+9
-19
lines changed

src/expand/expand.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
#![crate_name = "expand"]
2-
#![feature(unicode)]
3-
42
/*
53
* This file is part of the uutils coreutils package.
64
*
@@ -14,14 +12,12 @@
1412

1513
extern crate getopts;
1614
extern crate libc;
17-
extern crate rustc_unicode;
1815
extern crate unicode_width;
1916

2017
use std::fs::File;
2118
use std::io::{stdin, stdout, BufRead, BufReader, BufWriter, Read, Write};
2219
use std::iter::repeat;
2320
use std::str::from_utf8;
24-
use rustc_unicode::str::utf8_char_width;
2521
use unicode_width::UnicodeWidthChar;
2622

2723
#[path = "../common/util.rs"]
@@ -177,7 +173,7 @@ fn expand(options: Options) {
177173

178174
while byte < buf.len() {
179175
let (ctype, cwidth, nbytes) = if options.uflag {
180-
let nbytes = utf8_char_width(buf[byte]);
176+
let nbytes = UnicodeWidthChar::width(buf[byte] as char).unwrap_or(0);
181177

182178
if byte + nbytes > buf.len() {
183179
// don't overrun buffer because of invalid UTF-8

src/fmt/parasplit.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ use std::iter::Peekable;
1111
use std::io::{BufRead, Lines};
1212
use std::slice::Iter;
1313
use std::str::CharRange;
14-
use rustc_unicode::str::UnicodeStr;
1514
use unicode_width::UnicodeWidthChar;
1615
use FileOrStdReader;
1716
use FmtOptions;
@@ -157,7 +156,7 @@ impl<'a> Iterator for FileLines<'a> {
157156
// emit a blank line
158157
// Err(true) indicates that this was a linebreak,
159158
// which is important to know when detecting mail headers
160-
if n.is_whitespace() {
159+
if n.chars().all(|c| c.is_whitespace()) {
161160
return Some(Line::NoFormatLine("\n".to_string(), true));
162161
}
163162

@@ -166,7 +165,7 @@ impl<'a> Iterator for FileLines<'a> {
166165
let (pmatch, poffset) = self.match_prefix(&n[..]);
167166
if !pmatch {
168167
return Some(Line::NoFormatLine(n, false));
169-
} else if n[poffset + self.opts.prefix.len()..].is_whitespace() {
168+
} else if n[poffset + self.opts.prefix.len()..].chars().all(|c| c.is_whitespace()) {
170169
// if the line matches the prefix, but is blank after,
171170
// don't allow lines to be combined through it (that is,
172171
// treat it like a blank line, except that since it's

src/fold/fold.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ fn fold_file<T: Read>(mut file: BufReader<T>, bytes: bool, spaces: bool, width:
156156
let ncount = routput.chars().fold(0, |out, ch: char| {
157157
out + match ch {
158158
'\t' => 8,
159-
'\x08' => if out > 0 { -1 } else { 0 },
159+
'\x08' => if out > 0 { !0 } else { 0 },
160160
'\r' => return 0,
161161
_ => 1
162162
}

src/stdbuf/stdbuf.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,11 +227,11 @@ pub fn uumain(args: Vec<String>) -> i32 {
227227
opts.optflag("", "version", "output version information and exit");
228228

229229
let mut options = ProgramOptions {stdin: BufferType::Default, stdout: BufferType::Default, stderr: BufferType::Default};
230-
let mut command_idx = -1;
230+
let mut command_idx: i32 = -1;
231231
for i in 1 .. args.len()+1 {
232232
match parse_options(&args[1 .. i], &mut options, &opts) {
233233
Ok(OkMsg::Buffering) => {
234-
command_idx = i - 1;
234+
command_idx = (i as i32) - 1;
235235
break;
236236
},
237237
Ok(OkMsg::Help) => {
@@ -249,10 +249,10 @@ pub fn uumain(args: Vec<String>) -> i32 {
249249
if command_idx == -1 {
250250
crash!(125, "Invalid options\nTry 'stdbuf --help' for more information.");
251251
}
252-
let ref command_name = args[command_idx];
252+
let ref command_name = args[command_idx as usize];
253253
let mut command = Command::new(command_name);
254254
let (preload_env, libstdbuf) = get_preload_env();
255-
command.args(&args[command_idx + 1 ..]).env(preload_env, libstdbuf);
255+
command.args(&args[(command_idx as usize) + 1 ..]).env(preload_env, libstdbuf);
256256
set_command_env(&mut command, "_STDBUF_I", options.stdin);
257257
set_command_env(&mut command, "_STDBUF_O", options.stdout);
258258
set_command_env(&mut command, "_STDBUF_E", options.stderr);

src/tr/tr.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#![crate_name = "tr"]
22
#![feature(io)]
3-
43
/*
54
* This file is part of the uutils coreutils package.
65
*

src/unexpand/unexpand.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
#![crate_name = "unexpand"]
2-
#![feature(unicode)]
3-
42
/*
53
* This file is part of the uutils coreutils package.
64
*
@@ -14,13 +12,11 @@
1412

1513
extern crate getopts;
1614
extern crate libc;
17-
extern crate rustc_unicode;
1815
extern crate unicode_width;
1916

2017
use std::fs::File;
2118
use std::io::{stdin, stdout, BufRead, BufReader, BufWriter, Read, Stdout, Write};
2219
use std::str::from_utf8;
23-
use rustc_unicode::str::utf8_char_width;
2420
use unicode_width::UnicodeWidthChar;
2521

2622
#[path = "../common/util.rs"]
@@ -210,7 +206,7 @@ fn unexpand(options: Options) {
210206
}
211207

212208
let (ctype, cwidth, nbytes) = if options.uflag {
213-
let nbytes = utf8_char_width(buf[byte]);
209+
let nbytes = UnicodeWidthChar::width(buf[byte] as char).unwrap_or(0);
214210

215211
// figure out how big the next char is, if it's UTF-8
216212
if byte + nbytes > buf.len() {

0 commit comments

Comments
 (0)