Switch from term to termcolor.
See https://rustsec.org/advisories/RUSTSEC-2018-0015
This commit is contained in:
81
Cargo.lock
generated
81
Cargo.lock
generated
@@ -117,12 +117,6 @@ dependencies = [
|
|||||||
"derive_arbitrary",
|
"derive_arbitrary",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "arrayref"
|
|
||||||
version = "0.3.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "arrayvec"
|
name = "arrayvec"
|
||||||
version = "0.5.2"
|
version = "0.5.2"
|
||||||
@@ -238,17 +232,6 @@ dependencies = [
|
|||||||
"wyz",
|
"wyz",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "blake2b_simd"
|
|
||||||
version = "0.5.11"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "afa748e348ad3be8263be728124b24a24f268266f6f5d58af9d75f6a40b5c587"
|
|
||||||
dependencies = [
|
|
||||||
"arrayref",
|
|
||||||
"arrayvec",
|
|
||||||
"constant_time_eq",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "block-buffer"
|
name = "block-buffer"
|
||||||
version = "0.9.0"
|
version = "0.9.0"
|
||||||
@@ -492,12 +475,6 @@ version = "0.4.5"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "28b9d6de7f49e22cf97ad17fc4036ece69300032f45f78f30b4a4482cdc3f4a6"
|
checksum = "28b9d6de7f49e22cf97ad17fc4036ece69300032f45f78f30b4a4482cdc3f4a6"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "constant_time_eq"
|
|
||||||
version = "0.1.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cpp_demangle"
|
name = "cpp_demangle"
|
||||||
version = "0.3.2"
|
version = "0.3.2"
|
||||||
@@ -739,7 +716,7 @@ dependencies = [
|
|||||||
"rayon",
|
"rayon",
|
||||||
"structopt",
|
"structopt",
|
||||||
"target-lexicon",
|
"target-lexicon",
|
||||||
"term",
|
"termcolor",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"walkdir",
|
"walkdir",
|
||||||
"wat",
|
"wat",
|
||||||
@@ -937,16 +914,6 @@ dependencies = [
|
|||||||
"dirs-sys-next",
|
"dirs-sys-next",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "dirs"
|
|
||||||
version = "2.0.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "13aea89a5c93364a98e9b37b2fa237effbb694d5cfe01c5b70941f7eb087d5e3"
|
|
||||||
dependencies = [
|
|
||||||
"cfg-if 0.1.10",
|
|
||||||
"dirs-sys",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dirs-next"
|
name = "dirs-next"
|
||||||
version = "2.0.0"
|
version = "2.0.0"
|
||||||
@@ -957,17 +924,6 @@ dependencies = [
|
|||||||
"dirs-sys-next",
|
"dirs-sys-next",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "dirs-sys"
|
|
||||||
version = "0.3.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "8e93d7f5705de3e49895a2b5e0b8855a1c27f080192ae9c32a6432d50741a57a"
|
|
||||||
dependencies = [
|
|
||||||
"libc",
|
|
||||||
"redox_users 0.3.5",
|
|
||||||
"winapi",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dirs-sys-next"
|
name = "dirs-sys-next"
|
||||||
version = "0.1.2"
|
version = "0.1.2"
|
||||||
@@ -975,7 +931,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d"
|
checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"redox_users 0.4.0",
|
"redox_users",
|
||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -2285,17 +2241,6 @@ dependencies = [
|
|||||||
"bitflags",
|
"bitflags",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "redox_users"
|
|
||||||
version = "0.3.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "de0737333e7a9502c789a36d7c7fa6092a49895d4faa31ca5df163857ded2e9d"
|
|
||||||
dependencies = [
|
|
||||||
"getrandom 0.1.16",
|
|
||||||
"redox_syscall 0.1.57",
|
|
||||||
"rust-argon2",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "redox_users"
|
name = "redox_users"
|
||||||
version = "0.4.0"
|
version = "0.4.0"
|
||||||
@@ -2409,18 +2354,6 @@ dependencies = [
|
|||||||
"cc",
|
"cc",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rust-argon2"
|
|
||||||
version = "0.8.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "4b18820d944b33caa75a71378964ac46f58517c92b6ae5f762636247c09e78fb"
|
|
||||||
dependencies = [
|
|
||||||
"base64",
|
|
||||||
"blake2b_simd",
|
|
||||||
"constant_time_eq",
|
|
||||||
"crossbeam-utils",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustc-demangle"
|
name = "rustc-demangle"
|
||||||
version = "0.1.18"
|
version = "0.1.18"
|
||||||
@@ -2767,16 +2700,6 @@ dependencies = [
|
|||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "term"
|
|
||||||
version = "0.6.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "c0863a3345e70f61d613eab32ee046ccd1bcc5f9105fe402c61fcd0c13eeb8b5"
|
|
||||||
dependencies = [
|
|
||||||
"dirs",
|
|
||||||
"winapi",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "termcolor"
|
name = "termcolor"
|
||||||
version = "1.1.2"
|
version = "1.1.2"
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ cranelift-preopt = { path = "preopt", version = "0.69.0" }
|
|||||||
cranelift = { path = "umbrella", version = "0.69.0" }
|
cranelift = { path = "umbrella", version = "0.69.0" }
|
||||||
filecheck = "0.5.0"
|
filecheck = "0.5.0"
|
||||||
log = "0.4.8"
|
log = "0.4.8"
|
||||||
term = "0.6.1"
|
termcolor = "1.1.2"
|
||||||
capstone = { version = "0.7.0", optional = true }
|
capstone = { version = "0.7.0", optional = true }
|
||||||
wat = { version = "1.0.18", optional = true }
|
wat = { version = "1.0.18", optional = true }
|
||||||
target-lexicon = { version = "0.11", features = ["std"] }
|
target-lexicon = { version = "0.11", features = ["std"] }
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ use std::io::Read;
|
|||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use structopt::StructOpt;
|
use structopt::StructOpt;
|
||||||
use term;
|
use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor};
|
||||||
|
|
||||||
/// For verbose printing: only print if the `$x` expression is true.
|
/// For verbose printing: only print if the `$x` expression is true.
|
||||||
macro_rules! vprintln {
|
macro_rules! vprintln {
|
||||||
@@ -36,11 +36,11 @@ macro_rules! vcprintln {
|
|||||||
($x: expr, $use_color: expr, $term: ident, $color: expr, $($tts:tt)*) => {
|
($x: expr, $use_color: expr, $term: ident, $color: expr, $($tts:tt)*) => {
|
||||||
if $x {
|
if $x {
|
||||||
if $use_color {
|
if $use_color {
|
||||||
let _ = $term.fg($color);
|
$term.set_color(ColorSpec::new().set_fg(Some($color)))?;
|
||||||
}
|
}
|
||||||
println!($($tts)*);
|
println!($($tts)*);
|
||||||
if $use_color {
|
if $use_color {
|
||||||
let _ = $term.reset();
|
$term.reset()?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -50,11 +50,11 @@ macro_rules! vcprint {
|
|||||||
($x: expr, $use_color: expr, $term: ident, $color: expr, $($tts:tt)*) => {
|
($x: expr, $use_color: expr, $term: ident, $color: expr, $($tts:tt)*) => {
|
||||||
if $x {
|
if $x {
|
||||||
if $use_color {
|
if $use_color {
|
||||||
let _ = $term.fg($color);
|
$term.set_color(ColorSpec::new().set_fg(Some($color)))?;
|
||||||
}
|
}
|
||||||
print!($($tts)*);
|
print!($($tts)*);
|
||||||
if $use_color {
|
if $use_color {
|
||||||
let _ = $term.reset();
|
$term.reset()?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -113,25 +113,25 @@ pub struct Options {
|
|||||||
|
|
||||||
/// Use colors in output? [options: auto/never/always; default: auto]
|
/// Use colors in output? [options: auto/never/always; default: auto]
|
||||||
#[structopt(long("color"), default_value("auto"))]
|
#[structopt(long("color"), default_value("auto"))]
|
||||||
color: Color,
|
color: ColorOpt,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq, Eq)]
|
#[derive(PartialEq, Eq)]
|
||||||
enum Color {
|
enum ColorOpt {
|
||||||
Auto,
|
Auto,
|
||||||
Never,
|
Never,
|
||||||
Always,
|
Always,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::str::FromStr for Color {
|
impl std::str::FromStr for ColorOpt {
|
||||||
type Err = String;
|
type Err = String;
|
||||||
|
|
||||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||||
let s = s.to_lowercase();
|
let s = s.to_lowercase();
|
||||||
match s.as_str() {
|
match s.as_str() {
|
||||||
"auto" => Ok(Color::Auto),
|
"auto" => Ok(ColorOpt::Auto),
|
||||||
"never" => Ok(Color::Never),
|
"never" => Ok(ColorOpt::Never),
|
||||||
"always" => Ok(Color::Always),
|
"always" => Ok(ColorOpt::Always),
|
||||||
_ => Err(format!("expected auto/never/always, found: {}", s)),
|
_ => Err(format!("expected auto/never/always, found: {}", s)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -149,14 +149,19 @@ pub fn run(options: &Options) -> Result<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn handle_module(options: &Options, path: &Path, name: &str, fisa: FlagsOrIsa) -> Result<()> {
|
fn handle_module(options: &Options, path: &Path, name: &str, fisa: FlagsOrIsa) -> Result<()> {
|
||||||
let mut terminal = term::stdout().unwrap();
|
let color_choice = match options.color {
|
||||||
let use_color =
|
ColorOpt::Auto => ColorChoice::Auto,
|
||||||
terminal.supports_color() && options.color == Color::Auto || options.color == Color::Always;
|
ColorOpt::Always => ColorChoice::Always,
|
||||||
|
ColorOpt::Never => ColorChoice::Never,
|
||||||
|
};
|
||||||
|
let mut terminal = StandardStream::stdout(color_choice);
|
||||||
|
let use_color = terminal.supports_color() && options.color == ColorOpt::Auto
|
||||||
|
|| options.color == ColorOpt::Always;
|
||||||
vcprint!(
|
vcprint!(
|
||||||
options.verbose,
|
options.verbose,
|
||||||
use_color,
|
use_color,
|
||||||
terminal,
|
terminal,
|
||||||
term::color::YELLOW,
|
Color::Yellow,
|
||||||
"Handling: "
|
"Handling: "
|
||||||
);
|
);
|
||||||
vprintln!(options.verbose, "\"{}\"", name);
|
vprintln!(options.verbose, "\"{}\"", name);
|
||||||
@@ -164,7 +169,7 @@ fn handle_module(options: &Options, path: &Path, name: &str, fisa: FlagsOrIsa) -
|
|||||||
options.verbose,
|
options.verbose,
|
||||||
use_color,
|
use_color,
|
||||||
terminal,
|
terminal,
|
||||||
term::color::MAGENTA,
|
Color::Magenta,
|
||||||
"Translating... "
|
"Translating... "
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -192,13 +197,7 @@ fn handle_module(options: &Options, path: &Path, name: &str, fisa: FlagsOrIsa) -
|
|||||||
DummyEnvironment::new(isa.frontend_config(), ReturnMode::NormalReturns, debug_info);
|
DummyEnvironment::new(isa.frontend_config(), ReturnMode::NormalReturns, debug_info);
|
||||||
translate_module(&module_binary, &mut dummy_environ)?;
|
translate_module(&module_binary, &mut dummy_environ)?;
|
||||||
|
|
||||||
vcprintln!(
|
vcprintln!(options.verbose, use_color, terminal, Color::Green, "ok");
|
||||||
options.verbose,
|
|
||||||
use_color,
|
|
||||||
terminal,
|
|
||||||
term::color::GREEN,
|
|
||||||
"ok"
|
|
||||||
);
|
|
||||||
|
|
||||||
if options.just_decode {
|
if options.just_decode {
|
||||||
if !options.print {
|
if !options.print {
|
||||||
@@ -233,7 +232,7 @@ fn handle_module(options: &Options, path: &Path, name: &str, fisa: FlagsOrIsa) -
|
|||||||
options.verbose,
|
options.verbose,
|
||||||
use_color,
|
use_color,
|
||||||
terminal,
|
terminal,
|
||||||
term::color::MAGENTA,
|
Color::Magenta,
|
||||||
"Checking... "
|
"Checking... "
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@@ -241,7 +240,7 @@ fn handle_module(options: &Options, path: &Path, name: &str, fisa: FlagsOrIsa) -
|
|||||||
options.verbose,
|
options.verbose,
|
||||||
use_color,
|
use_color,
|
||||||
terminal,
|
terminal,
|
||||||
term::color::MAGENTA,
|
Color::Magenta,
|
||||||
"Compiling... "
|
"Compiling... "
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -351,12 +350,6 @@ fn handle_module(options: &Options, path: &Path, name: &str, fisa: FlagsOrIsa) -
|
|||||||
println!("{}", timing::take_current());
|
println!("{}", timing::take_current());
|
||||||
}
|
}
|
||||||
|
|
||||||
vcprintln!(
|
vcprintln!(options.verbose, use_color, terminal, Color::Green, "ok");
|
||||||
options.verbose,
|
|
||||||
use_color,
|
|
||||||
terminal,
|
|
||||||
term::color::GREEN,
|
|
||||||
"ok"
|
|
||||||
);
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user