+/*
+ * 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>
* 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
* 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"
*/
if (plist->count - ninst < 2)
return;
- /* prune to suggested/enhanced*/
+ /* prune to suggested/enhanced */
ninst = 0;
for (i = j = 0; i < plist->count; i++)
{
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++;
}
}
}
/* 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)
{
/* how many strings to maintain (round robin) */
#define POOL_TMPSPACEBUF 16
-//-----------------------------------------------
+/*----------------------------------------------- */
struct _Repo;
struct _Repodata;
#define SOLV_DEBUG_TO_STDERR (1<<30)
-//-----------------------------------------------
+/* ----------------------------------------------- */
/* mark dependencies with relation by setting bit31 */
color = ARCHCOLOR_64;
else
color = ARCHCOLOR_32;
+ pool->id2color[arch] = color;
return color;
}
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;
}
-// 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)
{
};
-// get operator for RelId
+/* get operator for RelId */
const char *
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)
{
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)
{
pool->relhashmask = 0;
}
-// EOF
+/* EOF */
*/
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);
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 */
* argument ordering
*/
+/* FIXME: should use mergesort instead */
+
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
}
+/***********************************************************************/
+
+/*
+ * some SUSE specific fixups, should go into a separate file
+ */
Offset
repo_fix_supplements(Repo *repo, Offset provides, Offset supplements, Offset freshens)
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
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
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++)
{
return conflicts;
}
+/***********************************************************************/
+
struct matchdata
{
Pool *pool;
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:
*/
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];
}
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
{
litofs--;
unsigned litlen = io - litofs;
- //fprintf(stderr, "lit: %d\n", litlen);
+ /* fprintf(stderr, "lit: %d\n", litlen); */
while (litlen)
{
unsigned int easy_sz;
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)
{
{
litofs--;
unsigned litlen = io - litofs;
- //fprintf(stderr, "lit: %d\n", litlen);
+ /* fprintf(stderr, "lit: %d\n", litlen); */
while (litlen)
{
unsigned int easy_sz;
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++;
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;
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)
break;
}
}
- //fprintf(stderr, "ref: %d @ %d\n", first, o);
+ /* fprintf(stderr, "ref: %d @ %d\n", first, o); */
o++;
o = -o;
#if 0
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;
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++)
{
Id id;
Hashtable hashtbl;
- // check string
if (!str)
return STRID_NULL;
if (!len)
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;
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[]);
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])
{