Skip to content

Commit

Permalink
Merge pull request uutils#356 from kwantam/master
Browse files Browse the repository at this point in the history
fmt: switch to char.width() method
  • Loading branch information
cnd committed Jul 14, 2014
2 parents 0259777 + 5d94f2a commit babd511
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 197 deletions.
192 changes: 0 additions & 192 deletions fmt/charwidth.rs

This file was deleted.

1 change: 0 additions & 1 deletion fmt/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ macro_rules! silent_unwrap(
mod util;
mod linebreak;
mod parasplit;
mod charwidth;

// program's NAME and VERSION are used for -V and -h
static NAME: &'static str = "fmt";
Expand Down
7 changes: 3 additions & 4 deletions fmt/parasplit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use std::slice::Items;
use std::str::CharRange;
use FileOrStdReader;
use FmtOptions;
use charwidth;

#[inline(always)]
fn char_width(c: char) -> uint {
Expand All @@ -25,7 +24,7 @@ fn char_width(c: char) -> uint {
// otherwise, get the unicode width
// note that we shouldn't actually get None here because only c < 0xA0
// can return None, but for safety and future-proofing we do it this way
charwidth::width(c, false).unwrap_or(1)
c.width(false).unwrap_or(1)
}
}

Expand All @@ -39,7 +38,7 @@ enum Line {

impl Line {
// when we know that it's a FormatLine, as in the ParagraphStream iterator
fn get_fileline(self) -> FileLine {
fn get_formatline(self) -> FileLine {
match self {
FormatLine(fl) => fl,
NoFormatLine(..) => fail!("Found NoFormatLine when expecting FormatLine")
Expand Down Expand Up @@ -367,7 +366,7 @@ impl<'a> Iterator<Result<Paragraph, String>> for ParagraphStream<'a> {
}
}

pLines.push(self.lines.next().unwrap().get_fileline().line);
pLines.push(self.lines.next().unwrap().get_formatline().line);

// when we're in split-only mode, we never join lines, so stop here
if self.opts.split_only {
Expand Down

0 comments on commit babd511

Please sign in to comment.