mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-21 23:17:16 +00:00
* 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
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user