Skip to content

Commit 94b9e53

Browse files
Palmer Cox“Palmer
authored andcommitted
---
yaml --- r: 90599 b: refs/heads/master c: efd6194 h: refs/heads/master i: 90597: 982e0e0 90595: 3634960 90591: c0bc89a v: v3
1 parent 2ec5a11 commit 94b9e53

File tree

5 files changed

+58
-43
lines changed

5 files changed

+58
-43
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 35fc0c8fe4210517508d624695e81c47bda00602
2+
refs/heads/master: efd619467df28b48b97250b2857b18a032b5dab6
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: a6d3e57dca68fde4effdda3e4ae2887aa535fcd6
55
refs/heads/try: b160761e35efcd1207112b3b782c06633cf441a8

trunk/src/etc/ctags.rust

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
--regex-Rust=/^[ \t]*(pub[ \t]+)?fn[ \t]+([a-zA-Z0-9_]+)/\2/f,functions,function definitions/
44
--regex-Rust=/^[ \t]*(pub[ \t]+)?type[ \t]+([a-zA-Z0-9_]+)/\2/T,types,type definitions/
55
--regex-Rust=/^[ \t]*(pub[ \t]+)?enum[ \t]+([a-zA-Z0-9_]+)/\2/g,enum,enumeration names/
6+
--regex-Rust=/^[ \t]*(pub[ \t]+)?enum[ \t]+([a-zA-Z0-9_]+)/\2/g,enum,enumeration names/
67
--regex-Rust=/^[ \t]*(pub[ \t]+)?struct[ \t]+([a-zA-Z0-9_]+)/\2/s,structure names/
78
--regex-Rust=/^[ \t]*(pub[ \t]+)?mod[ \t]+([a-zA-Z0-9_]+)/\2/m,modules,module names/
89
--regex-Rust=/^[ \t]*(pub[ \t]+)?static[ \t]+([a-zA-Z0-9_]+)/\2/c,consts,static constants/
910
--regex-Rust=/^[ \t]*(pub[ \t]+)?trait[ \t]+([a-zA-Z0-9_]+)/\2/t,traits,traits/
1011
--regex-Rust=/^[ \t]*(pub[ \t]+)?impl([ \t\n]+<.*>)?[ \t]+([a-zA-Z0-9_]+)/\3/i,impls,trait implementations/
11-
--regex-Rust=/^[ \t]*macro_rules![ \t]+([a-zA-Z0-9_]+)/\1/d,macros,macro definitions/
12+
--regex-Rust=/^[ \t]*macro_rules![ \t]+([a-zA-Z0-9_]+)/\2/d,macros,macro definitions/

trunk/src/libextra/term.rs

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515

1616
use std::io::{Decorator, Writer};
1717

18-
use std::os;
19-
use terminfo::*;
20-
use terminfo::searcher::open;
21-
use terminfo::parser::compiled::{parse, msys_terminfo};
22-
use terminfo::parm::{expand, Number, Variables};
18+
#[cfg(not(target_os = "win32"))] use std::os;
19+
#[cfg(not(target_os = "win32"))] use terminfo::*;
20+
#[cfg(not(target_os = "win32"))] use terminfo::searcher::open;
21+
#[cfg(not(target_os = "win32"))] use terminfo::parser::compiled::parse;
22+
#[cfg(not(target_os = "win32"))] use terminfo::parm::{expand, Number, Variables};
2323

2424
// FIXME (#2807): Windows support.
2525

@@ -74,6 +74,7 @@ pub mod attr {
7474
}
7575
}
7676

77+
#[cfg(not(target_os = "win32"))]
7778
fn cap_for_attr(attr: attr::Attr) -> &'static str {
7879
match attr {
7980
attr::Bold => "bold",
@@ -92,24 +93,29 @@ fn cap_for_attr(attr: attr::Attr) -> &'static str {
9293
}
9394
}
9495

96+
#[cfg(not(target_os = "win32"))]
9597
pub struct Terminal<T> {
9698
priv num_colors: u16,
9799
priv out: T,
98100
priv ti: ~TermInfo
99101
}
100102

