Browse Source

re-add missing APT::String::Strip

tags/debian/0.9.13.exp1
Michael Vogt 8 years ago
parent
commit
65dbd5a1a3
6 changed files with 36 additions and 6 deletions
  1. +16
    -1
      apt-pkg/contrib/strutl.cc
  2. +7
    -0
      apt-pkg/contrib/strutl.h
  3. +4
    -3
      apt-pkg/deb/dpkgpm.cc
  4. +8
    -0
      apt-pkg/iprogress.cc
  5. +1
    -1
      apt-pkg/iprogress.h
  6. +0
    -1
      test/integration/test-apt-progress-fd

+ 16
- 1
apt-pkg/contrib/strutl.cc View File

@@ -36,7 +36,22 @@

using namespace std;
/*}}}*/

// Strip - Remove white space from the front and back of a string /*{{{*/
// ---------------------------------------------------------------------
namespace APT {
namespace String {
std::string Strip(const std::string &s)
{
size_t start = s.find_first_not_of(" \t\n");
// only whitespace
if (start == string::npos)
return "";
size_t end = s.find_last_not_of(" \t\n");
return s.substr(start, end-start+1);
}
}
}
/*}}}*/
// UTF8ToCodeset - Convert some UTF-8 string for some codeset /*{{{*/
// ---------------------------------------------------------------------
/* This is handy to use before display some information for enduser */


+ 7
- 0
apt-pkg/contrib/strutl.h View File

@@ -33,6 +33,13 @@ using std::vector;
using std::ostream;
#endif

namespace APT {
namespace String {
std::string Strip(const std::string &s);
};
};


bool UTF8ToCodeset(const char *codeset, const std::string &orig, std::string *dest);
char *_strstrip(char *String);
char *_strrstrip(char *String); // right strip only


+ 4
- 3
apt-pkg/deb/dpkgpm.cc View File

@@ -668,6 +668,10 @@ void pkgDPkgPM::ProcessDpkgStatusLine(char *line)
// check if the package moved to the next dpkg state
if(next_action && (action == next_action))
{
// we moved from one dpkg state to a new one, report that
PackageOpsDone[pkg]++;
PackagesDone++;

// only read the translation if there is actually a next
// action
const char *translation = _(states[PackageOpsDone[pkg]].str);
@@ -675,9 +679,6 @@ void pkgDPkgPM::ProcessDpkgStatusLine(char *line)
strprintf(msg, translation, i18n_pkgname.c_str());
d->progress->StatusChanged(pkgname, PackagesDone, PackagesTotal, msg);
// we moved from one dpkg state to a new one, report that
PackageOpsDone[pkg]++;
PackagesDone++;
}
if (Debug == true)
std::clog << "(parsed from dpkg) pkg: " << short_pkgname


+ 8
- 0
apt-pkg/iprogress.cc View File

@@ -29,6 +29,7 @@ bool PackageManager::StatusChanged(std::string PackageName,
}

PackageManagerProgressFd::PackageManagerProgressFd(int progress_fd)
: StepsDone(0), StepsTotal(1)
{
OutStatusFd = progress_fd;
}
@@ -106,6 +107,13 @@ bool PackageManagerProgressFd::StatusChanged(std::string PackageName,
<< ":" << pkg_action
<< std::endl;
WriteToStatusFd(status.str());

if(_config->FindB("Debug::APT::Progress::PackageManagerFd", false) == true)
std::cerr << "progress: " << PackageName << " " << xStepsDone
<< " " << xTotalSteps << " " << pkg_action
<< std::endl;


return true;
}



+ 1
- 1
apt-pkg/iprogress.h View File

@@ -21,7 +21,7 @@ namespace Progress {

public:
PackageManager()
: percentage(0.0), last_reported_progress(0) {};
: percentage(0.0), last_reported_progress(-1) {};
virtual ~PackageManager() {};

virtual void Start() {};


+ 0
- 1
test/integration/test-apt-progress-fd View File

@@ -50,7 +50,6 @@ pmstatus:testing:33.3333:Preparing for removal of testing (amd64)
pmstatus:testing:66.6667:Removing testing (amd64)
pmstatus:testing:100:Removed testing (amd64)" cat apt-progress.log


# install non-native and ensure we get proper progress info
exec 3> apt-progress.log
testsuccess aptget install testing2:i386 -y -o APT::Status-Fd=3


Loading…
Cancel
Save