summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Burrows <dburrows@debian.org>2010-06-27 10:03:36 -0700
committerDaniel Burrows <dburrows@debian.org>2010-06-27 10:05:06 -0700
commitd3e3fd8731a86e4e27541dcbbba2149b9934e267 (patch)
tree47851787ec3056bdd241f5cf3f3a2868023ea480 /src
parent5f1adab0833ab71f684989ead11028d00649928e (diff)
downloadaptitude-d3e3fd8731a86e4e27541dcbbba2149b9934e267.tar.gz
Adapt patch from Ubuntu to fix a formatting problem in the progress code on large terminals. (Closes: #586470)
This module needs a broader overhaul, but the patch is quick and easy to apply and will fix the immediate problem.
Diffstat (limited to 'src')
-rw-r--r--src/generic/apt/acqprogress.cc12
-rw-r--r--src/generic/apt/acqprogress.h3
2 files changed, 10 insertions, 5 deletions
diff --git a/src/generic/apt/acqprogress.cc b/src/generic/apt/acqprogress.cc
index 556c64ee..889b6e24 100644
--- a/src/generic/apt/acqprogress.cc
+++ b/src/generic/apt/acqprogress.cc
@@ -175,14 +175,18 @@ void AcqTextStatus::Pulse(pkgAcquire *Owner, download_signal_log &manager,
enum {Long = 0,Medium,Short} Mode = Long;
- char Buffer[1024];
+ char Buffer[buffer_size];
char *End = Buffer + sizeof(Buffer);
char *S = Buffer;
- if (ScreenWidth >= sizeof(Buffer))
- ScreenWidth = sizeof(Buffer)-1;
+ // Save the current screen width in case it's updated underneath us
+ // for whatever reason.
+ const unsigned int ScreenWidth =
+ (this->ScreenWidth >= sizeof(Buffer))
+ ? sizeof(Buffer) - 1
+ : this->ScreenWidth;
// Put in the percent done
- snprintf(S,1024,"%ld%%",long(double((CurrentBytes + CurrentItems)*100.0)/double(TotalBytes+TotalItems)));
+ snprintf(S, buffer_size,"%ld%%",long(double((CurrentBytes + CurrentItems)*100.0)/double(TotalBytes+TotalItems)));
bool Shown = false;
for (pkgAcquire::Worker *I = Owner->WorkersBegin(); I != 0;
diff --git a/src/generic/apt/acqprogress.h b/src/generic/apt/acqprogress.h
index 5130deb8..b70972df 100644
--- a/src/generic/apt/acqprogress.h
+++ b/src/generic/apt/acqprogress.h
@@ -20,7 +20,8 @@ class download_signal_log;
class AcqTextStatus : public sigc::trackable
{
unsigned int &ScreenWidth;
- char BlankLine[300];
+ static const int buffer_size = 1024;
+ char BlankLine[buffer_size];
unsigned long ID;
unsigned long Quiet;