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");