From dd0ee663045491fb1a95ccb0c0fb0dd0918122bf Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Sun, 21 Nov 2010 03:25:53 -0300 Subject: [PATCH] qpkg: give ID2S macro a more "offical" status - prereq.c (ID2S), id.h (ID2PF): renamed ID2S to ID2PF and moved it to id.h - prereq.c (push, satisfies, resolve): change ID2S to ID2PF --- qpkg/id.h | 8 ++++++++ qpkg/prereq.c | 11 ++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/qpkg/id.h b/qpkg/id.h index 0614266..ab4f78e 100644 --- a/qpkg/id.h +++ b/qpkg/id.h @@ -59,6 +59,14 @@ struct id { }; +/* + * Helper macro for printing identifiers. + * Use with "... %.*s ..." + */ + +#define ID2PF(id) (int) (id)->len, (id)->s + + int comp_id(const void *a, const void *b); struct tree *make_tree(int (*comp)(const void *a, const void *b)); diff --git a/qpkg/prereq.c b/qpkg/prereq.c index 05a7bdc..b12f2d6 100644 --- a/qpkg/prereq.c +++ b/qpkg/prereq.c @@ -36,9 +36,6 @@ static int n_stack = 0; static int stack_max = 0; -#define ID2S(id) (int) (id)->len, (id)->s - - static int epoch(const char **s, const struct id *id) { const char *end = id->s+id->len; @@ -114,7 +111,7 @@ static void done(void) static void push(struct pkg *pkg) { -//fprintf(stderr, "push %.*s\n", ID2S(pkg->id)); +//fprintf(stderr, "push %.*s\n", ID2PF(pkg->id)); if (n_stack == stack_max) { stack_max = (stack_max+1)*2; stack = realloc(stack, sizeof(*stack)*stack_max); @@ -149,7 +146,7 @@ static int satisfies(const struct pkg *pkg, const struct ref *ref) assert(pkg->version); cmp = comp_versions(pkg->version, ref->version); //fprintf(stderr, "%.*s <%d> %.*s\n", -// ID2S(pkg->version), cmp, ID2S(ref->version)); +// ID2PF(pkg->version), cmp, ID2PF(ref->version)); switch (ref->relop) { case rel_eq: return !cmp; @@ -193,9 +190,9 @@ static int level = 0; return; #if 0 fprintf(stderr, "%*s", level, ""); -fprintf(stderr, "%.*s %p", ID2S(pkg->id), pkg); +fprintf(stderr, "%.*s %p", ID2PF(pkg->id), pkg); if (pkg->version) -fprintf(stderr, " %.*s", ID2S(pkg->version)); +fprintf(stderr, " %.*s", ID2PF(pkg->version)); if (pkg->mark) fprintf(stderr, " +"); if (pkg->flags & QPKG_INSTALLED) fprintf(stderr, " ***"); fprintf(stderr, "\n");