index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
-rw-r--r-- | src/util/Makefile.am | 5 | ||||
-rw-r--r-- | src/util/cleanupdelta.c | 10 | ||||
-rw-r--r-- | src/util/pacsort.c | 2 | ||||
-rw-r--r-- | src/util/pactree.c | 43 | ||||
-rw-r--r-- | src/util/testdb.c | 10 | ||||
-rw-r--r-- | src/util/testpkg.c | 2 |
diff --git a/src/util/Makefile.am b/src/util/Makefile.am index e4af56cf..2110781b 100644 --- a/src/util/Makefile.am +++ b/src/util/Makefile.am @@ -11,7 +11,10 @@ DEFS = -DLOCALEDIR=\"@localedir@\" \ -DDBPATH=\"$(dbpath)\" \ -DCACHEDIR=\"$(cachedir)\" \ @DEFS@ -INCLUDES = -I$(top_srcdir)/lib/libalpm + +AM_CPPFLAGS = \ + -imacros $(top_builddir)/config.h \ + -I$(top_srcdir)/lib/libalpm AM_CFLAGS = -pedantic -D_GNU_SOURCE diff --git a/src/util/cleanupdelta.c b/src/util/cleanupdelta.c index 6553e6f6..ea34fe7f 100644 --- a/src/util/cleanupdelta.c +++ b/src/util/cleanupdelta.c @@ -17,8 +17,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "config.h" - #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -56,10 +54,10 @@ static void checkpkgs(alpm_list_t *pkglist) { alpm_list_t *i, *j; for(i = pkglist; i; i = alpm_list_next(i)) { - alpm_pkg_t *pkg = alpm_list_getdata(i); + alpm_pkg_t *pkg = i->data; alpm_list_t *unused = alpm_pkg_unused_deltas(pkg); for(j = unused; j; j = alpm_list_next(j)) { - char *delta = alpm_list_getdata(j); + const char *delta = j->data; printf("%s\n", delta); } alpm_list_free(unused); @@ -72,7 +70,7 @@ static void checkdbs(alpm_list_t *dbnames) { const alpm_siglevel_t level = ALPM_SIG_DATABASE | ALPM_SIG_DATABASE_OPTIONAL; for(i = dbnames; i; i = alpm_list_next(i)) { - const char *dbname = alpm_list_getdata(i); + const char *dbname = i->data; db = alpm_db_register_sync(handle, dbname, level); if(db == NULL) { fprintf(stderr, "error: could not register sync database '%s' (%s)\n", @@ -94,7 +92,7 @@ static void usage(void) { int main(int argc, char *argv[]) { const char *dbpath = DBPATH; - enum _alpm_errno_t err; + alpm_errno_t err; int a = 1; alpm_list_t *dbnames = NULL; diff --git a/src/util/pacsort.c b/src/util/pacsort.c index 0eedf59d..7275cc77 100644 --- a/src/util/pacsort.c +++ b/src/util/pacsort.c @@ -17,8 +17,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "config.h" - #include <errno.h> #include <getopt.h> #include <stdio.h> diff --git a/src/util/pactree.c b/src/util/pactree.c index 997ba466..0adc2ea8 100644 --- a/src/util/pactree.c +++ b/src/util/pactree.c @@ -17,8 +17,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "config.h" - #include <ctype.h> #include <getopt.h> #include <stdio.h> @@ -119,13 +117,13 @@ char *strndup(const char *s, size_t n) } #endif -static char *strtrim(char *str) +static size_t strtrim(char *str) { - char *pch = str; + char *end, *pch = str; if(str == NULL || *str == '\0') { /* string is empty, so we're done. */ - return str; + return 0; } while(isspace((unsigned char)*pch)) { @@ -142,21 +140,21 @@ static char *strtrim(char *str) /* check if there wasn't anything but whitespace in the string. */ if(*str == '\0') { - return str; + return 0; } - pch = (str + (strlen(str) - 1)); - while(isspace((unsigned char)*pch)) { - pch--; + end = (str + strlen(str) - 1); + while(isspace((unsigned char)*end)) { + end--; } - *++pch = '\0'; + *++end = '\0'; - return str; + return end - pch; } static int register_syncs(void) { FILE *fp; - char *ptr, *section = NULL; + char *section = NULL; char line[LINE_MAX]; const alpm_siglevel_t level = ALPM_SIG_DATABASE | ALPM_SIG_DATABASE_OPTIONAL; @@ -167,20 +165,23 @@ static int register_syncs(void) { } while(fgets(line, LINE_MAX, fp)) { - strtrim(line); + size_t linelen; + char *ptr; + + linelen = strtrim(line); - if(line[0] == '#' || !strlen(line)) { + if(line[0] == '#' || !linelen) { continue; } if((ptr = strchr(line, '#'))) { *ptr = '\0'; - strtrim(line); + linelen = strtrim(line); } - if(line[0] == '[' && line[strlen(line) - 1] == ']') { + if(line[0] == '[' && line[linelen - 1] == ']') { free(section); - section = strndup(&line[1], strlen(line) - 2); + section = strndup(&line[1], linelen - 2); if(section && strcmp(section, "options") != 0) { alpm_db_register_sync(handle, section, level); @@ -363,7 +364,7 @@ static alpm_pkg_t *get_pkg_from_dbs(alpm_list_t *dbs, const char *needle) { alpm_pkg_t *ret; for(i = dbs; i; i = alpm_list_next(i)) { - ret = alpm_db_get_pkg(alpm_list_getdata(i), needle); + ret = alpm_db_get_pkg(i->data, needle); if(ret) { return ret; } @@ -386,7 +387,7 @@ static void walk_reverse_deps(alpm_list_t *dblist, alpm_pkg_t *pkg, int depth) required_by = alpm_pkg_compute_requiredby(pkg); for(i = required_by; i; i = alpm_list_next(i)) { - const char *pkgname = alpm_list_getdata(i); + const char *pkgname = i->data; if(alpm_list_find_str(walked, pkgname)) { /* if we've already seen this package, don't print in "unique" output @@ -417,7 +418,7 @@ static void walk_deps(alpm_list_t *dblist, alpm_pkg_t *pkg, int depth) walked = alpm_list_add(walked, (void *)alpm_pkg_get_name(pkg)); for(i = alpm_pkg_get_depends(pkg); i; i = alpm_list_next(i)) { - alpm_depend_t *depend = alpm_list_getdata(i); + alpm_depend_t *depend = i->data; alpm_pkg_t *provider = alpm_find_dbs_satisfier(handle, dblist, depend->name); if(provider) { @@ -443,7 +444,7 @@ static void walk_deps(alpm_list_t *dblist, alpm_pkg_t *pkg, int depth) int main(int argc, char *argv[]) { int freelist = 0, ret = 0; - enum _alpm_errno_t err; + alpm_errno_t err; const char *target_name; alpm_pkg_t *pkg; alpm_list_t *dblist = NULL; diff --git a/src/util/testdb.c b/src/util/testdb.c index d85687a4..4f6bfed5 100644 --- a/src/util/testdb.c +++ b/src/util/testdb.c @@ -17,8 +17,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "config.h" - #include <unistd.h> #include <stdio.h> #include <stdlib.h> @@ -101,7 +99,7 @@ static int checkdeps(alpm_list_t *pkglist) /* check dependencies */ data = alpm_checkdeps(handle, pkglist, NULL, pkglist, 0); for(i = data; i; i = alpm_list_next(i)) { - alpm_depmissing_t *miss = alpm_list_getdata(i); + alpm_depmissing_t *miss = i->data; char *depstring = alpm_dep_compute_string(miss->depend); printf("missing dependency for %s : %s\n", miss->target, depstring); @@ -119,7 +117,7 @@ static int checkconflicts(alpm_list_t *pkglist) /* check conflicts */ data = alpm_checkconflicts(handle, pkglist); for(i = data; i; i = i->next) { - alpm_conflict_t *conflict = alpm_list_getdata(i); + alpm_conflict_t *conflict = i->data; printf("%s conflicts with %s\n", conflict->package1, conflict->package2); ret++; @@ -154,7 +152,7 @@ static int check_syncdbs(alpm_list_t *dbnames) const alpm_siglevel_t level = ALPM_SIG_DATABASE | ALPM_SIG_DATABASE_OPTIONAL; for(i = dbnames; i; i = alpm_list_next(i)) { - char *dbname = alpm_list_getdata(i); + const char *dbname = i->data; db = alpm_db_register_sync(handle, dbname, level); if(db == NULL) { fprintf(stderr, "error: could not register sync database (%s)\n", @@ -185,7 +183,7 @@ static void usage(void) int main(int argc, char *argv[]) { int ret = 0; - enum _alpm_errno_t err; + alpm_errno_t err; const char *dbpath = DBPATH; int a = 1; alpm_list_t *dbnames = NULL; diff --git a/src/util/testpkg.c b/src/util/testpkg.c index 90758e16..6385e417 100644 --- a/src/util/testpkg.c +++ b/src/util/testpkg.c @@ -41,7 +41,7 @@ int main(int argc, char *argv[]) { int retval = 1; /* default = false */ alpm_handle_t *handle; - enum _alpm_errno_t err; + alpm_errno_t err; alpm_pkg_t *pkg = NULL; const alpm_siglevel_t level = ALPM_SIG_PACKAGE | ALPM_SIG_PACKAGE_OPTIONAL; |