diff options
author | Michael Vogt <mvo@debian.org> | 2013-10-18 18:26:56 +0200 |
---|---|---|
committer | Michael Vogt <mvo@debian.org> | 2013-10-18 18:26:56 +0200 |
commit | 65dbd5a1a32f63dae81c8b5814cd246f1154c38d (patch) | |
tree | 1fb99e95a46aa784f15ccd9f4c402b36134dfae0 /apt-pkg/contrib/strutl.cc | |
parent | 34d6563ef47b455b69a7bc9ad0838902bb911dea (diff) |
re-add missing APT::String::Strip
Diffstat (limited to 'apt-pkg/contrib/strutl.cc')
-rw-r--r-- | apt-pkg/contrib/strutl.cc | 17 |
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 */ |