summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Gesang <phg@phi-gamma.net>2015-05-07 23:06:11 +0200
committerPhilipp Gesang <phg@phi-gamma.net>2015-05-07 23:06:11 +0200
commit0c44dad8cacc95ad6abd39fda5ab9663c3bdccce (patch)
treed5684fedb2c4e5e473c619ab1f5d46bb67241631
parente74c77937e2b834f9a065d174f2374dd40755535 (diff)
downloadvtcol-0c44dad8cacc95ad6abd39fda5ab9663c3bdccce.tar.gz
vtcol.rs: finally catch up with 1.0; lots of “feature” directives
-rw-r--r--src/vtcol.rs23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/vtcol.rs b/src/vtcol.rs
index 9a865c8..9f0779e 100644
--- a/src/vtcol.rs
+++ b/src/vtcol.rs
@@ -1,8 +1,13 @@
-#![allow(unstable)]
+#![feature(libc)]
+#![feature(rustc_private)]
+#![feature(collections)]
+#![feature(convert)]
extern crate libc;
extern crate getopts;
+use std::io::BufRead;
+
type Fd = libc::c_int;
const PALETTE_SIZE : usize = 16_usize;
@@ -397,21 +402,21 @@ impl Palette {
{
let mut pal_idx : usize = 0_usize;
let mut pal : [u8; PALETTE_BYTES] = unsafe { std::mem::zeroed() };
+ let mut line : String = String::new();
- while let Ok(line) = reader.read_line() {
- let len = line.len();
+ while let Ok(len) = reader.read_line(&mut line) {
if len < 8_usize { panic!("invalid line in string: {}", line); };
- if let Some(off) = line.find_str("#") {
+ if let Some(off) = line.find('#') {
if off != 0_usize {
/* Palette index specified, number prepended */
- let str_idx = line.slice_chars(0, off);
- let parse_res : Result<usize>
+ let str_idx = unsafe { line.slice_unchecked(0_usize, off) };
+ let parse_res : Result<usize, _>
= std::str::FromStr::from_str(str_idx);
match parse_res {
- Some(new_idx) => {
+ Ok(new_idx) => {
if new_idx < PALETTE_SIZE { pal_idx = new_idx * 3_usize; }
},
- None => ()
+ _ => ()
}
}
let off = off + 1_usize;
@@ -437,7 +442,7 @@ impl Palette {
{
/* Check if file exists
*/
- let path = std::path::Path::new(fname.as_bytes());
+ let path = std::path::Path::new(fname);
let file = match std::fs::File::open(&path)
{
Err(e) => panic!("failed to open {} as file ({})", fname, e),