aboutsummaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorGraydon Hoare <[email protected]>2011-05-06 16:30:39 -0700
committerGraydon Hoare <[email protected]>2011-05-06 16:30:39 -0700
commit0f23bbac0104fe4c51923eb09b7a98c3e6239571 (patch)
tree0eab6391a37b71c753b5515358285163e93f76f2 /src/lib
parentPut out burning linux tinderbox. (diff)
downloadrust-0f23bbac0104fe4c51923eb09b7a98c3e6239571.tar.xz
rust-0f23bbac0104fe4c51923eb09b7a98c3e6239571.zip
Fix GenericOS.getenv returning a raw str, return an Option.t[str] instead.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/GenericOS.rs9
-rw-r--r--src/lib/Term.rs2
2 files changed, 8 insertions, 3 deletions
diff --git a/src/lib/GenericOS.rs b/src/lib/GenericOS.rs
index c60fa2b8..30b1d1d0 100644
--- a/src/lib/GenericOS.rs
+++ b/src/lib/GenericOS.rs
@@ -1,4 +1,9 @@
-fn getenv(str n) -> str {
- ret Str.str_from_cstr(OS.libc.getenv(Str.buf(n)));
+fn getenv(str n) -> Option.t[str] {
+ auto s = OS.libc.getenv(Str.buf(n));
+ if (s == 0 as Str.sbuf) {
+ ret Option.none[str];
+ } else {
+ ret Option.some[str](Str.str_from_cstr(s));
+ }
}
diff --git a/src/lib/Term.rs b/src/lib/Term.rs
index fca04bff..b07dcc0c 100644
--- a/src/lib/Term.rs
+++ b/src/lib/Term.rs
@@ -31,7 +31,7 @@ fn reset(IO.buf_writer writer) {
}
fn color_supported() -> bool {
- ret Str.eq(GenericOS.getenv("TERM"), "xterm-color");
+ ret GenericOS.getenv("TERM") == Option.some[str]("xterm-color");
}
fn set_color(IO.buf_writer writer, u8 first_char, u8 color) {