summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib/strutl.cc
diff options
context:
space:
mode:
authorMichael Vogt <mvo@debian.org>2013-10-18 08:10:29 +0200
committerMichael Vogt <mvo@debian.org>2013-10-18 08:10:29 +0200
commit2842f8f3e31fbec8c53ce40f15ff0c76f021f030 (patch)
tree4372d777894e79b0b7959bc22d4855986de0207c /apt-pkg/contrib/strutl.cc
parentc420fe0096985234e861aaafc2b9908b6259a1bb (diff)
add APT::String::Strip(), start cleanup of ProcessDpkgStatusLine
Diffstat (limited to 'apt-pkg/contrib/strutl.cc')
-rw-r--r--apt-pkg/contrib/strutl.cc17
1 files changed, 16 insertions, 1 deletions
diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc
index 77e48962c..9f794927d 100644
--- a/apt-pkg/contrib/strutl.cc
+++ b/apt-pkg/contrib/strutl.cc
@@ -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 */