diff options
| author | Chris Lattner <sabre@nondot.org> | 2003-12-31 10:20:38 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2003-12-31 10:20:38 +0000 |
| commit | 78f1f51c66a815ee1affffa29f8de31e1dbb9961 (patch) | |
| tree | 7bc5b8fe92d9064795be8ff49f9961f98df4a9d2 /llvm/lib/Support | |
| parent | 09bd1a06c1390a51e9a2f34563dd0881fec4698c (diff) | |
| download | bcm5719-llvm-78f1f51c66a815ee1affffa29f8de31e1dbb9961.tar.gz bcm5719-llvm-78f1f51c66a815ee1affffa29f8de31e1dbb9961.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%
llvm-svn: 10672
Diffstat (limited to 'llvm/lib/Support')
| -rw-r--r-- | llvm/lib/Support/SlowOperationInformer.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/llvm/lib/Support/SlowOperationInformer.cpp b/llvm/lib/Support/SlowOperationInformer.cpp index 9dc2750f769..9fd718e3060 100644 --- a/llvm/lib/Support/SlowOperationInformer.cpp +++ b/llvm/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; |

