Quellcode durchsuchen

split out a method to strip whitespaces only on the right side

Michael Vogt vor 13 Jahren
Ursprung
Commit
4fb400a66f
2 geänderte Dateien mit 8 neuen und 1 gelöschten Zeilen
  1. 7 1
      apt-pkg/contrib/strutl.cc
  2. 1 0
      apt-pkg/contrib/strutl.h

+ 7 - 1
apt-pkg/contrib/strutl.cc

@@ -117,7 +117,13 @@ char *_strstrip(char *String)
 
    if (*String == 0)
       return String;
-
+   return _strrstrip(String);
+}
+									/*}}}*/
+// strrstrip - Remove white space from the back of a string	/*{{{*/
+// ---------------------------------------------------------------------
+char *_strrstrip(char *String)
+{
    char *End = String + strlen(String) - 1;
    for (;End != String - 1 && (*End == ' ' || *End == '\t' || *End == '\n' ||
 			       *End == '\r'); End--);

+ 1 - 0
apt-pkg/contrib/strutl.h

@@ -35,6 +35,7 @@ using std::ostream;
 
 bool UTF8ToCodeset(const char *codeset, const std::string &orig, std::string *dest);
 char *_strstrip(char *String);
+char *_strrstrip(char *String); // right strip only
 char *_strtabexpand(char *String,size_t Len);
 bool ParseQuoteWord(const char *&String,std::string &Res);
 bool ParseCWord(const char *&String,std::string &Res);