summaryrefslogtreecommitdiffstats
path: root/lib/libalpm
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2007-01-30 06:41:13 +0100
committerDan McGee <dan@archlinux.org>2007-01-30 06:41:13 +0100
commit0bc06918e4b93cae874c09f4b1d487865ca44fbd (patch)
treea10a1a774d49fb06b42b60eaa072a85889b8e88a /lib/libalpm
parente668b471426d7c8c406ace6ad05d0c5aefc56dea (diff)
downloadpacman-0bc06918e4b93cae874c09f4b1d487865ca44fbd.tar.gz
pacman-0bc06918e4b93cae874c09f4b1d487865ca44fbd.tar.xz
* Remove -fno-strict-aliasing as it is now unnecessary to compile.
* Fix up add.c a bit better than it was in regards to FS #3492. * Optimized the sqrt call in dependency cycle checking to a single call. * Removal of an outdated comment.
Diffstat (limited to 'lib/libalpm')
-rw-r--r--lib/libalpm/Makefile.am4
-rw-r--r--lib/libalpm/add.c32
-rw-r--r--lib/libalpm/deps.c13
-rw-r--r--lib/libalpm/util.c4
4 files changed, 34 insertions, 19 deletions
diff --git a/lib/libalpm/Makefile.am b/lib/libalpm/Makefile.am
index 037bcff4..eb8d788f 100644
--- a/lib/libalpm/Makefile.am
+++ b/lib/libalpm/Makefile.am
@@ -1,8 +1,6 @@
AUTOMAKE_OPTIONS = gnu
DEFINES = -pedantic -D_GNU_SOURCE
-#libalpm isn't fully C99 safe with the strict aliasing rules
-# to be fixed in the future
-AM_CFLAGS = $(DEFINES) -fno-strict-aliasing
+AM_CFLAGS = $(DEFINES)
SUBDIRS = po
localedir = $(datadir)/locale
diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c
index 678da620..f034131b 100644
--- a/lib/libalpm/add.c
+++ b/lib/libalpm/add.c
@@ -211,9 +211,12 @@ error:
}
-static int name_cmp(const void *p1, const void *p2)
+/* This is still messy. We have a lot of compare functions, and we should
+ * try to consolidate them as much as we can (between add and sync) */
+static int pkg_cmp(const void *p1, const void *p2)
{
- return(strcmp(((pmpkg_t *)p1)->name, (const char *)p2));
+ return(strcmp(((pmdepmissing_t *)p1)->target,
+ ((pmdepmissing_t *)p2)->target));
}
int _alpm_add_prepare(pmtrans_t *trans, pmdb_t *db, alpm_list_t **data)
@@ -253,11 +256,26 @@ int _alpm_add_prepare(pmtrans_t *trans, pmdb_t *db, alpm_list_t **data)
/* Attempt to resolve conflicts */
QUESTION(trans, PM_TRANS_CONV_CONFLICT_PKG, miss->target, miss->depend.name, NULL, &skip_this);
if(skip_this) {
- pmpkg_t **pkg = NULL;
- lp = alpm_list_remove(lp, (void *)miss->depend.name, name_cmp, (void **)pkg);
- FREEPKG(*pkg);
- }
- }
+ pmdepmissing_t *pkg = NULL;
+ lp = alpm_list_remove(lp, (void *)miss, pkg_cmp, (void*)&pkg);
+ /* TODO: We remove the conflict from the list but never actually remove
+ * the package. Need to do this to fix FS #3492. The sync code should
+ * provide an example of how to do this, as it handles replaces and
+ * removes. We run into problems because we do a file conflict check
+ * below and it fails there. A force flag will skip that part, but
+ * still not remove the original package designated here for removal.
+ * Better yet, dump all this shitty duplicate code and somehow combine
+ * it with the sync code. */
+ FREE(pkg);
+ if(lp == NULL) {
+ break;
+ }
+ }
+ }
+ /* Removal code should go here, as described above. Instead of simply
+ * removing items, perhaps throw them in another list to be removed, then
+ * proceed as sync.c would? I'm not sure because I'm not familiar enough
+ * with the codebase. */
if(lp != NULL) {
if(data) {
*data = lp;
diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c
index 0b4af443..0de9b930 100644
--- a/lib/libalpm/deps.c
+++ b/lib/libalpm/deps.c
@@ -106,6 +106,7 @@ alpm_list_t *_alpm_sortbydeps(alpm_list_t *targets, int mode)
int change = 1;
int numscans = 0;
int numtargs = 0;
+ int maxscans;
if(targets == NULL) {
return(NULL);
@@ -116,15 +117,13 @@ alpm_list_t *_alpm_sortbydeps(alpm_list_t *targets, int mode)
numtargs++;
}
+ maxscans = (int)sqrt(numtargs);
+
_alpm_log(PM_LOG_DEBUG, _("started sorting dependencies"));
while(change) {
alpm_list_t *tmptargs = NULL;
change = 0;
- /* TODO only use of a math.h function in entire libalpm,
- * can we get rid of it? Former code line:
- *if(numscans > numtargs) {
- */
- if(numscans > sqrt(numtargs)) {
+ if(numscans > maxscans) {
_alpm_log(PM_LOG_DEBUG, _("possible dependency cycle detected"));
continue;
}
@@ -321,9 +320,9 @@ alpm_list_t *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, pmtranstype_t op,
/* else if still not found... */
if(!found) {
_alpm_log(PM_LOG_DEBUG, _("checkdeps: found %s as a dependency for %s"),
- depend.name, tp->name);
+ depend.name, tp->name);
miss = _alpm_depmiss_new(tp->name, PM_DEP_TYPE_DEPEND, depend.mod,
- depend.name, depend.version);
+ depend.name, depend.version);
if(!_alpm_depmiss_isin(miss, baddeps)) {
baddeps = alpm_list_add(baddeps, miss);
} else {
diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c
index ce3bc85b..29d3ad56 100644
--- a/lib/libalpm/util.c
+++ b/lib/libalpm/util.c
@@ -359,8 +359,8 @@ int _alpm_logaction(unsigned short usesyslog, FILE *f, const char *str)
/* Use ISO-8601 date format */
fprintf(f, "[%04d-%02d-%02d %02d:%02d] %s\n",
- tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday,
- tm->tm_hour, tm->tm_min, str);
+ tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday,
+ tm->tm_hour, tm->tm_min, str);
fflush(f);
}