summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Woodward2019-07-05 16:44:43 +0000
committerJason Woodward2019-07-12 03:13:52 +0000
commit25c043e58dcffe6482a98357b594f3ec9ed8e22e (patch)
tree9c02827c2edf0b3aa7d2402d9dde996cd59e636b
parent260637cee49eb53a781b6ac242f33263274f54b8 (diff)
downloadslapt-get-25c043e58dcffe6482a98357b594f3ec9ed8e22e.tar.gz
make private pkg_compare available as slapt_pkg_info_t_qsort_cmp
-rw-r--r--src/package.c12
-rw-r--r--src/package.h3
2 files changed, 7 insertions, 8 deletions
diff --git a/src/package.c b/src/package.c
index 7875017..5d2c1be 100644
--- a/src/package.c
+++ b/src/package.c
@@ -23,8 +23,6 @@ struct slapt_pkg_version_parts {
uint32_t count;
};
-/* used by qsort */
-static int pkg_compare(const void *a, const void *b);
/* analyze the pkg version hunk by hunk */
static struct slapt_pkg_version_parts *break_down_pkg_version(const char *version);
/* parse the meta lines */
@@ -72,7 +70,7 @@ slapt_pkg_list_t *slapt_get_available_pkgs(void)
/* this is pointless to do if we wrote the data sorted, but this
ensures upgrades from older, presorting slapt-gets still work
as expected. */
- qsort(list->pkgs, list->pkg_count, sizeof(list->pkgs[0]), pkg_compare);
+ qsort(list->pkgs, list->pkg_count, sizeof(list->pkgs[0]), slapt_pkg_info_t_qsort_cmp);
list->ordered = true;
@@ -667,7 +665,7 @@ slapt_pkg_list_t *slapt_get_installed_pkgs(void)
list->free_pkgs = true;
- qsort(list->pkgs, list->pkg_count, sizeof(list->pkgs[0]), pkg_compare);
+ qsort(list->pkgs, list->pkg_count, sizeof(list->pkgs[0]), slapt_pkg_info_t_qsort_cmp);
list->ordered = true;
@@ -1996,7 +1994,7 @@ int slapt_update_pkg_cache(const slapt_rc_config *global_config)
if ((pkg_list_fh = slapt_open_file(SLAPT_PKG_LIST_L, "w+")) == NULL)
exit(EXIT_FAILURE);
- qsort(new_pkgs->pkgs, new_pkgs->pkg_count, sizeof(new_pkgs->pkgs[0]), pkg_compare);
+ qsort(new_pkgs->pkgs, new_pkgs->pkg_count, sizeof(new_pkgs->pkgs[0]), slapt_pkg_info_t_qsort_cmp);
slapt_write_pkg_data(NULL, pkg_list_fh, new_pkgs);
@@ -3259,7 +3257,7 @@ slapt_get_obsolete_pkgs(const slapt_rc_config *global_config,
return obsolete;
}
-static int pkg_compare(const void *a, const void *b)
+int slapt_pkg_info_t_qsort_cmp(const void *a, const void *b)
{
int cmp = 0;
@@ -3271,11 +3269,9 @@ static int pkg_compare(const void *a, const void *b)
if (cmp == 0) {
if ((cmp = strverscmp(pkg_a->version, pkg_b->version)) == 0) {
return strcmp(pkg_a->location, pkg_b->location);
-
} else {
return cmp;
}
-
} else {
return cmp;
}
diff --git a/src/package.h b/src/package.h
index ce92e12..685dbe3 100644
--- a/src/package.h
+++ b/src/package.h
@@ -319,3 +319,6 @@ char *slapt_get_pkg_filelist(const slapt_pkg_info_t *pkg);
caller responsible for freeing the returned data
*/
char *slapt_gen_package_log_dir_name(void);
+
+/* used by qsort */
+int slapt_pkg_info_t_qsort_cmp(const void *a, const void *b);