103+
#[cfg(target_os = "win32")]
104+
pub struct Terminal<T> {
105+
priv num_colors: u16,
106+
priv out: T,
107+
}
108+
109+
#[cfg(not(target_os = "win32"))]
101110
impl<T: Writer> Terminal<T> {
102111
pub fn new(out: T) -> Result<Terminal<T>, ~str> {
103-
let term = match os::getenv("TERM") {
104-
Some(t) => t,
105-
None => return Err(~"TERM environment variable undefined")
106-
};
112+
let term = os::getenv("TERM");
113+
if term.is_none() {
114+
return Err(~"TERM environment variable undefined");
115+
}
107116

108-
let entry = open(term);
117+
let entry = open(term.unwrap());
109118
if entry.is_err() {
110-
if "cygwin" == term { // msys terminal
111-
return Ok(Terminal {out: out, ti: msys_terminfo(), num_colors: 8});
112-
}
113119
return Err(entry.unwrap_err());
114120
}
115121

@@ -235,6 +241,32 @@ impl<T: Writer> Terminal<T> {
235241
}
236242
}
237243

244+
#[cfg(target_os = "win32")]
245+
impl<T: Writer> Terminal<T> {
246+
pub fn new(out: T) -> Result<Terminal<T>, ~str> {
247+
return Ok(Terminal {out: out, num_colors: 0});
248+
}
249+
250+
pub fn fg(&mut self, _color: color::Color) -> bool {
251+
false
252+
}
253+
254+
pub fn bg(&mut self, _color: color::Color) -> bool {
255+
false
256+
}
257+
258+
pub fn attr(&mut self, _attr: attr::Attr) -> bool {
259+
false
260+
}
261+
262+
pub fn supports_attr(&self, _attr: attr::Attr) -> bool {
263+
false
264+
}
265+
266+
pub fn reset(&self) {
267+
}
268+
}
269+
238270
impl<T: Writer> Decorator<T> for Terminal<T> {
239271
fn inner(self) -> T {
240272
self.out

trunk/src/libextra/terminfo/parser/compiled.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -316,21 +316,6 @@ pub fn parse(file: &mut io::Reader,
316316
Ok(~TermInfo {names: term_names, bools: bools_map, numbers: numbers_map, strings: string_map })
317317
}
318318

319-
/// Create a dummy TermInfo struct for msys terminals
320-
pub fn msys_terminfo() -> ~TermInfo {
321-
let mut strings = HashMap::new();
322-
strings.insert(~"sgr0", bytes!("\x1b[0m").to_owned());
323-
strings.insert(~"bold", bytes!("\x1b[1m;").to_owned());
324-
strings.insert(~"setaf", bytes!("\x1b[3%p1%dm").to_owned());
325-
strings.insert(~"setab", bytes!("\x1b[4%p1%dm").to_owned());
326-
~TermInfo {
327-
names: ~[~"cygwin"], // msys is a fork of an older cygwin version
328-
bools: HashMap::new(),
329-
numbers: HashMap::new(),
330-
strings: strings
331-
}
332-
}
333-
334319
#[cfg(test)]
335320
mod test {
336321
use super::*;

trunk/src/libstd/vec.rs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2127,8 +2127,7 @@ impl<'a,T> MutableVector<'a, T> for &'a mut [T] {
21272127
#[inline]
21282128
fn mut_chunks(self, chunk_size: uint) -> MutChunkIter<'a, T> {
21292129
assert!(chunk_size > 0);
2130-
let len = self.len();
2131-
MutChunkIter { v: self, chunk_size: chunk_size, remaining: len }
2130+
MutChunkIter { v: self, chunk_size: chunk_size }
21322131
}
21332132

21342133
fn mut_shift_ref(&mut self) -> &'a mut T {
@@ -2568,31 +2567,29 @@ impl<'a, T> DoubleEndedIterator<&'a mut [T]> for MutSplitIterator<'a, T> {
25682567
/// the remainder.
25692568
pub struct MutChunkIter<'a, T> {
25702569
priv v: &'a mut [T],
2571-
priv chunk_size: uint,
2572-
priv remaining: uint
2570+
priv chunk_size: uint
25732571
}
25742572

25752573
impl<'a, T> Iterator<&'a mut [T]> for MutChunkIter<'a, T> {
25762574
#[inline]
25772575
fn next(&mut self) -> Option<&'a mut [T]> {
2578-
if self.remaining == 0 {
2576+
if self.v.len() == 0 {
25792577
None
25802578
} else {
2581-
let sz = cmp::min(self.remaining, self.chunk_size);
2579+
let sz = cmp::min(self.v.len(), self.chunk_size);
25822580
let tmp = util::replace(&mut self.v, &mut []);
25832581
let (head, tail) = tmp.mut_split_at(sz);
25842582
self.v = tail;
2585-
self.remaining -= sz;
25862583
Some(head)
25872584
}
25882585
}
25892586

25902587
#[inline]
25912588
fn size_hint(&self) -> (uint, Option<uint>) {
2592-
if self.remaining == 0 {
2589+
if self.v.len() == 0 {
25932590
(0, Some(0))
25942591
} else {
2595-
let (n, rem) = self.remaining.div_rem(&self.chunk_size);
2592+
let (n, rem) = self.v.len().div_rem(&self.chunk_size);
25962593
let n = if rem > 0 { n + 1 } else { n };
25972594
(n, Some(n))
25982595
}
@@ -2602,15 +2599,15 @@ impl<'a, T> Iterator<&'a mut [T]> for MutChunkIter<'a, T> {
26022599
impl<'a, T> DoubleEndedIterator<&'a mut [T]> for MutChunkIter<'a, T> {
26032600
#[inline]
26042601
fn next_back(&mut self) -> Option<&'a mut [T]> {
2605-
if self.remaining == 0 {
2602+
if self.v.len() == 0 {
26062603
None
26072604
} else {
2608-
let remainder = self.remaining % self.chunk_size;
2605+
let remainder = self.v.len() % self.chunk_size;
26092606
let sz = if remainder != 0 { remainder } else { self.chunk_size };
26102607
let tmp = util::replace(&mut self.v, &mut []);
2611-
let (head, tail) = tmp.mut_split_at(self.remaining - sz);
2608+
let tmp_len = tmp.len();
2609+
let (head, tail) = tmp.mut_split_at(tmp_len - sz);
26122610
self.v = head;
2613-
self.remaining -= sz;
26142611
Some(tail)
26152612
}
26162613
}

0 commit comments

Comments
 (0)