summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorpierresy <pierre-henri.symoneaux@alcatel-lucent.com>2015-05-31 16:02:16 +0200
committerpierresy <pierre-henri.symoneaux@alcatel-lucent.com>2015-05-31 16:02:16 +0200
commit2c34d5004dbf9dbe45f5d1195fb384e953a97d37 (patch)
treeec456fa8a5f726ef1a83a9965beed59d75a94fa1 /src
parent187d0c875e275d507baf1d4efc09840101dfd541 (diff)
Conditional compilation : linefeed is \n on unix and mac os, but s \r\n
on windows
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 20da5d7..f167930 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -4,6 +4,11 @@ use std::fmt;
use std::str;
use std::string::ToString;
+#[cfg(any(unix, macos))]
+static LINEFEED: &'static [u8] = b"\n";
+#[cfg(windows)]
+static LINEFEED: &'static [u8] = b"\r\n";
+
/// A Struct representing a printable table
#[derive(Clone, Debug)]
pub struct Table {
@@ -118,7 +123,7 @@ impl Table {
}
try!(out.write_all(self.sep_cross.to_string().as_bytes()));
}
- return out.write_all(b"\n");
+ return out.write_all(LINEFEED);
}
fn print_line<T: Write>(&self, out: &mut T, line: &[String], col_width: &[usize]) -> Result<(), Error> {
@@ -132,7 +137,7 @@ impl Table {
}
try!(out.write_all(self.col_sep.to_string().as_bytes()));
}
- return out.write_all(b"\n");
+ return out.write_all(LINEFEED);
}
/// Print the table to `out`