<commit_before>extern crate goblin;
extern crate colored;
extern crate structopt;
#[macro_use]
extern crate structopt_derive;
extern crate rustc_demangle;

use goblin::{error, Hint, pe, elf, mach, archive, container};
use std::path::Path;
use std::fs::File;
use std::io::Read;

use colored::Colorize;
use structopt::StructOpt;

#[derive(StructOpt, Debug, Clone)]
#[structopt(name = "bingrep", about = "bingrep - grepping through binaries since 2017")]
struct Opt {
    /// A flag, true if used in the command line.
    #[structopt(short = "d", long = "debug", help = "Print debug version of parse results")]
    debug: bool,

    /// A flag, true if used in the command line.
    #[structopt(short = "D", long = "demangle-rust", help = "Apply Rust demangling")]
    demangle: bool,

    /// Needed parameter, the first on the command line.
    #[structopt(help = "Binary file")]
    input: String,
}

fn hdr(name: &str) -> colored::ColoredString {
    format!("{}", name).dimmed().white().underline()
}

fn hdr_size (name: &str, size: usize) -> colored::ColoredString {
    format!("{}({})", name, size).dimmed().white().underline()
}

fn fmt_header (fmt: &mut ::std::fmt::Formatter, name: &str, size: usize) -> ::std::fmt::Result {
    writeln!(fmt, "{}:\n", hdr_size(name, size))?;
    Ok(())
}

fn addr (addr: u64) -> colored::ColoredString {
    format!("{:x}",addr).red()
}

fn addrx (addr: u64) -> colored::ColoredString {
    format!("{:#x}",addr).red()
}

fn off (off: u64) -> colored::ColoredString {
    format!("{:#x}",off).yellow()
}<commit_msg>Demangling also applies for C++<commit_after>extern crate goblin;
extern crate colored;
extern crate structopt;
#[macro_use]
extern crate structopt_derive;
extern crate rustc_demangle;

use goblin::{error, Hint, pe, elf, mach, archive, container};
use std::path::Path;
use std::fs::File;
use std::io::Read;

use colored::Colorize;
use structopt::StructOpt;

#[derive(StructOpt, Debug, Clone)]
#[structopt(name = "bingrep", about = "bingrep - grepping through binaries since 2017")]
struct Opt {
    /// A flag, true if used in the command line.
    #[structopt(short = "d", long = "debug", help = "Print debug version of parse results")]
    debug: bool,

    /// A flag, true if used in the command line.
    #[structopt(short = "D", long = "demangle", help = "Apply Rust/C++ demangling")]
    demangle: bool,

    /// Needed parameter, the first on the command line.
    #[structopt(help = "Binary file")]
    input: String,
}

fn hdr(name: &str) -> colored::ColoredString {
    format!("{}", name).dimmed().white().underline()
}

fn hdr_size (name: &str, size: usize) -> colored::ColoredString {
    format!("{}({})", name, size).dimmed().white().underline()
}

fn fmt_header (fmt: &mut ::std::fmt::Formatter, name: &str, size: usize) -> ::std::fmt::Result {
    writeln!(fmt, "{}:\n", hdr_size(name, size))?;
    Ok(())
}

fn addr (addr: u64) -> colored::ColoredString {
    format!("{:x}",addr).red()
}

fn addrx (addr: u64) -> colored::ColoredString {
    format!("{:#x}",addr).red()
}

fn off (off: u64) -> colored::ColoredString {
    format!("{:#x}",off).yellow()
}
{'fraction_non_alphanumeric': 0.1916320664324497, 'fraction_numerical': 0.0063877355477483235, 'mean_word_length': 4.3907056798623065, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4766784', 'n_tokens_mistral': 1085, 'n_tokens_neox': 1072, 'n_words': 306}