]> git.lizzy.rs Git - rust.git/blobdiff - src/libterm/terminfo/parser/compiled.rs
Remove two useless comparisons
[rust.git] / src / libterm / terminfo / parser / compiled.rs
index 37ef3c133a57f639d08c6e9a583e1b84492896da..db5dd2d5c1907375cc56b339837c1cbae86308db 100644 (file)
@@ -195,21 +195,21 @@ macro_rules! try( ($e:expr) => (
     assert!(names_bytes          > 0);
 
     if (bools_bytes as uint) > boolnames.len() {
-        return Err(~"incompatible file: more booleans than expected");
+        return Err("incompatible file: more booleans than expected".to_owned());
     }
 
     if (numbers_count as uint) > numnames.len() {
-        return Err(~"incompatible file: more numbers than expected");
+        return Err("incompatible file: more numbers than expected".to_owned());
     }
 
     if (string_offsets_count as uint) > stringnames.len() {
-        return Err(~"incompatible file: more string offsets than expected");
+        return Err("incompatible file: more string offsets than expected".to_owned());
     }
 
     // don't read NUL
     let bytes = try!(file.read_exact(names_bytes as uint - 1));
     let names_str = match str::from_utf8(bytes.as_slice()) {
-        Some(s) => s.to_owned(), None => return Err(~"input not utf-8"),
+        Some(s) => s.to_owned(), None => return Err("input not utf-8".to_owned()),
     };
 
     let term_names: Vec<~str> = names_str.split('|').map(|s| s.to_owned()).collect();
@@ -220,9 +220,7 @@ macro_rules! try( ($e:expr) => (
     if bools_bytes != 0 {
         for i in range(0, bools_bytes) {
             let b = try!(file.read_byte());
-            if b < 0 {
-                return Err(~"error: expected more bools but hit EOF");
-            } else if b == 1 {
+            if b == 1 {
                 bools_map.insert(bnames[i as uint].to_owned(), true);
             }
         }
@@ -253,7 +251,7 @@ macro_rules! try( ($e:expr) => (
         let string_table = try!(file.read_exact(string_table_bytes as uint));
 
         if string_table.len() != string_table_bytes as uint {
-            return Err(~"error: hit EOF before end of string table");
+            return Err("error: hit EOF before end of string table".to_owned());
         }
 
         for (i, v) in string_offsets.iter().enumerate() {
@@ -287,25 +285,30 @@ macro_rules! try( ($e:expr) => (
                                           offset as uint + len)))
                 },
                 None => {
-                    return Err(~"invalid file: missing NUL in string_table");
+                    return Err("invalid file: missing NUL in string_table".to_owned());
                 }
             };
         }
     }
 
     // And that's all there is to it
-    Ok(~TermInfo {names: term_names, bools: bools_map, numbers: numbers_map, strings: string_map })
+    Ok(box TermInfo {
+        names: term_names,
+        bools: bools_map,
+        numbers: numbers_map,
+        strings: string_map
+    })
 }
 
 /// Create a dummy TermInfo struct for msys terminals
 pub fn msys_terminfo() -> ~TermInfo {
     let mut strings = HashMap::new();
-    strings.insert(~"sgr0", Vec::from_slice(bytes!("\x1b[0m")));
-    strings.insert(~"bold", Vec::from_slice(bytes!("\x1b[1m")));
-    strings.insert(~"setaf", Vec::from_slice(bytes!("\x1b[3%p1%dm")));
-    strings.insert(~"setab", Vec::from_slice(bytes!("\x1b[4%p1%dm")));
-    ~TermInfo {
-        names: vec!(~"cygwin"), // msys is a fork of an older cygwin version
+    strings.insert("sgr0".to_owned(), Vec::from_slice(bytes!("\x1b[0m")));
+    strings.insert("bold".to_owned(), Vec::from_slice(bytes!("\x1b[1m")));
+    strings.insert("setaf".to_owned(), Vec::from_slice(bytes!("\x1b[3%p1%dm")));
+    strings.insert("setab".to_owned(), Vec::from_slice(bytes!("\x1b[4%p1%dm")));
+    box TermInfo {
+        names: vec!("cygwin".to_owned()), // msys is a fork of an older cygwin version
         bools: HashMap::new(),
         numbers: HashMap::new(),
         strings: strings