[llvm-commits] CVS: llvm/lib/Support/SlowOperationInformer.cpp

Chris Lattner lattner at cs.uiuc.edu
Wed Dec 31 04:21:12 PST 2003


Changes in directory llvm/lib/Support:

SlowOperationInformer.cpp updated: 1.2 -> 1.3

---
Log message:

* 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%


---
Diffs of the changes:  (+11 -4)

Index: llvm/lib/Support/SlowOperationInformer.cpp
diff -u llvm/lib/Support/SlowOperationInformer.cpp:1.2 llvm/lib/Support/SlowOperationInformer.cpp:1.3
--- llvm/lib/Support/SlowOperationInformer.cpp:1.2	Wed Dec 31 01:31:10 2003
+++ llvm/lib/Support/SlowOperationInformer.cpp	Wed Dec 31 04:20:38 2003
@@ -59,8 +59,12 @@
 
 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 @@
   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;





More information about the llvm-commits mailing list