summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Gregory <andrew.gregory.8@gmail.com>2012-10-15 14:29:08 -0400
committerAllan McRae <allan@archlinux.org>2012-11-27 15:16:15 +1000
commite1fdcfb145aa45eb1115ba400587cfed5eaf5455 (patch)
treee2c478b9a7d27440e0d4a4ef5833f6d4b57f1679 /src
parentc4c5b8ba1d191bcde65eb09c9ce30b18c4619a35 (diff)
pactree: style last branch node differently
Also removes the less helpful provides-specific branch tip. Old: New: |--pkg |--pkg +--dep1 provides dep5 |--dep1 provides dep5 | |--dep2 | `--dep2 |--dep3 `--dep3 |--dep4 `--dep4 [dreisner@archlinux.org: switch original suggestion of \-- to `--] Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'src')
-rw-r--r--src/util/pactree.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/src/util/pactree.c b/src/util/pactree.c
index ab5d90a1..4984a12e 100644
--- a/src/util/pactree.c
+++ b/src/util/pactree.c
@@ -36,8 +36,8 @@ typedef struct tdepth {
/* output */
struct graph_style {
const char *provides;
- const char *tip1;
- const char *tip2;
+ const char *tip;
+ const char *last;
const char *limb;
int indent;
};
@@ -45,7 +45,7 @@ struct graph_style {
static struct graph_style graph_default = {
" provides",
"|--",
- "+--",
+ "`--",
"|",
3
};
@@ -301,8 +301,10 @@ static void cleanup(void)
}
/* pkg provides provision */
-static void print_text(const char *pkg, const char *provision, tdepth *depth)
+static void print_text(const char *pkg, const char *provision,
+ tdepth *depth, int last)
{
+ const char* tip = last ? style->last : style->tip;
if(!pkg && !provision) {
/* not much we can do */
return;
@@ -323,14 +325,14 @@ static void print_text(const char *pkg, const char *provision, tdepth *depth)
/* print tip */
if(!pkg && provision) {
- printf("%s%s%s%s [unresolvable]%s\n", style->tip1, color->leaf1,
+ printf("%s%s%s%s [unresolvable]%s\n", tip, color->leaf1,
provision, color->branch1, color->off);
} else if(provision && strcmp(pkg, provision) != 0) {
- printf("%s%s%s%s%s %s%s%s\n", style->tip2, color->leaf1, pkg,
+ printf("%s%s%s%s%s %s%s%s\n", tip, color->leaf1, pkg,
color->leaf2, style->provides, color->leaf1, provision,
color->off);
} else {
- printf("%s%s%s%s\n", style->tip1, color->leaf1, pkg, color->off);
+ printf("%s%s%s%s\n", tip, color->leaf1, pkg, color->off);
}
}
@@ -348,12 +350,13 @@ static void print_graph(const char *parentname, const char *pkgname, const char
}
/* parent depends on dep which is satisfied by pkg */
-static void print(const char *parentname, const char *pkgname, const char *depname, tdepth *depth)
+static void print(const char *parentname, const char *pkgname,
+ const char *depname, tdepth *depth, int last)
{
if(graphviz) {
print_graph(parentname, pkgname, depname);
} else {
- print_text(pkgname, depname, depth);
+ print_text(pkgname, depname, depth, last);
}
}
@@ -369,7 +372,7 @@ static void print_start(const char *pkgname, const char *provname)
NULL,
0
};
- print_text(pkgname, provname, &d);
+ print_text(pkgname, provname, &d, 0);
}
}
@@ -412,6 +415,7 @@ static void walk_deps(alpm_list_t *dblist, alpm_pkg_t *pkg, tdepth *depth, int r
for(i = deps; i; i = alpm_list_next(i)) {
const char *pkgname = i->data;
+ int last = alpm_list_next(i) ? 0 : 1;
alpm_pkg_t *dep_pkg = alpm_find_dbs_satisfier(handle, dblist, pkgname);
@@ -419,10 +423,10 @@ static void walk_deps(alpm_list_t *dblist, alpm_pkg_t *pkg, tdepth *depth, int r
/* if we've already seen this package, don't print in "unique" output
* and don't recurse */
if(!unique) {
- print(alpm_pkg_get_name(pkg), alpm_pkg_get_name(dep_pkg), pkgname, depth);
+ print(alpm_pkg_get_name(pkg), alpm_pkg_get_name(dep_pkg), pkgname, depth, last);
}
} else {
- print(alpm_pkg_get_name(pkg), alpm_pkg_get_name(dep_pkg), pkgname, depth);
+ print(alpm_pkg_get_name(pkg), alpm_pkg_get_name(dep_pkg), pkgname, depth, last);
if(dep_pkg) {
tdepth d = {
depth,
@@ -431,7 +435,7 @@ static void walk_deps(alpm_list_t *dblist, alpm_pkg_t *pkg, tdepth *depth, int r
};
depth->next = &d;
/* last dep, cut off the limb here */
- if(!alpm_list_next(i)){
+ if(last){
if(depth->prev){
depth->prev->next = &d;
d.prev = depth->prev;