summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvan Martin <martine@danga.com>2011-04-18 03:14:31 (GMT)
committerEvan Martin <martine@danga.com>2011-04-18 03:14:31 (GMT)
commit56fedfde5d3e4e46683238ebd3fed2598d92db7c (patch)
tree1433eb4c6799c5e70703d5ee147fc3880f6e49b2
parentfa3bf5e0d4d33e6ed3d72653fbec4d2824274335 (diff)
parentd5fdbb440ecb16d205cf7edfd33258fc5751a7b4 (diff)
downloadNinja-56fedfde5d3e4e46683238ebd3fed2598d92db7c.zip
Ninja-56fedfde5d3e4e46683238ebd3fed2598d92db7c.tar.gz
Ninja-56fedfde5d3e4e46683238ebd3fed2598d92db7c.tar.bz2
Merge branch 'term-fix' of https://github.com/SByer/ninja
-rw-r--r--src/build.cc8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/build.cc b/src/build.cc
index 09c362a..ba7f1be 100644
--- a/src/build.cc
+++ b/src/build.cc
@@ -106,12 +106,14 @@ void BuildStatus::PrintStatus(Edge* edge) {
to_print = edge->EvaluateCommand();
if (smart_terminal_) {
- // Limit output to width of the terminal so we don't cause line-wrapping.
+ // Limit output to width of the terminal if provided so we don't cause
+ // line-wrapping.
winsize size;
- if (ioctl(0, TIOCGWINSZ, &size) == 0) {
+ if ((ioctl(0, TIOCGWINSZ, &size) == 0) && size.ws_col) {
const int kMargin = 15; // Space for [xxx/yyy] and "...".
if (to_print.size() + kMargin > size.ws_col) {
- int substr = to_print.size() + kMargin - size.ws_col;
+ int substr = std::min(to_print.size(),
+ to_print.size() + kMargin - size.ws_col);
to_print = "..." + to_print.substr(substr);
}
}