1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-30 04:27:45 +00:00

Merge pull request #338 from ebfe/fix-build-master

Fix build with rust master
This commit is contained in:
Arcterus 2014-07-02 22:43:43 -07:00
commit c9146852cc
3 changed files with 12 additions and 10 deletions

View file

@ -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 { let (max_digits, is_legal_digit) = match base {
8u => (3, isodigit), 8u => (3, isodigit),
16u => (2, isxdigit), 16u => (2, isxdigit),
@ -201,7 +201,7 @@ pub fn uumain(args: Vec<String>) -> int {
't' => print!("\t"), 't' => print!("\t"),
'v' => print!("\x0B"), 'v' => print!("\x0B"),
'x' => { '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 { if num_char_used == 0 {
print!("\\x"); print!("\\x");
} else { } else {
@ -212,7 +212,7 @@ pub fn uumain(args: Vec<String>) -> int {
} }
}, },
'0' => { '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 { if num_char_used == 0 {
print!("\0"); print!("\0");
} else { } 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 { if num_char_used == 0 {
print!("\\{}", c); print!("\\{}", c);
} else { } else {

View file

@ -17,6 +17,7 @@ use std::io::{stdin};
use std::io::BufferedReader; use std::io::BufferedReader;
use std::io::fs::File; use std::io::fs::File;
use std::path::Path; use std::path::Path;
use std::str::from_utf8;
use getopts::{optopt, optflag, getopts, usage}; use getopts::{optopt, optflag, getopts, usage};
static PROGRAM: &'static str = "head"; static PROGRAM: &'static str = "head";
@ -104,18 +105,18 @@ fn obsolete (options: &[String]) -> (Vec<String>, Option<uint>) {
while a < b { while a < b {
let current = options.get(a).clone(); let current = options.get(a).clone();
let current = current.as_slice(); let current = current.as_bytes();
if current.len() > 1 && current[0] == '-' as u8 { if current.len() > 1 && current[0] == '-' as u8 {
let len = current.len(); let len = current.len();
for pos in range(1, len) { for pos in range(1, len) {
// Ensure that the argument is only made out of digits // 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 this is the last number
if pos == len - 1 { if pos == len - 1 {
options.remove(a); 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())); return (options, Some(number.unwrap()));
} }
} }

View file

@ -16,6 +16,7 @@ use std::io::{stdin};
use std::io::BufferedReader; use std::io::BufferedReader;
use std::io::fs::File; use std::io::fs::File;
use std::path::Path; use std::path::Path;
use std::str::from_utf8;
use getopts::{optopt, optflag, getopts, usage}; use getopts::{optopt, optflag, getopts, usage};
use std::collections::Deque; use std::collections::Deque;
use std::collections::ringbuf::RingBuf; use std::collections::ringbuf::RingBuf;
@ -123,18 +124,18 @@ fn obsolete (options: &[String]) -> (Vec<String>, Option<uint>) {
while a < b { while a < b {
let current = options.get(a).clone(); let current = options.get(a).clone();
let current = current.as_slice(); let current = current.as_bytes();
if current.len() > 1 && current[0] == '-' as u8 { if current.len() > 1 && current[0] == '-' as u8 {
let len = current.len(); let len = current.len();
for pos in range(1, len) { for pos in range(1, len) {
// Ensure that the argument is only made out of digits // 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 this is the last number
if pos == len - 1 { if pos == len - 1 {
options.remove(a); 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())); return (options, Some(number.unwrap()));
} }
} }