mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-29 12:07:46 +00:00
Merge pull request #338 from ebfe/fix-build-master
Fix build with rust master
This commit is contained in:
commit
c9146852cc
3 changed files with 12 additions and 10 deletions
|
@ -51,7 +51,7 @@ fn isodigit(c: u8) -> bool {
|
|||
}
|
||||
}
|
||||
|
||||
fn convert_str(string: &str, index: uint, base: uint) -> (char, uint) {
|
||||
fn convert_str(string: &[u8], index: uint, base: uint) -> (char, uint) {
|
||||
let (max_digits, is_legal_digit) = match base {
|
||||
8u => (3, isodigit),
|
||||
16u => (2, isxdigit),
|
||||
|
@ -201,7 +201,7 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
't' => print!("\t"),
|
||||
'v' => print!("\x0B"),
|
||||
'x' => {
|
||||
let (c, num_char_used) = convert_str(string.as_slice(), index + 1, 16u);
|
||||
let (c, num_char_used) = convert_str(string.as_bytes(), index + 1, 16u);
|
||||
if num_char_used == 0 {
|
||||
print!("\\x");
|
||||
} else {
|
||||
|
@ -212,7 +212,7 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
}
|
||||
},
|
||||
'0' => {
|
||||
let (c, num_char_used) = convert_str(string.as_slice(), index + 1, 8u);
|
||||
let (c, num_char_used) = convert_str(string.as_bytes(), index + 1, 8u);
|
||||
if num_char_used == 0 {
|
||||
print!("\0");
|
||||
} else {
|
||||
|
@ -223,7 +223,7 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
}
|
||||
}
|
||||
_ => {
|
||||
let (esc_c, num_char_used) = convert_str(string.as_slice(), index, 8u);
|
||||
let (esc_c, num_char_used) = convert_str(string.as_bytes(), index, 8u);
|
||||
if num_char_used == 0 {
|
||||
print!("\\{}", c);
|
||||
} else {
|
||||
|
|
|
@ -17,6 +17,7 @@ use std::io::{stdin};
|
|||
use std::io::BufferedReader;
|
||||
use std::io::fs::File;
|
||||
use std::path::Path;
|
||||
use std::str::from_utf8;
|
||||
use getopts::{optopt, optflag, getopts, usage};
|
||||
|
||||
static PROGRAM: &'static str = "head";
|
||||
|
@ -104,18 +105,18 @@ fn obsolete (options: &[String]) -> (Vec<String>, Option<uint>) {
|
|||
|
||||
while a < b {
|
||||
let current = options.get(a).clone();
|
||||
let current = current.as_slice();
|
||||
let current = current.as_bytes();
|
||||
|
||||
if current.len() > 1 && current[0] == '-' as u8 {
|
||||
let len = current.len();
|
||||
for pos in range(1, len) {
|
||||
// Ensure that the argument is only made out of digits
|
||||
if !char::is_digit(current.char_at(pos)) { break; }
|
||||
if !char::is_digit(current[pos] as char) { break; }
|
||||
|
||||
// If this is the last number
|
||||
if pos == len - 1 {
|
||||
options.remove(a);
|
||||
let number : Option<uint> = from_str(current.slice(1,len));
|
||||
let number : Option<uint> = from_str(from_utf8(current.slice(1,len)).unwrap());
|
||||
return (options, Some(number.unwrap()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ use std::io::{stdin};
|
|||
use std::io::BufferedReader;
|
||||
use std::io::fs::File;
|
||||
use std::path::Path;
|
||||
use std::str::from_utf8;
|
||||
use getopts::{optopt, optflag, getopts, usage};
|
||||
use std::collections::Deque;
|
||||
use std::collections::ringbuf::RingBuf;
|
||||
|
@ -123,18 +124,18 @@ fn obsolete (options: &[String]) -> (Vec<String>, Option<uint>) {
|
|||
|
||||
while a < b {
|
||||
let current = options.get(a).clone();
|
||||
let current = current.as_slice();
|
||||
let current = current.as_bytes();
|
||||
|
||||
if current.len() > 1 && current[0] == '-' as u8 {
|
||||
let len = current.len();
|
||||
for pos in range(1, len) {
|
||||
// Ensure that the argument is only made out of digits
|
||||
if !char::is_digit(current.char_at(pos)) { break; }
|
||||
if !char::is_digit(current[pos] as char) { break; }
|
||||
|
||||
// If this is the last number
|
||||
if pos == len - 1 {
|
||||
options.remove(a);
|
||||
let number : Option<uint> = from_str(current.slice(1,len));
|
||||
let number : Option<uint> = from_str(from_utf8(current.slice(1,len)).unwrap());
|
||||
return (options, Some(number.unwrap()));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue