- set pool_id2color, fix comments
authorMichael Schroeder <mls@suse.de>
Wed, 11 Jan 2012 13:12:06 +0000 (14:12 +0100)
committerMichael Schroeder <mls@suse.de>
Wed, 11 Jan 2012 13:12:06 +0000 (14:12 +0100)
15 files changed:
src/chksum.c
src/dirpool.c
src/policy.c
src/pool.h
src/poolarch.c
src/poolid.c
src/poolid.h
src/pooltypes.h
src/qsort_r.c
src/repo.c
src/repopage.c
src/rules.c
src/strpool.c
src/strpool.h
src/transaction.c

index fb252bc..c69a350 100644 (file)
@@ -1,3 +1,10 @@
+/*
+ * Copyright (c) 2008-2012, Novell Inc.
+ *
+ * This program is licensed under the BSD license, read LICENSE.BSD
+ * for further information
+ */
+
 #include <sys/types.h>
 #include <stdio.h>
 #include <stdlib.h>
index 4d3281c..d7ed384 100644 (file)
@@ -26,7 +26,7 @@
  *   dirs[id] <= 0 : -(parent directory id)
  *
  * Directories with the same parent are stored as
- * multiple blocks. We need multiple blocks, because
+ * multiple blocks. We need multiple blocks because
  * we cannot insert entries into old blocks, as that
  * would shift the ids of already used directories.
  * Each block starts with (-parent_dirid) and contains
@@ -37,7 +37,7 @@
  * There is also the aux "dirtraverse" array, which
  * is created on demand to speed things up a bit.
  * if dirs[id] > 0, dirtravers[id] points to the first
- * entry in the last block with parent id
+ * entry in the last block with parent id.
  * if dirs[id] <= 0, dirtravers[id] points to the entry
  * in the previous block with the same parent.
  * (Thus it acts as a linked list that starts at the
  * parent.)
  *
  *  id    dirs[id]  dirtraverse[id]
