~ubuntu-core-dev/apt/oneiric

« back to all changes in this revision

Viewing changes to apt-pkg/contrib/strutl.cc

  • Committer: Michael Vogt
  • Date: 2011-08-15 12:14:35 UTC
  • mfrom: (1327.97.57 debian-sid)
  • Revision ID: michael.vogt@ubuntu.com-20110815121435-ya00o0nicb1kiz2y
merged from the debian-sid branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
271
271
string QuoteString(const string &Str, const char *Bad)
272
272
{
273
273
   string Res;
274
 
   for (string::const_iterator I = Str.begin(); I != Str.end(); I++)
 
274
   for (string::const_iterator I = Str.begin(); I != Str.end(); ++I)
275
275
   {
276
276
      if (strchr(Bad,*I) != 0 || isprint(*I) == 0 || 
277
277
          *I == 0x25 || // percent '%' char
298
298
                        string::const_iterator const &end)
299
299
{
300
300
   string Res;
301
 
   for (string::const_iterator I = begin; I != end; I++)
 
301
   for (string::const_iterator I = begin; I != end; ++I)
302
302
   {
303
303
      if (*I == '%' && I + 2 < end &&
304
304
          isxdigit(I[1]) && isxdigit(I[2]))
632
632
{
633
633
   // Look for a matching tag.
634
634
   int Length = strlen(Tag);
635
 
   for (string::const_iterator I = Message.begin(); I + Length < Message.end(); I++)
 
635
   for (string::const_iterator I = Message.begin(); I + Length < Message.end(); ++I)
636
636
   {
637
637
      // Found the tag
638
638
      if (I[Length] == ':' && stringcasecmp(I,I+Length,Tag) == 0)
640
640
         // Find the end of line and strip the leading/trailing spaces
641
641
         string::const_iterator J;
642
642
         I += Length + 1;
643
 
         for (; isspace(*I) != 0 && I < Message.end(); I++);
644
 
         for (J = I; *J != '\n' && J < Message.end(); J++);
645
 
         for (; J > I && isspace(J[-1]) != 0; J--);
 
643
         for (; isspace(*I) != 0 && I < Message.end(); ++I);
 
644
         for (J = I; *J != '\n' && J < Message.end(); ++J);
 
645
         for (; J > I && isspace(J[-1]) != 0; --J);
646
646
         
647
647
         return string(I,J);
648
648
      }
649
649
      
650
 
      for (; *I != '\n' && I < Message.end(); I++);
 
650
      for (; *I != '\n' && I < Message.end(); ++I);
651
651
   }   
652
652
   
653
653
   // Failed to find a match
1224
1224
bool CheckDomainList(const string &Host,const string &List)
1225
1225
{
1226
1226
   string::const_iterator Start = List.begin();
1227
 
   for (string::const_iterator Cur = List.begin(); Cur <= List.end(); Cur++)
 
1227
   for (string::const_iterator Cur = List.begin(); Cur <= List.end(); ++Cur)
1228
1228
   {
1229
1229
      if (Cur < List.end() && *Cur != ',')
1230
1230
         continue;
1248
1248
   char tmp[3];
1249
1249
   string::const_iterator it, escape_start;
1250
1250
   string output, octal, hex;
1251
 
   for (it = input.begin(); it != input.end(); it++) 
 
1251
   for (it = input.begin(); it != input.end(); ++it)
1252
1252
   {
1253
1253
      // just copy non-escape chars
1254
1254
      if (*it != '\\')
1264
1264
         // copy
1265
1265
         output += *it;
1266
1266
         // advance iterator one step further
1267
 
         it += 1;
 
1267
         ++it;
1268
1268
         continue;
1269
1269
      }
1270
1270
        
1273
1273
         continue;
1274
1274
 
1275
1275
      // read it
1276
 
      it++;
 
1276
      ++it;
1277
1277
      switch (*it)
1278
1278
      {
1279
1279
         case '0':
1310
1310
   string::const_iterator I = U.begin();
1311
1311
 
1312
1312
   // Locate the first colon, this separates the scheme
1313
 
   for (; I < U.end() && *I != ':' ; I++);
 
1313
   for (; I < U.end() && *I != ':' ; ++I);
1314
1314
   string::const_iterator FirstColon = I;
1315
1315
 
1316
1316
   /* Determine if this is a host type URI with a leading double //
1322
1322
   /* Find the / indicating the end of the hostname, ignoring /'s in the
1323
1323
      square brackets */
1324
1324
   bool InBracket = false;
1325
 
   for (; SingleSlash < U.end() && (*SingleSlash != '/' || InBracket == true); SingleSlash++)
 
1325
   for (; SingleSlash < U.end() && (*SingleSlash != '/' || InBracket == true); ++SingleSlash)
1326
1326
   {
1327
1327
      if (*SingleSlash == '[')
1328
1328
         InBracket = true;
1355
1355
   I = FirstColon + 1;
1356
1356
   if (I > SingleSlash)
1357
1357
      I = SingleSlash;
1358
 
   for (; I < SingleSlash && *I != ':'; I++);
 
1358
   for (; I < SingleSlash && *I != ':'; ++I);
1359
1359
   string::const_iterator SecondColon = I;
1360
1360
   
1361
1361
   // Search for the @ after the colon
1362
 
   for (; I < SingleSlash && *I != '@'; I++);
 
1362
   for (; I < SingleSlash && *I != '@'; ++I);
1363
1363
   string::const_iterator At = I;
1364
1364
   
1365
1365
   // Now write the host and user/pass