X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/7f25bdff3a0fa55ba897964d5c82475b45f3325a..f17ac0977167d1e58316d3b3f7159f65d40a090a:/apt-pkg/contrib/strutl.cc diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc index 6a90b2b88..eb3ef96a2 100644 --- a/apt-pkg/contrib/strutl.cc +++ b/apt-pkg/contrib/strutl.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: strutl.cc,v 1.17 1999/01/18 06:20:08 jgg Exp $ +// $Id: strutl.cc,v 1.20 1999/02/27 22:29:11 jgg Exp $ /* ###################################################################### String Util - Some usefull string functions. @@ -16,15 +16,16 @@ /*}}}*/ // Includes /*{{{*/ #ifdef __GNUG__ -#pragma implementation "strutl.h" +#pragma implementation "apt-pkg/strutl.h" #endif -#include +#include #include #include #include #include +#include /*}}}*/ // strstrip - Remove white space from the front and back of a string /*{{{*/ @@ -116,7 +117,7 @@ bool ParseQuoteWord(const char *&String,string &Res) { Tmp[0] = Start[1]; Tmp[1] = Start[2]; - Tmp[3] = 0; + Tmp[2] = 0; *I = (char)strtol(Tmp,0,16); Start += 3; continue; @@ -177,6 +178,30 @@ bool ParseCWord(const char *String,string &Res) return true; } /*}}}*/ +// DeQuoteString - Convert a string from quoted from /*{{{*/ +// --------------------------------------------------------------------- +/* This undoes QuoteString */ +string DeQuoteString(string Str) +{ + string Res; + for (string::iterator I = Str.begin(); I != Str.end(); I++) + { + if (*I == '%' && I + 2 < Str.end()) + { + char Tmp[3]; + Tmp[0] = I[1]; + Tmp[1] = I[2]; + Tmp[2] = 0; + Res += (char)strtol(Tmp,0,16); + I += 2; + continue; + } + else + Res += *I; + } + return Res; +} + /*}}}*/ // QuoteString - Convert a string into quoted from /*{{{*/ // --------------------------------------------------------------------- /* */