From: Michael Schroeder Date: Wed, 11 Jan 2012 13:12:06 +0000 (+0100) Subject: - set pool_id2color, fix comments X-Git-Tag: BASE-SuSE-Code-12_2-Branch~210 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=34fd443de1375fcbc9cd05669f34ba545d329217;p=thirdparty%2Flibsolv.git - set pool_id2color, fix comments --- diff --git a/src/chksum.c b/src/chksum.c index fb252bcd..c69a3503 100644 --- a/src/chksum.c +++ b/src/chksum.c @@ -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 #include #include diff --git a/src/dirpool.c b/src/dirpool.c index 4d3281c5..d7ed384a 100644 --- a/src/dirpool.c +++ b/src/dirpool.c @@ -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 @@ -45,21 +45,21 @@ * 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" */ diff --git a/src/policy.c b/src/policy.c index 8e3b75ad..494072f1 100644 --- a/src/policy.c +++ b/src/policy.c @@ -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) { diff --git a/src/pool.h b/src/pool.h index 535fd698..bd60d9cf 100644 --- a/src/pool.h +++ b/src/pool.h @@ -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 */ diff --git a/src/poolarch.c b/src/poolarch.c index 2faa8e06..fd10910d 100644 --- a/src/poolarch.c +++ b/src/poolarch.c @@ -155,6 +155,7 @@ pool_arch2color_slow(Pool *pool, Id arch) color = ARCHCOLOR_64; else color = ARCHCOLOR_32; + pool->id2color[arch] = color; return color; } diff --git a/src/poolid.c b/src/poolid.c index bf8d18ba..accccc7b 100644 --- a/src/poolid.c +++ b/src/poolid.c @@ -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 */ diff --git a/src/poolid.h b/src/poolid.h index d8cd6586..f5ea82ec 100644 --- a/src/poolid.h +++ b/src/poolid.h @@ -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); diff --git a/src/pooltypes.h b/src/pooltypes.h index daee334b..51f65211 100644 --- a/src/pooltypes.h +++ b/src/pooltypes.h @@ -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 */ diff --git a/src/qsort_r.c b/src/qsort_r.c index c4bc6d27..953462b1 100644 --- a/src/qsort_r.c +++ b/src/qsort_r.c @@ -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. diff --git a/src/repo.c b/src/repo.c index 418ba7f2..c3767c86 100644 --- a/src/repo.c +++ b/src/repo.c @@ -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: */ diff --git a/src/repopage.c b/src/repopage.c index ad633a34..f9cd514c 100644 --- a/src/repopage.c +++ b/src/repopage.c @@ -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 + /* b 100lllll */ { 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 diff --git a/src/rules.c b/src/rules.c index 83426f8e..bfa79579 100644 --- a/src/rules.c +++ b/src/rules.c @@ -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; diff --git a/src/strpool.c b/src/strpool.c index 0b47367e..0d92bebd 100644 --- a/src/strpool.c +++ b/src/strpool.c @@ -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; diff --git a/src/strpool.h b/src/strpool.h index 5e465446..1a385c91 100644 --- a/src/strpool.h +++ b/src/strpool.h @@ -15,13 +15,13 @@ 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[]); diff --git a/src/transaction.c b/src/transaction.c index f098749b..aa6d77c1 100644 --- a/src/transaction.c +++ b/src/transaction.c @@ -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]) {