]> git.saurik.com Git - apt.git/blobdiff - ftparchive/cachedb.cc
[debian/changlog] add entry for the "missing source.list file" fix
[apt.git] / ftparchive / cachedb.cc
index 0e6078642ad4833b6aa4bb200096774032389e33..ff9a92d3264f2f78013893949e9ce944e1c07945 100644 (file)
    ##################################################################### */
                                                                        /*}}}*/
 // Include Files                                                       /*{{{*/
    ##################################################################### */
                                                                        /*}}}*/
 // Include Files                                                       /*{{{*/
-#ifdef __GNUG__
-#pragma implementation "cachedb.h"
-#endif
-
 #include "cachedb.h"
 
 #include <apti18n.h>
 #include "cachedb.h"
 
 #include <apti18n.h>
@@ -453,21 +449,21 @@ bool CacheDB::Clean()
    memset(&Data,0,sizeof(Data));
    while ((errno = Cursor->c_get(Cursor,&Key,&Data,DB_NEXT)) == 0)
    {
    memset(&Data,0,sizeof(Data));
    while ((errno = Cursor->c_get(Cursor,&Key,&Data,DB_NEXT)) == 0)
    {
-      const char *Colon = (char *)Key.data;
-      for (; Colon != (char *)Key.data+Key.size && *Colon != ':'; Colon++);
-      if ((char *)Key.data+Key.size - Colon > 2)
+      const char *Colon = (char*)memrchr(Key.data, ':', Key.size);
+      if (Colon)
       {
       {
-        if (stringcmp((char *)Key.data,Colon,"st") == 0 ||
-            stringcmp((char *)Key.data,Colon,"cn") == 0 ||
-            stringcmp((char *)Key.data,Colon,"cl") == 0)
+         if (stringcmp(Colon + 1, (char *)Key.data+Key.size,"st") == 0 ||
+             stringcmp(Colon + 1, (char *)Key.data+Key.size,"cl") == 0 ||
+             stringcmp(Colon + 1, (char *)Key.data+Key.size,"cn") == 0)
         {
         {
-           if (FileExists(string(Colon+1,(const char *)Key.data+Key.size)) == true)
+            if (FileExists(string((const char *)Key.data,Colon)) == true)
                continue;            
         }
       }
       
       Cursor->c_del(Cursor,0);
    }
                continue;            
         }
       }
       
       Cursor->c_del(Cursor,0);
    }
+   Dbp->compact(Dbp, NULL, NULL, NULL, NULL, DB_FREE_SPACE, NULL);
 
    return true;
 }
 
    return true;
 }