<commit_before>#![deny(unused_must_use)]
#![feature(slicing_syntax, rustc_private, collections, io, os, core, std_misc, path)]

#[macro_use] extern crate log;


extern crate "rustc-serialize" as rustc_serialize;

extern crate hyper;
extern crate irc;
extern crate rand;
extern crate time;
extern crate toml;
extern crate url;

use std::old_path::Path;
use std::old_io::fs::File;
use std::os::args_as_bytes;

use botcore::{BotConfig, BotConnection};

mod botcore;
mod plugins;
mod command_mapper;


fn parse_appconfig() -> Option<BotConfig> {
    let filename = Path::new(match args_as_bytes().as_slice() {
        [] => panic!("impossible"),
        [_] => return None,
        [_, ref filename] => filename.clone(),
        [_, ref filename, ..] => filename.clone()
    });
    let mut file = match File::open(&filename) {
        Ok(file) => file,
        Err(err) => panic!("{}", err)
    };
    let contents = match file.read_to_string() {
        Ok(contents) => contents,
        Err(err) => panic!("{}", err)
    };
    let mut parser = toml::Parser::new(contents.as_slice());<commit_msg>Try std::io in ircbot.rs<commit_after>#![deny(unused_must_use)]
#![feature(collections, core, env, fs, io, rustc_private, std_misc)]

#[macro_use] extern crate log;


extern crate "rustc-serialize" as rustc_serialize;

extern crate hyper;
extern crate irc;
extern crate rand;
extern crate time;
extern crate toml;
extern crate url;

use std::io::Read;
use std::fs::File;
use std::env::args_os;

use botcore::{BotConfig, BotConnection};

mod botcore;
mod plugins;
mod command_mapper;


fn parse_appconfig() -> Option<BotConfig> {
    let args = args_os().collect::<Vec<_>>();

    let filename = match args.as_slice() {
        [] => unreachable!(),
        [_] => return None,
        [_, ref filename] => filename,
        [_, ref filename, ..] => filename,
    };

    let mut buf = String::new();
    let read_result = File::open(filename)
        .and_then(|mut f| f.read_to_string(&mut buf));
    
    if let Err(err) = read_result {
        panic!("Error reading file {:?}: {}", filename, err);
    }

    let mut parser = toml::Parser::new(buf.as_slice());
{'fraction_non_alphanumeric': 0.1607970342910102, 'fraction_numerical': 0.0, 'mean_word_length': 3.7977777777777777, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 21, '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': '1145385', 'n_tokens_mistral': 734, 'n_tokens_neox': 715, 'n_words': 185}