From: Michael Schroeder Date: Thu, 6 Dec 2007 13:10:44 +0000 (+0000) Subject: - cleanup code a bit X-Git-Tag: BASE-SuSE-Code-12_1-Branch~308^2~769 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5f37fba290d4b7efbddf94b0d1ce9fcb5097fa2c;p=thirdparty%2Flibsolv.git - cleanup code a bit --- diff --git a/src/repo_solv.c b/src/repo_solv.c index edb5fcbc..a7dcd579 100644 --- a/src/repo_solv.c +++ b/src/repo_solv.c @@ -132,26 +132,31 @@ read_idarray(FILE *fp, Id max, Id *map, Id *store, Id *end, int relative) if ((c & 128) == 0) { x = (x << 6) | (c & 63); - if (!relative || x != 0) + if (relative) { - if (relative) - { - x--; - x += old; - old = x; - } - if (x >= max) + if (x == 0 && c == 0x40) { - pool_debug(mypool, SAT_FATAL, "read_idarray: id too large (%u/%u)\n", x, max); - exit(1); + /* prereq hack */ + if (store == end) + { + pool_debug(mypool, SAT_FATAL, "read_idarray: array overflow\n"); + exit(1); + } + *store++ = SOLVABLE_PREREQMARKER; + old = 0; + x = 0; + continue; } - if (map) - x = map[x]; + x = (x - 1) + old; + old = x; + } + if (x >= max) + { + pool_debug(mypool, SAT_FATAL, "read_idarray: id too large (%u/%u)\n", x, max); + exit(1); } - else - /* (relative && x==0) : - Ugly PREREQ handling. See repo_write.c. */ - x = SOLVABLE_PREREQMARKER, old = 0; + if (map) + x = map[x]; if (store == end) { pool_debug(mypool, SAT_FATAL, "read_idarray: array overflow\n"); @@ -160,6 +165,8 @@ read_idarray(FILE *fp, Id max, Id *map, Id *store, Id *end, int relative) *store++ = x; if ((c & 64) == 0) { + if (x == 0) /* already have trailing zero? */ + return store; if (store == end) { pool_debug(mypool, SAT_FATAL, "read_idarray: array overflow\n"); diff --git a/tools/repo_write.c b/tools/repo_write.c index af7bf6ce..11eb7a97 100644 --- a/tools/repo_write.c +++ b/tools/repo_write.c @@ -198,8 +198,6 @@ write_idarray(FILE *fp, Pool *pool, NeedId *needid, Id *ids) return; if (!*ids) { - /* XXX I think this is broken. A lone '0' will be interpreted as - zero plus end-of-array, which stores another zero. */ write_u8(fp, 0); return; } @@ -235,8 +233,6 @@ write_idarray_sort(FILE *fp, Pool *pool, NeedId *needid, Id *ids) return; if (!*ids) { - /* XXX I think this is broken. A lone '0' will be interpreted as - zero plus end-of-array, which stores another zero. */ write_u8 (fp, 0); return; }