diff options
| -rw-r--r-- | Cargo.lock | 17 | ||||
| -rw-r--r-- | Cargo.toml | 3 | ||||
| -rw-r--r-- | src/vtcol.rs | 43 | 
3 files changed, 33 insertions, 30 deletions
| @@ -1,4 +1,21 @@  [root]  name = "vtcol"  version = "0.42.1" +dependencies = [ + "getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)", +] +[[package]] +name = "getopts" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "libc" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[metadata] +"checksum getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "d9047cfbd08a437050b363d35ef160452c5fe8ea5187ae0a624708c91581d685" +"checksum libc 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)" = "9e030dc72013ed68994d1b2cbf36a94dd0e58418ba949c4b0db7eeb70a7a6352" @@ -17,3 +17,6 @@ name        = "vtcol"  test        = false  doc         = false +[dependencies] +libc = "0.2" +getopts = "0.2" diff --git a/src/vtcol.rs b/src/vtcol.rs index e4f0b06..a82e5bb 100644 --- a/src/vtcol.rs +++ b/src/vtcol.rs @@ -1,24 +1,7 @@ -#![feature(libc)] -#![feature(rustc_private)] -#![feature(convert)] - -/* Core appears to require some extra handholding … - */ -#![feature(core)] -#![feature(core_slice_ext)] -#![feature(core_str_ext)] -  extern crate libc;  extern crate getopts;  extern crate core; -use std::io::BufRead; - -/* Various traits. - */ -use core::slice::SliceExt; -use core::str::StrExt; -  type Fd = libc::c_int;  static mut VERBOSITY : u8 = 0_u8; @@ -156,16 +139,16 @@ impl<'a> Job {      {          let argv : Vec<String> = std::env::args().collect();          let this = argv[0].clone(); -        let opts = &[ -            getopts::optopt("s", "scheme", "predefined color scheme", "NAME"), -            getopts::optopt("d", "dump", "dump predefined scheme", "NAME"), -            getopts::optopt("f", "file", "apply scheme from file", "PATH"), -            getopts::optflag("v", "verbose", "enable verbose messages"), -            getopts::optflag("l", "list", "list available color schemes"), -            getopts::optflag("h", "help", "print this message") -        ]; - -        let matches = match getopts::getopts(argv.tail(), opts) +        let mut opts = getopts::Options::new(); + +        opts.optopt("s", "scheme", "predefined color scheme", "NAME"); +        opts.optopt("d", "dump", "dump predefined scheme", "NAME"); +        opts.optopt("f", "file", "apply scheme from file", "PATH"); +        opts.optflag("v", "verbose", "enable verbose messages"); +        opts.optflag("l", "list", "list available color schemes"); +        opts.optflag("h", "help", "print this message"); + +        let matches = match opts.parse(&argv[1..])          {              Ok(m) => m,              Err(f) => panic!(f.to_string()) @@ -252,10 +235,10 @@ impl<'a> Job {      }      fn -    usage (this : &String, opts: &[getopts::OptGroup]) +    usage (this : &String, opts: getopts::Options)      {          let brief = format!("usage: {} [options]", this); -        print!("{}", getopts::usage(brief.as_str(), opts)); +        print!("{}", opts.usage(&brief));      }      fn @@ -469,7 +452,7 @@ impl Palette {                      if off > len - 6_usize { /* no room left for color definition after '#' char */                          panic!("invalid color definition: {}", line);                      } -                    let col = line.slice_chars(off, off + RAW_COLEXPR_SIZE); +                    let col = &line[off..(off + RAW_COLEXPR_SIZE)];                      let (r, g, b) = rgb_of_hex_triplet(col);                      pal[pal_idx + 0_usize] = r; | 
