<commit_before>// These are taken from http://en.wikipedia.org/wiki/List_of_HTTP_Status_Codes.
// Last updated on 2013-07-04
// Entries from third-party vendors not standardised upon are not included.
// If not specified otherwise, they are defined in RFC 2616.

// Yes, this is ugly code.
// No, I don't mind.
// That was easy. :-)

use std::collections::hashmap::HashSet;
use std::ascii::StrAsciiExt;
use std::io::IoResult;
use super::get_writer;

enum HeadingOrStatus {
    Heading(&'static str),
    Status(Status),
}

struct Status {
    code: uint,
    reason: &'static str,
    comment: Option<&'static str>,
}

/// Status with comment
fn status_c(code: uint, reason: &'static str, comment: &'static str) -> HeadingOrStatus {
    Status(Status { code: code, reason: reason, comment: Some(comment) })
}

/// Status without comment
fn status_n(code: uint, reason: &'static str) -> HeadingOrStatus {
    Status(Status { code: code, reason: reason, comment: None })
}

impl Status {
    fn ident(&self) -> String {
        camel_case(self.reason)
    }

    fn padded_ident(&self) -> String {
        self.ident().append(self.reason_padding_spaces().as_slice())
    }

    fn reason_padding_spaces(&self) -> String {
        " ".repeat(unsafe { longest_reason } - self.reason.len())
    }
}

/// >>> camel_case("I'm a Tea-pot")
/// "ImATeaPot"
fn camel_case(msg: &str) -> String {
    let msg = msg.replace("-", " ").replace("'", "");
    let mut result = String::with_capacity(msg.len());
    let mut capitalise = true;
    for c in msg.as_slice().chars() {
        let c = match capitalise {
            true => c.to_ascii().to_uppercase().to_char(),
            false => c.to_ascii().to_lowercase().to_char(),
        };
        // For a space, capitalise the next char
        capitalise = c == ' ';
        if !capitalise {  // And also, for a space, don't keep it
            result.push_char(c);
        }
    }
    result<commit_msg>fixes #144 codegen duplicate definition of Status<commit_after>// These are taken from http://en.wikipedia.org/wiki/List_of_HTTP_Status_Codes.
// Last updated on 2013-07-04
// Entries from third-party vendors not standardised upon are not included.
// If not specified otherwise, they are defined in RFC 2616.

// Yes, this is ugly code.
// No, I don't mind.
// That was easy. :-)

use std::collections::hashmap::HashSet;
use std::ascii::StrAsciiExt;
use std::io::IoResult;
use super::get_writer;

enum HeadingOrStatus {
    Heading(&'static str),
    Status(HttpStatus),
}

struct HttpStatus {
    code: uint,
    reason: &'static str,
    comment: Option<&'static str>,
}

/// Status with comment
fn status_c(code: uint, reason: &'static str, comment: &'static str) -> HeadingOrStatus {
    Status(HttpStatus { code: code, reason: reason, comment: Some(comment) })
}

/// Status without comment
fn status_n(code: uint, reason: &'static str) -> HeadingOrStatus {
    Status(HttpStatus { code: code, reason: reason, comment: None })
}

impl HttpStatus {
    fn ident(&self) -> String {
        camel_case(self.reason)
    }

    fn padded_ident(&self) -> String {
        self.ident().append(self.reason_padding_spaces().as_slice())
    }

    fn reason_padding_spaces(&self) -> String {
        " ".repeat(unsafe { longest_reason } - self.reason.len())
    }
}

/// >>> camel_case("I'm a Tea-pot")
/// "ImATeaPot"
fn camel_case(msg: &str) -> String {
    let msg = msg.replace("-", " ").replace("'", "");
    let mut result = String::with_capacity(msg.len());
    let mut capitalise = true;
    for c in msg.as_slice().chars() {
        let c = match capitalise {
            true => c.to_ascii().to_uppercase().to_char(),
            false => c.to_ascii().to_lowercase().to_char(),
        };
        // For a space, capitalise the next char
        capitalise = c == ' ';
        if !capitalise {  // And also, for a space, don't keep it
            result.push_char(c);
        }
    }
    result
{'fraction_non_alphanumeric': 0.15136916835699799, 'fraction_numerical': 0.006845841784989858, 'mean_word_length': 2.8943731490621913, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 27, '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': '5591483', 'n_tokens_mistral': 1305, 'n_tokens_neox': 1254, 'n_words': 347}