]> git.wh0rd.org - patches.git/blob - qdepends.patch
more random patches. who knows.
[patches.git] / qdepends.patch
1 Index: qdepends.c
2 ===================================================================
3 RCS file: /var/cvsroot/gentoo-projects/portage-utils/qdepends.c,v
4 retrieving revision 1.38
5 diff -u -p -r1.38 qdepends.c
6 --- qdepends.c 5 Jun 2006 11:43:30 -0000 1.38
7 +++ qdepends.c 9 Oct 2006 21:14:34 -0000
8 @@ -336,6 +336,12 @@ char *dep_flatten_tree(dep_node *root)
9 static char flat[8192];
10 size_t pos = 0;
11 _dep_flatten_tree(root, flat, &pos);
12 + if (pos == 0) {
13 + /* all the nodes were squashed ... for example:
14 + * USE=-selinux RDEPEND="selinux? ( sys-libs/libselinux )"
15 + */
16 + return NULL;
17 + }
18 flat[pos-1] = '\0';
19 return flat;
20 }
21 @@ -383,6 +389,7 @@ int qdepends_main_vdb(const char *depend
22 if (i == argc)
23 continue;
24
25 + IF_DEBUG(warn("matched %s/%s", dentry->d_name, de->d_name));
26 snprintf(buf, sizeof(buf), "%s%s/%s/%s/%s", portroot, portvdb,
27 dentry->d_name, de->d_name, depend_file);
28
29 @@ -396,6 +403,7 @@ int qdepends_main_vdb(const char *depend
30 continue;
31 }
32
33 + IF_DEBUG(warn("growing tree..."));
34 dep_tree = dep_grow_tree(depend);
35 if (dep_tree == NULL) continue;
36 IF_DEBUG(puts(depend));
37 @@ -431,7 +439,8 @@ int qdepends_main_vdb(const char *depend
38 }
39
40 /*dep_dump_tree(dep_tree);*/
41 - printf("%s\n", dep_flatten_tree(dep_tree));
42 + ptr = dep_flatten_tree(dep_tree);
43 + printf("%s\n", (ptr == NULL ? "" : ptr));
44
45 dep_burn_tree(dep_tree);
46 }
47 @@ -470,16 +479,20 @@ int qdepends_vdb_deep(const char *depend
48 if (*de->d_name == '.')
49 continue;
50
51 + IF_DEBUG(warn("matched %s/%s", dentry->d_name, de->d_name));
52 snprintf(buf, sizeof(buf), "%s%s/%s/%s/%s", portroot, portvdb,
53 dentry->d_name, de->d_name, depend_file);
54 +
55 if (!eat_file(buf, depend, sizeof(depend))) {
56 warn("i'm such a fatty, could not eat_file(%s)", buf);
57 continue;
58 }
59 - IF_DEBUG(puts(depend));
60
61 + IF_DEBUG(warn("growing tree..."));
62 dep_tree = dep_grow_tree(depend);
63 if (dep_tree == NULL) continue;
64 + IF_DEBUG(puts(depend));
65 + IF_DEBUG(dep_dump_tree(dep_tree));
66
67 snprintf(buf, sizeof(buf), "%s%s/%s/%s/USE", portroot, portvdb,
68 dentry->d_name, de->d_name);
69 @@ -497,7 +510,7 @@ int qdepends_vdb_deep(const char *depend
70 dep_prune_use(dep_tree, use);
71
72 ptr = dep_flatten_tree(dep_tree);
73 - if (rematch(query, ptr, REG_EXTENDED) == 0) {
74 + if (ptr && rematch(query, ptr, REG_EXTENDED) == 0) {
75 if (qdep_name_only) {
76 depend_atom *atom = NULL;
77 snprintf(buf, sizeof(buf), "%s/%s", dentry->d_name, de->d_name);
78 @@ -509,7 +522,7 @@ int qdepends_vdb_deep(const char *depend
79 printf("%s%s/%s%s%s%c", BOLD, dentry->d_name, BLUE, de->d_name, NORM, verbose ? ':' : '\n');
80 }
81 if (verbose)
82 - printf(" %s\n", dep_flatten_tree(dep_tree));
83 + printf(" %s\n", ptr);
84 }
85 dep_burn_tree(dep_tree);
86 }