]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/contrib/strutl.cc
Simplified time calculations
[apt.git] / apt-pkg / contrib / strutl.cc
index 6a90b2b8803ab9debca1d87c654d3613c7b69287..eb3ef96a2992519399c90d03e50b8b32f1af0ec8 100644 (file)
@@ -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.
                                                                        /*}}}*/
 // Includes                                                            /*{{{*/
 #ifdef __GNUG__
-#pragma implementation "strutl.h"
+#pragma implementation "apt-pkg/strutl.h"
 #endif
 
-#include <strutl.h>
+#include <apt-pkg/strutl.h>
 #include <apt-pkg/fileutl.h>
 
 #include <ctype.h>
 #include <string.h>
 #include <stdio.h>
+#include <unistd.h>
                                                                        /*}}}*/
 
 // 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                     /*{{{*/
 // ---------------------------------------------------------------------
 /* */