aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Support/raw_ostream.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-08-24 04:43:38 +0000
committerDan Gohman <gohman@apple.com>2009-08-24 04:43:38 +0000
commitc9fa051f850e9944a2e4e2d93ce9008acc59acc4 (patch)
tree814b7478ba838af4109f1c5e3d80ea9bf9fced1a /llvm/lib/Support/raw_ostream.cpp
parente7f064ed2b76b77a2a617bfbb3e6cdae882ca4c5 (diff)
downloadllvm-c9fa051f850e9944a2e4e2d93ce9008acc59acc4.zip
llvm-c9fa051f850e9944a2e4e2d93ce9008acc59acc4.tar.gz
llvm-c9fa051f850e9944a2e4e2d93ce9008acc59acc4.tar.bz2
Correctly account for the Spaces array nul terminator. Thanks Chris!
llvm-svn: 79894
Diffstat (limited to 'llvm/lib/Support/raw_ostream.cpp')
-rw-r--r--llvm/lib/Support/raw_ostream.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp
index 64d9205..230d9a8 100644
--- a/llvm/lib/Support/raw_ostream.cpp
+++ b/llvm/lib/Support/raw_ostream.cpp
@@ -304,11 +304,12 @@ raw_ostream &raw_ostream::indent(unsigned NumSpaces) {
" ";
// Usually the indentation is small, handle it with a fastpath.
- if (NumSpaces <= array_lengthof(Spaces))
+ if (NumSpaces < array_lengthof(Spaces))
return write(Spaces, NumSpaces);
while (NumSpaces) {
- unsigned NumToWrite = std::min(NumSpaces, (unsigned)array_lengthof(Spaces));
+ unsigned NumToWrite = std::min(NumSpaces,
+ (unsigned)array_lengthof(Spaces)-1);
write(Spaces, NumToWrite);
NumSpaces -= NumToWrite;
}