- *   0     0           8       [block#0 no parent]
+ *   0     0           8       [no parent, block#0]
  *   1    ""           3
- *   2    -1                   [block#0 parent 1, /]
+ *   2    -1                   [parent 1, /, block #0]
  *   3    "usr"       12
- *   4    -3                   [block#0 parent 3, /usr]
+ *   4    -3                   [parent 3, /usr, block #0]
  *   5    "bin"
  *   6    "lib"
- *   7     0           1       [block#1 no parent]
+ *   7     0           1       [no parent, block#1]
  *   8    "foo"       10
- *   9    -8                   [block#0 parent 8, foo]
+ *   9    -8                   [parent 8, foo, block #0]
  *  10    "bar"
- *  11    -3           5       [block#1 parent 3, /usr]
+ *  11    -3           5       [parent 3, /usr, block #1]
  *  12    "games"
  *   
- * to find all children of dirid 3, "/usr", follow the
+ * to find all children of dirid 3 ("/usr"), follow the
  * dirtraverse link to 12 -> "games". Then follow the
  * dirtraverse link of this block to 5 -> "bin", "lib"
  */
index 8e3b75a..494072f 100644 (file)
@@ -229,7 +229,7 @@ prune_to_recommended(Solver *solv, Queue *plist)
   if (plist->count - ninst < 2)
     return;
 
-  /* prune to suggested/enhanced*/
+  /* prune to suggested/enhanced */
   ninst = 0;
   for (i = j = 0; i < plist->count; i++)
     {
@@ -521,6 +521,8 @@ move_installed_to_front(Pool *pool, Queue *plist)
                memmove(plist->elements + j + 1, plist->elements + j, (i - j) * sizeof(Id));
              plist->elements[j] = p;
            }
+         else if (j + 2 == plist->count)
+           break;      /* no need to check last element if all prev ones are installed */
          j++;
        }
     }
@@ -611,7 +613,7 @@ prune_best_arch_name_version(const Solver *solv, Pool *pool, Queue *plist)
 }
 
 /* installed packages involed in a dup operation can only be kept
-* if they are identical to a non-installed one */
+ * if they are identical to a non-installed one */
 static void
 prune_installed_dup_packages(Solver *solv, Queue *plist)
 {
index 535fd69..bd60d9c 100644 (file)
@@ -37,7 +37,7 @@ extern "C" {
 /* how many strings to maintain (round robin) */
 #define POOL_TMPSPACEBUF 16
 
-//-----------------------------------------------
+/*----------------------------------------------- */
 
 struct _Repo;
 struct _Repodata;
@@ -157,7 +157,7 @@ struct _Pool {
 
 #define SOLV_DEBUG_TO_STDERR           (1<<30)
 
-//-----------------------------------------------
+/* ----------------------------------------------- */
 
 
 /* mark dependencies with relation by setting bit31 */
index 2faa8e0..fd10910 100644 (file)
@@ -155,6 +155,7 @@ pool_arch2color_slow(Pool *pool, Id arch)
     color = ARCHCOLOR_64;
   else
     color = ARCHCOLOR_32;
+  pool->id2color[arch] = color;
   return color;
 }
 
index bf8d18b..accccc7 100644 (file)
@@ -72,7 +72,7 @@ pool_rel2id(Pool *pool, Id name, Id evr, int flags, int create)
       solv_free(pool->relhashtbl);
       pool->relhashmask = hashmask = mkmask(pool->nrels + REL_BLOCK);
       pool->relhashtbl = hashtbl = solv_calloc(hashmask + 1, sizeof(Id));
-      // rehash all rels into new hashtable
+      /* rehash all rels into new hashtable */
       for (i = 1; i < pool->nrels; i++)
        {
          h = relhash(ran[i].name, ran[i].evr, ran[i].flags) & hashmask;
@@ -117,9 +117,9 @@ pool_rel2id(Pool *pool, Id name, Id evr, int flags, int create)
 }
 
 
-// Id -> String
-// for rels (returns name only) and strings
-/
+/* Id -> String
+ * for rels (returns name only) and strings
+ *
 const char *
 pool_id2str(const Pool *pool, Id id)
 {
@@ -153,7 +153,7 @@ static const char *rels[] = {
 };
 
 
-// get operator for RelId
+/* get operator for RelId */
 const char *
 pool_id2rel(const Pool *pool, Id id)
 {
@@ -185,8 +185,7 @@ pool_id2rel(const Pool *pool, Id id)
 }
 
 
-// get e:v.r for Id
-// 
+/* get e:v.r for Id */
 const char *
 pool_id2evr(const Pool *pool, Id id)
 {
@@ -278,8 +277,7 @@ pool_shrink_rels(Pool *pool)
   pool->rels = solv_extend_resize(pool->rels, pool->nrels, sizeof(Reldep), REL_BLOCK);
 }
 
-// reset all hash tables
-// 
+/* free all hash tables */
 void
 pool_freeidhashes(Pool *pool)
 {
@@ -288,4 +286,4 @@ pool_freeidhashes(Pool *pool)
   pool->relhashmask = 0;
 }
 
-// EOF
+/* EOF */
index d8cd658..f5ea82e 100644 (file)
@@ -21,9 +21,9 @@
  */
 
 typedef struct _Reldep {
-  Id name;             // "package"
-  Id evr;              // "0:42-3"
-  int flags;           // operation/relation, see REL_x in pool.h
+  Id name;             /* "package" */
+  Id evr;              /* "0:42-3" */
+  int flags;           /* operation/relation, see REL_x in pool.h */
 } Reldep;
 
 extern Id pool_str2id(Pool *pool, const char *, int);
index daee334..51f6521 100644 (file)
@@ -44,10 +44,10 @@ typedef struct _Stringpool Stringpool;
 struct _Pool;
 typedef struct _Pool Pool;
 
-// identifier for string values
+/* identifier for string values */
 typedef int Id;                /* must be signed!, since negative Id is used in solver rules to denote negation */
 
-// offset value, e.g. used to 'point' into the stringspace
+/* offset value, e.g. used to 'point' into the stringspace */
 typedef unsigned int Offset;
 
 #endif /* LIBSOLV_POOLTYPES_H */
index c4bc6d2..953462b 100644 (file)
@@ -3,6 +3,8 @@
  * argument ordering
  */
 
+/* FIXME: should use mergesort instead */
+
 /*-
  * Copyright (c) 1992, 1993
  *     The Regents of the University of California.  All rights reserved.
index 418ba7f..c3767c8 100644 (file)
@@ -585,6 +585,11 @@ repo_reserve_ids(Repo *repo, Offset olddeps, int num)
 }
 
 
+/***********************************************************************/
+
+/*
+ * some SUSE specific fixups, should go into a separate file
+ */
 
 Offset
 repo_fix_supplements(Repo *repo, Offset provides, Offset supplements, Offset freshens)
@@ -622,13 +627,8 @@ repo_fix_supplements(Repo *repo, Offset provides, Offset supplements, Offset fre
                      continue;
                    }
                  *p++ = 0;
-#if 0
-                 strncpy(dep - 9, "language:", 9);
-                 idl = pool_str2id(pool, dep - 9, 1);
-#else
                  idl = pool_str2id(pool, dep, 1);
                  idl = pool_rel2id(pool, NAMESPACE_LANGUAGE, idl, REL_NAMESPACE, 1);
-#endif
                  if (id)
                    id = pool_rel2id(pool, id, idl, REL_OR, 1);
                  else
@@ -640,13 +640,8 @@ repo_fix_supplements(Repo *repo, Offset provides, Offset supplements, Offset fre
                  for (p = dep; *p && *p != ')'; p++)
                    ;
                  *p = 0;
-#if 0
-                 strncpy(dep - 9, "language:", 9);
-                 idl = pool_str2id(pool, dep - 9, 1);
-#else
                  idl = pool_str2id(pool, dep, 1);
                  idl = pool_rel2id(pool, NAMESPACE_LANGUAGE, idl, REL_NAMESPACE, 1);
-#endif
                  if (id)
                    id = pool_rel2id(pool, id, idl, REL_OR, 1);
                  else
@@ -753,7 +748,7 @@ repo_fix_supplements(Repo *repo, Offset provides, Offset supplements, Offset fre
   if (freshens && repo->idarraydata[freshens])
     {
       Id idsupp = 0, idfresh = 0;
-      if (!supplements)
+      if (!supplements || !repo->idarraydata[supplements])
        return freshens;
       for (i = supplements; repo->idarraydata[i]; i++)
         {
@@ -807,6 +802,8 @@ repo_fix_conflicts(Repo *repo, Offset conflicts)
   return conflicts;
 }
 
+/***********************************************************************/
+
 struct matchdata
 {
   Pool *pool;
@@ -1431,7 +1428,7 @@ repo_disable_paging(Repo *repo)
   FOR_REPODATAS(repo, i, data)
     repodata_disable_paging(data);
 }
-// EOF
+
 /*
 vim:cinoptions={.5s,g0,p5,t0,(0,^-0.5s,n-0.5s:tw=78:cindent:sw=4:
 */
index ad633a3..f9cd514 100644 (file)
@@ -90,8 +90,8 @@ static unsigned int
 compress_buf(const unsigned char *in, unsigned int in_len,
              unsigned char *out, unsigned int out_len)
 {
-  unsigned int oo = 0;         //out-offset
-  unsigned int io = 0;         //in-offset
+  unsigned int oo = 0;         /* out-offset */
+  unsigned int io = 0;         /* in-offset */
 #define HS (65536)
   Ref htab[HS];
   Ref hnext[BLOCK_SIZE];
@@ -125,8 +125,8 @@ compress_buf(const unsigned char *in, unsigned int in_len,
        }
       for (; try != -1 && tries < 12; tries++)
        {
-         //assert(mlen >= 2);
-         //assert(io + mlen < in_len);
+         /* assert(mlen >= 2); */
+         /* assert(io + mlen < in_len); */
          /* Try a match starting from [io] with the strings at [try].
             That's only sensible if TRY actually is before IO (can happen
             with uninit hash table).  If we have a previous match already
@@ -230,7 +230,7 @@ match_done:
            {
              litofs--;
              unsigned litlen = io - litofs;
-             //fprintf(stderr, "lit: %d\n", litlen);
+             /* fprintf(stderr, "lit: %d\n", litlen); */
              while (litlen)
                {
                  unsigned int easy_sz;
@@ -277,7 +277,7 @@ match_done:
              litofs = 0;
            }
 
-         //fprintf(stderr, "ref: %d @ %d\n", mlen, mofs);
+         /* fprintf(stderr, "ref: %d @ %d\n", mlen, mofs); */
 
          if (mlen >= 2 && mlen <= 9 && mofs < 1024)
            {
@@ -353,7 +353,7 @@ match_done:
     {
       litofs--;
       unsigned litlen = io - litofs;
-      //fprintf(stderr, "lit: %d\n", litlen);
+      /* fprintf(stderr, "lit: %d\n", litlen); */
       while (litlen)
        {
          unsigned int easy_sz;
@@ -424,22 +424,22 @@ unchecked_decompress_buf(const unsigned char *in, unsigned int in_len,
        case 2: case 3:
        case 4: case 5:
        case 6: case 7:
-         //a 0LLLLLLL
-         //fprintf (stderr, "lit: 1\n");
+         /* a 0LLLLLLL */
+         /* fprintf (stderr, "lit: 1\n"); */
          *out++ = first;
          continue;
        case 8: case 9:
-         //b 100lllll <l+1 bytes>
+         /* b 100lllll <l+1 bytes> */
          {
            unsigned int l = first & 31;
-           //fprintf (stderr, "lit: %d\n", l);
+           /* fprintf (stderr, "lit: %d\n", l); */
            do
              *out++ = *in++;
            while (l--);
            continue;
          }
        case 10: case 11:
-         //c 101oolll <8o>
+         /* c 101oolll <8o> */
          {
            o = first & (3 << 3);
            o = (o << 5) | *in++;
@@ -447,14 +447,14 @@ unchecked_decompress_buf(const unsigned char *in, unsigned int in_len,
            break;
          }
        case 12: case 13:
-         //d 110lllll <8o>
+         /* d 110lllll <8o> */
          {
            o = *in++;
            first = (first & 31) + 10;
            break;
          }
        case 14:
-         // e 1110llll <8o> <8o>
+         /* e 1110llll <8o> <8o> */
          {
            o = in[0] | (in[1] << 8);
            in += 2;
@@ -463,9 +463,9 @@ unchecked_decompress_buf(const unsigned char *in, unsigned int in_len,
            break;
          }
        case 15:
-         //f1 1111llll <8o> <8o> <8l>
-         //f2 11110lll <8o> <8o> <8l>
-         // g 11111lll <8o> <8o> <8o> <8l>
+         /* f1 1111llll <8o> <8o> <8l> */
+         /* f2 11110lll <8o> <8o> <8l> */
+         /* g 11111lll <8o> <8o> <8o> <8l> */
          {
            first = first & 15;
            if (first >= 8)
@@ -483,7 +483,7 @@ unchecked_decompress_buf(const unsigned char *in, unsigned int in_len,
            break;
          }
        }
-      //fprintf(stderr, "ref: %d @ %d\n", first, o);
+      /* fprintf(stderr, "ref: %d @ %d\n", first, o); */
       o++;
       o = -o;
 #if 0
index 83426f8..bfa7957 100644 (file)
@@ -2020,7 +2020,7 @@ solver_addchoicerules(Solver *solv)
       r = solv->rules + rid;
       if (r->p >= 0 || ((r->d == 0 || r->d == -1) && r->w2 < 0))
        continue;       /* only look at requires rules */
-      // solver_printrule(solv, SOLV_DEBUG_RESULT, r);
+      /* solver_printrule(solv, SOLV_DEBUG_RESULT, r); */
       queue_empty(&q);
       queue_empty(&qi);
       havechoice = 0;
index 0b47367..0d92beb 100644 (file)
@@ -19,15 +19,15 @@ stringpool_init(Stringpool *ss, const char *strs[])
   unsigned count;
 
   memset(ss, 0, sizeof(*ss));
-  // count number and total size of predefined strings
+  /* count number and total size of predefined strings */
   for (count = 0; strs[count]; count++)
     totalsize += strlen(strs[count]) + 1;
 
-  // alloc appropriate space
+  /* alloc appropriate space */
   ss->stringspace = solv_extend_resize(0, totalsize, 1, STRINGSPACE_BLOCK);
   ss->strings = solv_extend_resize(0, count, sizeof(Offset), STRING_BLOCK);
 
-  // now copy predefined strings into allocated space
+  /* now copy predefined strings into allocated space */
   ss->sstrings = 0;
   for (count = 0; strs[count]; count++)
     {
@@ -86,7 +86,6 @@ stringpool_strn2id(Stringpool *ss, const char *str, unsigned int len, int create
   Id id;
   Hashtable hashtbl;
 
-  // check string
   if (!str)
     return STRID_NULL;
   if (!len)
@@ -95,48 +94,47 @@ stringpool_strn2id(Stringpool *ss, const char *str, unsigned int len, int create
   hashmask = ss->stringhashmask;
   hashtbl = ss->stringhashtbl;
 
-  // expand hashtable if needed
+  /* expand hashtable if needed */
   if (ss->nstrings * 2 > hashmask)
     {
       solv_free(hashtbl);
 
-      // realloc hash table
+      /* realloc hash table */
       ss->stringhashmask = hashmask = mkmask(ss->nstrings + STRING_BLOCK);
       ss->stringhashtbl = hashtbl = (Hashtable)solv_calloc(hashmask + 1, sizeof(Id));
 
-      // rehash all strings into new hashtable
+      /* rehash all strings into new hashtable */
       for (i = 1; i < ss->nstrings; i++)
        {
          h = strhash(ss->stringspace + ss->strings[i]) & hashmask;
          hh = HASHCHAIN_START;
-         while (hashtbl[h] != 0)  // follow overflow chain
+         while (hashtbl[h] != 0)
            h = HASHCHAIN_NEXT(h, hh, hashmask);
          hashtbl[h] = i;
        }
     }
 
-  // compute hash and check for match
+  /* compute hash and check for match */
   h = strnhash(str, len) & hashmask;
   hh = HASHCHAIN_START;
-  while ((id = hashtbl[h]) != 0)  // follow hash overflow chain
+  while ((id = hashtbl[h]) != 0)
     {
-      // break if string already hashed
       if(!memcmp(ss->stringspace + ss->strings[id], str, len)
          && ss->stringspace[ss->strings[id] + len] == 0)
        break;
       h = HASHCHAIN_NEXT(h, hh, hashmask);
     }
-  if (id || !create)    // exit here if string found
+  if (id || !create)    /* exit here if string found */
     return id;
 
-  // generate next id and save in table
+  /* generate next id and save in table */
   id = ss->nstrings++;
   hashtbl[h] = id;
 
   ss->strings = solv_extend(ss->strings, id, 1, sizeof(Offset), STRING_BLOCK);
   ss->strings[id] = ss->sstrings;      /* we will append to the end */
 
-  // append string to stringspace
+  /* append string to stringspace */
   ss->stringspace = solv_extend(ss->stringspace, ss->sstrings, len + 1, 1, STRINGSPACE_BLOCK);
   memcpy(ss->stringspace + ss->sstrings, str, len);
   ss->stringspace[ss->sstrings + len] = 0;
index 5e46544..1a385c9 100644 (file)
 
 struct _Stringpool
 {
-  Offset *strings;            // table of offsets into stringspace, indexed by Id: Id -> Offset
-  int nstrings;               // number of unique strings in stringspace
-  char *stringspace;          // space for all unique strings: stringspace + Offset = string
-  Offset sstrings;            // next free pos in stringspace
+  Offset *strings;            /* table of offsets into stringspace, indexed by Id: Id -> Offset */
+  int nstrings;               /* number of ids in strings table */
+  char *stringspace;          /* space for all unique strings: stringspace + Offset = string */
+  Offset sstrings;            /* size of used stringspace */
 
-  Hashtable stringhashtbl;    // hash table: (string ->) Hash -> Id
-  Hashmask stringhashmask;    // modulo value for hash table (size of table - 1)
+  Hashtable stringhashtbl;    /* hash table: (string ->) Hash -> Id */
+  Hashmask stringhashmask;    /* modulo value for hash table (size of table - 1) */
 };
 
 void stringpool_init(Stringpool *ss, const char *strs[]);
index f098749..aa6d77c 100644 (file)
@@ -918,7 +918,7 @@ addedge(struct orderdata *od, Id from, Id to, int type)
   struct _TransactionElement *te;
   int i;
 
-  // printf("addedge %d %d type %d\n", from, to, type);
+  /* printf("addedge %d %d type %d\n", from, to, type); */
   s = pool->solvables + from;
   if (s->repo == pool->installed && trans->transaction_installed[from - pool->installed->start])
     {