aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Support/SlowOperationInformer.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-12-31 10:20:38 +0000
committerChris Lattner <sabre@nondot.org>2003-12-31 10:20:38 +0000
commit9e26027b82e70308151e129fdddb12ee85dd82c5 (patch)
tree0689e969602bbc9ab222b07bfbdf85e83abff464 /lib/Support/SlowOperationInformer.cpp
parent60837821e2bb179c6dd239ecb4d72df37560d3bb (diff)
downloadexternal_llvm-9e26027b82e70308151e129fdddb12ee85dd82c5.tar.gz
external_llvm-9e26027b82e70308151e129fdddb12ee85dd82c5.tar.bz2
external_llvm-9e26027b82e70308151e129fdddb12ee85dd82c5.zip
* Add a new helper progress method
* Make sure that the user sees the 100% mark * Don't bother printing out X.0%, just print out X% git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10672 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/SlowOperationInformer.cpp')
-rw-r--r--lib/Support/SlowOperationInformer.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/Support/SlowOperationInformer.cpp b/lib/Support/SlowOperationInformer.cpp
index 9dc2750f76..9fd718e306 100644
--- a/lib/Support/SlowOperationInformer.cpp
+++ b/lib/Support/SlowOperationInformer.cpp
@@ -59,8 +59,12 @@ SlowOperationInformer::SlowOperationInformer(const std::string &Name)
SlowOperationInformer::~SlowOperationInformer() {
NestedSOI = false;
- if (LastPrintAmount)
- std::cout << "\n";
+ if (LastPrintAmount) {
+ // If we have printed something, make _sure_ we print the 100% amount, and
+ // also print a newline.
+ std::cout << std::string(LastPrintAmount, '\b') << "Progress "
+ << OperationName << ": 100% \n";
+ }
alarm(0);
signal(SIGALRM, SIG_DFL);
@@ -87,8 +91,11 @@ void SlowOperationInformer::progress(unsigned Amount) {
std::string ToPrint = std::string(LastPrintAmount, '\b');
std::ostringstream OS;
- OS << "Progress " << OperationName << ": " << Amount/10 << "." << Amount % 10
- << "%";
+ OS << "Progress " << OperationName << ": " << Amount/10;
+ if (unsigned Rem = Amount % 10)
+ OS << "." << Rem << "%";
+ else
+ OS << "% ";
LastPrintAmount = OS.str().size();
std::cout << ToPrint+OS.str() << std::flush;