public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] gentoo-projects commit in portage-utils: qdepends.c
@ 2008-03-14 23:24 Ned Ludd (solar)
  0 siblings, 0 replies; 11+ messages in thread
From: Ned Ludd (solar) @ 2008-03-14 23:24 UTC (permalink / raw
  To: gentoo-commits

solar       08/03/14 23:24:47

  Modified:             qdepends.c
  Log:
  - dont puke with the -Q option when the vdb/USE file does not exist.

Revision  Changes    Path
1.47                 portage-utils/qdepends.c

file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/qdepends.c?rev=1.47&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/qdepends.c?rev=1.47&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/qdepends.c?r1=1.46&r2=1.47

Index: qdepends.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/qdepends.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -r1.46 -r1.47
--- qdepends.c	24 May 2007 14:47:18 -0000	1.46
+++ qdepends.c	14 Mar 2008 23:24:47 -0000	1.47
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2007 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qdepends.c,v 1.46 2007/05/24 14:47:18 solar Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qdepends.c,v 1.47 2008/03/14 23:24:47 solar Exp $
  *
  * Copyright 2005-2007 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2007 Mike Frysinger  - <vapier@gentoo.org>
@@ -30,7 +30,7 @@
 	"Show all DEPEND info",
 	COMMON_OPTS_HELP
 };
-static const char qdepends_rcsid[] = "$Id: qdepends.c,v 1.46 2007/05/24 14:47:18 solar Exp $";
+static const char qdepends_rcsid[] = "$Id: qdepends.c,v 1.47 2008/03/14 23:24:47 solar Exp $";
 #define qdepends_usage(ret) usage(ret, QDEPENDS_FLAGS, qdepends_long_opts, qdepends_opts_help, lookup_applet_idx("qdepends"))
 
 static char qdep_name_only = 0;
@@ -504,7 +504,10 @@
 
 			snprintf(buf, sizeof(buf), "%s%s/%s/%s/USE", portroot, portvdb,
 			         dentry->d_name, de->d_name);
-			assert(eat_file(buf, use, sizeof(use)) == 1);
+
+			if (eat_file(buf, use, sizeof(use)) == 1)
+				use[0] = ' ';
+
 			for (ptr = use; *ptr; ++ptr)
 				if (*ptr == '\n' || *ptr == '\t')
 					*ptr = ' ';



-- 
gentoo-commits@lists.gentoo.org mailing list



^ permalink raw reply	[flat|nested] 11+ messages in thread

* [gentoo-commits] gentoo-projects commit in portage-utils: qdepends.c
@ 2009-08-29 19:43 Ned Ludd (solar)
  0 siblings, 0 replies; 11+ messages in thread
From: Ned Ludd (solar) @ 2009-08-29 19:43 UTC (permalink / raw
  To: gentoo-commits

solar       09/08/29 19:43:14

  Modified:             qdepends.c
  Log:
  - fix crash in qdepends. Bug 263892

Revision  Changes    Path
1.48                 portage-utils/qdepends.c

file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/qdepends.c?rev=1.48&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/qdepends.c?rev=1.48&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/qdepends.c?r1=1.47&r2=1.48

Index: qdepends.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/qdepends.c,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -r1.47 -r1.48
--- qdepends.c	14 Mar 2008 23:24:47 -0000	1.47
+++ qdepends.c	29 Aug 2009 19:43:14 -0000	1.48
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2007 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qdepends.c,v 1.47 2008/03/14 23:24:47 solar Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qdepends.c,v 1.48 2009/08/29 19:43:14 solar Exp $
  *
  * Copyright 2005-2007 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2007 Mike Frysinger  - <vapier@gentoo.org>
@@ -30,7 +30,7 @@
 	"Show all DEPEND info",
 	COMMON_OPTS_HELP
 };
-static const char qdepends_rcsid[] = "$Id: qdepends.c,v 1.47 2008/03/14 23:24:47 solar Exp $";
+static const char qdepends_rcsid[] = "$Id: qdepends.c,v 1.48 2009/08/29 19:43:14 solar Exp $";
 #define qdepends_usage(ret) usage(ret, QDEPENDS_FLAGS, qdepends_long_opts, qdepends_opts_help, lookup_applet_idx("qdepends"))
 
 static char qdep_name_only = 0;
@@ -293,10 +293,11 @@
 {
 	if (root->neighbor) dep_prune_use(root->neighbor, use);
 	if (root->type == DEP_USE) {
-		char useflag[40+3]; /* use flags shouldnt be longer than 40 ... */
+		char *useflag = NULL;
 		int notfound, invert = (root->info[0] == '!' ? 1 : 0);
-		sprintf(useflag, " %s ", root->info+invert);
+		xasprintf(&useflag, " %s ", root->info+invert);
 		notfound = (strstr(use, useflag) == NULL ? 1 : 0);
+		free(useflag);
 		if (notfound ^ invert) {
 			root->type = DEP_NULL;
 			return;






^ permalink raw reply	[flat|nested] 11+ messages in thread

* [gentoo-commits] gentoo-projects commit in portage-utils: qdepends.c
@ 2011-12-21 21:54 Mike Frysinger (vapier)
  0 siblings, 0 replies; 11+ messages in thread
From: Mike Frysinger (vapier) @ 2011-12-21 21:54 UTC (permalink / raw
  To: gentoo-commits

vapier      11/12/21 21:54:45

  Modified:             qdepends.c
  Log:
  do not warn if we could not eat the depends file since it might not exist in which case we do not care #395591 by Tomasz Wasiak

Revision  Changes    Path
1.56                 portage-utils/qdepends.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qdepends.c?rev=1.56&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qdepends.c?rev=1.56&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qdepends.c?r1=1.55&r2=1.56

Index: qdepends.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/qdepends.c,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -r1.55 -r1.56
--- qdepends.c	19 Dec 2011 04:28:35 -0000	1.55
+++ qdepends.c	21 Dec 2011 21:54:44 -0000	1.56
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2010 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qdepends.c,v 1.55 2011/12/19 04:28:35 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qdepends.c,v 1.56 2011/12/21 21:54:44 vapier Exp $
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2010 Mike Frysinger  - <vapier@gentoo.org>
@@ -30,7 +30,7 @@
 	"Show all DEPEND info",
 	COMMON_OPTS_HELP
 };
-static const char qdepends_rcsid[] = "$Id: qdepends.c,v 1.55 2011/12/19 04:28:35 vapier Exp $";
+static const char qdepends_rcsid[] = "$Id: qdepends.c,v 1.56 2011/12/21 21:54:44 vapier Exp $";
 #define qdepends_usage(ret) usage(ret, QDEPENDS_FLAGS, qdepends_long_opts, qdepends_opts_help, lookup_applet_idx("qdepends"))
 
 static char qdep_name_only = 0;
@@ -375,11 +375,8 @@
 
 	IF_DEBUG(warn("matched %s/%s", catname, pkgname));
 
-	if (!eat_file_at(pkg_ctx->fd, state->depend_file, depend, sizeof(depend))) {
-		warn("i'm such a fatty, could not eat_file(%s) with %zi bytes",
-			state->depend_file, sizeof(depend));
+	if (!eat_file_at(pkg_ctx->fd, state->depend_file, depend, sizeof(depend)))
 		return 0;
-	}
 
 	IF_DEBUG(warn("growing tree..."));
 	dep_tree = dep_grow_tree(depend);
@@ -437,10 +434,8 @@
 
 	IF_DEBUG(warn("matched %s/%s", catname, pkgname));
 
-	if (!eat_file_at(pkg_ctx->fd, state->depend_file, depend, sizeof(depend))) {
-		warn("i'm such a fatty, could not eat_file(%s)", state->depend_file);
+	if (!eat_file_at(pkg_ctx->fd, state->depend_file, depend, sizeof(depend)))
 		return 0;
-	}
 
 	IF_DEBUG(warn("growing tree..."));
 	dep_tree = dep_grow_tree(depend);






^ permalink raw reply	[flat|nested] 11+ messages in thread

* [gentoo-commits] gentoo-projects commit in portage-utils: qdepends.c
@ 2012-11-10  6:35 Mike Frysinger (vapier)
  0 siblings, 0 replies; 11+ messages in thread
From: Mike Frysinger (vapier) @ 2012-11-10  6:35 UTC (permalink / raw
  To: gentoo-commits

vapier      12/11/10 06:35:21

  Modified:             qdepends.c
  Log:
  qdepends: fix by Andreas Fink for --all handling #440048

Revision  Changes    Path
1.57                 portage-utils/qdepends.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qdepends.c?rev=1.57&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qdepends.c?rev=1.57&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qdepends.c?r1=1.56&r2=1.57

Index: qdepends.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/qdepends.c,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -r1.56 -r1.57
--- qdepends.c	21 Dec 2011 21:54:44 -0000	1.56
+++ qdepends.c	10 Nov 2012 06:35:21 -0000	1.57
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2010 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qdepends.c,v 1.56 2011/12/21 21:54:44 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qdepends.c,v 1.57 2012/11/10 06:35:21 vapier Exp $
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2010 Mike Frysinger  - <vapier@gentoo.org>
@@ -30,7 +30,7 @@
 	"Show all DEPEND info",
 	COMMON_OPTS_HELP
 };
-static const char qdepends_rcsid[] = "$Id: qdepends.c,v 1.56 2011/12/21 21:54:44 vapier Exp $";
+static const char qdepends_rcsid[] = "$Id: qdepends.c,v 1.57 2012/11/10 06:35:21 vapier Exp $";
 #define qdepends_usage(ret) usage(ret, QDEPENDS_FLAGS, qdepends_long_opts, qdepends_opts_help, lookup_applet_idx("qdepends"))
 
 static char qdep_name_only = 0;
@@ -520,6 +520,7 @@
 		int ret = 0;
 		for (i = 0; depend_files[i]; ++i) {
 			printf(" %s*%s %s\n", GREEN, NORM, depend_files[i]);
+			state.depend_file = depend_files[i];
 			ret += q_vdb_foreach_pkg(cb, &state, NULL);
 		}
 		return ret;





^ permalink raw reply	[flat|nested] 11+ messages in thread

* [gentoo-commits] gentoo-projects commit in portage-utils: qdepends.c
@ 2013-09-29  5:09 Mike Frysinger (vapier)
  0 siblings, 0 replies; 11+ messages in thread
From: Mike Frysinger (vapier) @ 2013-09-29  5:09 UTC (permalink / raw
  To: gentoo-commits

vapier      13/09/29 05:09:29

  Modified:             qdepends.c
  Log:
  qdepends: use xzalloc

Revision  Changes    Path
1.58                 portage-utils/qdepends.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qdepends.c?rev=1.58&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qdepends.c?rev=1.58&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qdepends.c?r1=1.57&r2=1.58

Index: qdepends.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/qdepends.c,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -r1.57 -r1.58
--- qdepends.c	10 Nov 2012 06:35:21 -0000	1.57
+++ qdepends.c	29 Sep 2013 05:09:29 -0000	1.58
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2010 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qdepends.c,v 1.57 2012/11/10 06:35:21 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qdepends.c,v 1.58 2013/09/29 05:09:29 vapier Exp $
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2010 Mike Frysinger  - <vapier@gentoo.org>
@@ -30,7 +30,7 @@
 	"Show all DEPEND info",
 	COMMON_OPTS_HELP
 };
-static const char qdepends_rcsid[] = "$Id: qdepends.c,v 1.57 2012/11/10 06:35:21 vapier Exp $";
+static const char qdepends_rcsid[] = "$Id: qdepends.c,v 1.58 2013/09/29 05:09:29 vapier Exp $";
 #define qdepends_usage(ret) usage(ret, QDEPENDS_FLAGS, qdepends_long_opts, qdepends_opts_help, lookup_applet_idx("qdepends"))
 
 static char qdep_name_only = 0;
@@ -96,8 +96,7 @@
 			info_len = strlen(info);
 		len += info_len + 1;
 	}
-	ret = xmalloc(len);
-	memset(ret, 0x00, len);
+	ret = xzalloc(len);
 
 	ret->type = type;
 	if (info) {





^ permalink raw reply	[flat|nested] 11+ messages in thread

* [gentoo-commits] gentoo-projects commit in portage-utils: qdepends.c
@ 2013-09-29  6:44 Mike Frysinger (vapier)
  0 siblings, 0 replies; 11+ messages in thread
From: Mike Frysinger (vapier) @ 2013-09-29  6:44 UTC (permalink / raw
  To: gentoo-commits

vapier      13/09/29 06:44:39

  Modified:             qdepends.c
  Log:
  qdepends: constify args

Revision  Changes    Path
1.59                 portage-utils/qdepends.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qdepends.c?rev=1.59&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qdepends.c?rev=1.59&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qdepends.c?r1=1.58&r2=1.59

Index: qdepends.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/qdepends.c,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -r1.58 -r1.59
--- qdepends.c	29 Sep 2013 05:09:29 -0000	1.58
+++ qdepends.c	29 Sep 2013 06:44:39 -0000	1.59
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2010 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qdepends.c,v 1.58 2013/09/29 05:09:29 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qdepends.c,v 1.59 2013/09/29 06:44:39 vapier Exp $
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2010 Mike Frysinger  - <vapier@gentoo.org>
@@ -30,7 +30,7 @@
 	"Show all DEPEND info",
 	COMMON_OPTS_HELP
 };
-static const char qdepends_rcsid[] = "$Id: qdepends.c,v 1.58 2013/09/29 05:09:29 vapier Exp $";
+static const char qdepends_rcsid[] = "$Id: qdepends.c,v 1.59 2013/09/29 06:44:39 vapier Exp $";
 #define qdepends_usage(ret) usage(ret, QDEPENDS_FLAGS, qdepends_long_opts, qdepends_opts_help, lookup_applet_idx("qdepends"))
 
 static char qdep_name_only = 0;
@@ -43,9 +43,7 @@
 	DEP_OR = 3,
 	DEP_GROUP = 4
 } dep_type;
-#ifdef EBUG
 static const char * const _dep_names[] = { "NULL", "NORM", "USE", "OR", "GROUP" };
-#endif
 
 struct _dep_node {
 	dep_type type;
@@ -60,21 +58,17 @@
 
 /* prototypes */
 #define dep_dump_tree(r) _dep_dump_tree(r,0)
-void _dep_dump_tree(dep_node *root, int space);
-dep_node *dep_grow_tree(char *depend);
+_q_static void _dep_dump_tree(const dep_node *root, int space);
 void dep_burn_tree(dep_node *root);
-void dep_prune_use(dep_node *root, char *use);
-char *dep_flatten_tree(dep_node *root);
-dep_node *_dep_grow_node(dep_type type, char *info, size_t info_len);
-void _dep_attach(dep_node *root, dep_node *attach_me, int type);
-void _dep_flatten_tree(dep_node *root, char *buf, size_t *pos);
-void _dep_burn_node(dep_node *node);
+char *dep_flatten_tree(const dep_node *root);
+_q_static void _dep_attach(dep_node *root, dep_node *attach_me, int type);
+_q_static void _dep_flatten_tree(const dep_node *root, char *buf, size_t *pos);
+_q_static void _dep_burn_node(dep_node *node);
 int qdepends_main_vdb(const char *depend_file, int argc, char **argv);
 int qdepends_vdb_deep(const char *depend_file, const char *query);
 
 #ifdef EBUG
-void print_word(char *ptr, int num);
-void print_word(char *ptr, int num)
+_q_static void print_word(const char *ptr, size_t num)
 {
 	while (num--)
 		printf("%c", *ptr++);
@@ -82,7 +76,8 @@
 }
 #endif
 
-dep_node *_dep_grow_node(dep_type type, char *info, size_t info_len)
+_q_static dep_node *
+_dep_grow_node(dep_type type, const char *info, size_t info_len)
 {
 	dep_node *ret;
 	size_t len;
@@ -139,10 +134,10 @@
 	}
 }
 
-dep_node *dep_grow_tree(char *depend)
+_q_static dep_node *dep_grow_tree(const char *depend)
 {
 	signed long paren_balanced;
-	char *word, *ptr, *p;
+	const char *ptr, *word;
 	int curr_attach;
 	dep_node *ret, *curr_node, *new_node;
 	dep_type prev_type;
@@ -153,9 +148,6 @@
 	curr_attach = _DEP_NEIGH;
 	word = NULL;
 
-	p = strrchr(depend, '\n');
-	if (p != NULL) *p = 0;
-
 #define _maybe_consume_word(t) \
 	do { \
 	if (!word) break; \
@@ -259,9 +251,12 @@
 	return NULL;
 }
 
-#ifdef EBUG
-void _dep_dump_tree(dep_node *root, int space)
+_q_static void _dep_dump_tree(const dep_node *root, int space)
 {
+#ifndef EBUG
+	return;
+#endif
+
 	int spaceit = space;
 	assert(root);
 	if (root->type == DEP_NULL) goto this_node_sucks;
@@ -276,9 +271,6 @@
 this_node_sucks:
 	if (root->neighbor) _dep_dump_tree(root->neighbor, space);
 }
-#else
-void _dep_dump_tree(_q_unused_ dep_node *root, _q_unused_ int space) {;}
-#endif
 
 void dep_burn_tree(dep_node *root)
 {
@@ -288,7 +280,7 @@
 	_dep_burn_node(root);
 }
 
-void dep_prune_use(dep_node *root, char *use)
+_q_static void dep_prune_use(dep_node *root, const char *use)
 {
 	if (root->neighbor) dep_prune_use(root->neighbor, use);
 	if (root->type == DEP_USE) {
@@ -305,7 +297,7 @@
 	if (root->children) dep_prune_use(root->children, use);
 }
 
-void _dep_flatten_tree(dep_node *root, char *buf, size_t *pos)
+void _dep_flatten_tree(const dep_node *root, char *buf, size_t *pos)
 {
 	if (root->type == DEP_NULL) goto this_node_sucks;
 	if (root->type == DEP_NORM) {
@@ -327,7 +319,7 @@
 	if (root->neighbor) _dep_flatten_tree(root->neighbor, buf, pos);
 }
 
-char *dep_flatten_tree(dep_node *root)
+char *dep_flatten_tree(const dep_node *root)
 {
 	static char flat[8192];
 	size_t pos = 0;





^ permalink raw reply	[flat|nested] 11+ messages in thread

* [gentoo-commits] gentoo-projects commit in portage-utils: qdepends.c
@ 2013-09-29  9:14 Mike Frysinger (vapier)
  0 siblings, 0 replies; 11+ messages in thread
From: Mike Frysinger (vapier) @ 2013-09-29  9:14 UTC (permalink / raw
  To: gentoo-commits

vapier      13/09/29 09:14:14

  Modified:             qdepends.c
  Log:
  qdepends: add a --format mode to make testing easier

Revision  Changes    Path
1.60                 portage-utils/qdepends.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qdepends.c?rev=1.60&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qdepends.c?rev=1.60&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qdepends.c?r1=1.59&r2=1.60

Index: qdepends.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/qdepends.c,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -r1.59 -r1.60
--- qdepends.c	29 Sep 2013 06:44:39 -0000	1.59
+++ qdepends.c	29 Sep 2013 09:14:14 -0000	1.60
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2010 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qdepends.c,v 1.59 2013/09/29 06:44:39 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qdepends.c,v 1.60 2013/09/29 09:14:14 vapier Exp $
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2010 Mike Frysinger  - <vapier@gentoo.org>
@@ -9,7 +9,7 @@
 
 #ifdef APPLET_qdepends
 
-#define QDEPENDS_FLAGS "drpaNk:Q:" COMMON_FLAGS
+#define QDEPENDS_FLAGS "drpafNk:Q:" COMMON_FLAGS
 static struct option const qdepends_long_opts[] = {
 	{"depend",    no_argument, NULL, 'd'},
 	{"rdepend",   no_argument, NULL, 'r'},
@@ -18,6 +18,7 @@
 	{"query",      a_argument, NULL, 'Q'},
 	{"name-only", no_argument, NULL, 'N'},
 	{"all",       no_argument, NULL, 'a'},
+	{"format",    no_argument, NULL, 'f'},
 	COMMON_LONG_OPTS
 };
 static const char * const qdepends_opts_help[] = {
@@ -28,9 +29,10 @@
 	"Query reverse deps",
 	"Only show package name",
 	"Show all DEPEND info",
+	"Pretty format specified depend strings",
 	COMMON_OPTS_HELP
 };
-static const char qdepends_rcsid[] = "$Id: qdepends.c,v 1.59 2013/09/29 06:44:39 vapier Exp $";
+static const char qdepends_rcsid[] = "$Id: qdepends.c,v 1.60 2013/09/29 09:14:14 vapier Exp $";
 #define qdepends_usage(ret) usage(ret, QDEPENDS_FLAGS, qdepends_long_opts, qdepends_opts_help, lookup_applet_idx("qdepends"))
 
 static char qdep_name_only = 0;
@@ -57,8 +59,12 @@
 typedef struct _dep_node dep_node;
 
 /* prototypes */
-#define dep_dump_tree(r) _dep_dump_tree(r,0)
-_q_static void _dep_dump_tree(const dep_node *root, int space);
+#ifdef NDEBUG
+# define dep_dump_tree(r)
+#else
+# define dep_dump_tree(r) _dep_print_tree(stdout, r, 0)
+#endif
+_q_static void _dep_print_tree(FILE *fp, const dep_node *root, size_t space);
 void dep_burn_tree(dep_node *root);
 char *dep_flatten_tree(const dep_node *root);
 _q_static void _dep_attach(dep_node *root, dep_node *attach_me, int type);
@@ -251,25 +257,57 @@
 	return NULL;
 }
 
-_q_static void _dep_dump_tree(const dep_node *root, int space)
+_q_static void _dep_print_tree(FILE *fp, const dep_node *root, size_t space)
 {
-#ifndef EBUG
-	return;
-#endif
+	size_t s;
 
-	int spaceit = space;
 	assert(root);
-	if (root->type == DEP_NULL) goto this_node_sucks;
+	if (root->type == DEP_NULL)
+		goto this_node_sucks;
+
+	for (s = space; s; --s)
+		fprintf(fp, "\t");
 
-	while (spaceit--) printf("\t");
-	printf("Node [%s]: ", _dep_names[root->type]);
+	if (verbose > 1)
+		fprintf(fp, "Node [%s]: ", _dep_names[root->type]);
 	/*printf("Node %p [%s] %p %p %p: ", root, _dep_names[root->type], root->parent, root->neighbor, root->children);*/
-	if (root->info) printf("'%s'", root->info);
-	printf("\n");
+	if (root->type == DEP_OR)
+		fprintf(fp, "|| (");
+	if (root->info) {
+		fprintf(fp, "%s", root->info);
+		/* If there is only one child, be nice to one-line: foo? ( pkg ) */
+		if (root->type == DEP_USE)
+			fprintf(fp, "? (");
+	}
+	fprintf(fp, "\n");
 
-	if (root->children) _dep_dump_tree(root->children, space+1);
-this_node_sucks:
-	if (root->neighbor) _dep_dump_tree(root->neighbor, space);
+	if (root->children)
+		_dep_print_tree(fp, root->children, space+1);
+
+	if (root->type == DEP_OR || root->type == DEP_USE) {
+		for (s = space; s; --s)
+			fprintf(fp, "\t");
+		fprintf(fp, ")\n");
+	}
+ this_node_sucks:
+	if (root->neighbor)
+		_dep_print_tree(fp, root->neighbor, space);
+}
+
+_q_static void dep_print_depend(FILE *fp, const char *depend)
+{
+	dep_node *dep_tree = dep_grow_tree(depend);
+	if (dep_tree == NULL)
+		return;
+
+	if (!quiet)
+		fprintf(fp, "DEPEND=\"\n");
+
+	_dep_print_tree(fp, dep_tree, 1);
+
+	dep_burn_tree(dep_tree);
+	if (!quiet)
+		fprintf(fp, "\"\n");
 }
 
 void dep_burn_tree(dep_node *root)
@@ -478,6 +516,7 @@
 	};
 	q_vdb_pkg_cb *cb;
 	int i;
+	bool do_format = false;
 	const char *query = NULL;
 	const char *depend_file;
 	const char *depend_files[] = { "DEPEND", "RDEPEND", "PDEPEND", NULL, NULL };
@@ -498,11 +537,21 @@
 		case 'a': depend_file = NULL; break;
 		case 'Q': query = optarg; break;
 		case 'N': qdep_name_only = 1; break;
+		case 'f': do_format = true; break;
 		}
 	}
-	if ((argc == optind) && (query == NULL))
+	if ((argc == optind) && (query == NULL) && !do_format)
 		qdepends_usage(EXIT_FAILURE);
 
+	if (do_format) {
+		while (optind < argc) {
+			dep_print_depend(stdout, argv[optind++]);
+			if (optind < argc)
+				fprintf(stdout, "\n");
+		}
+		return EXIT_SUCCESS;
+	}
+
 	state.depend_file = depend_file;
 	state.query = query;
 	cb = query ? qdepends_vdb_deep_cb : qdepends_main_vdb_cb;





^ permalink raw reply	[flat|nested] 11+ messages in thread

* [gentoo-commits] gentoo-projects commit in portage-utils: qdepends.c
@ 2013-09-29 10:01 Mike Frysinger (vapier)
  0 siblings, 0 replies; 11+ messages in thread
From: Mike Frysinger (vapier) @ 2013-09-29 10:01 UTC (permalink / raw
  To: gentoo-commits

vapier      13/09/29 10:01:55

  Modified:             qdepends.c
  Log:
  qdepends: pass back an empty node when parsing is OK so -f can exit appropriately

Revision  Changes    Path
1.61                 portage-utils/qdepends.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qdepends.c?rev=1.61&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qdepends.c?rev=1.61&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qdepends.c?r1=1.60&r2=1.61

Index: qdepends.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/qdepends.c,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -r1.60 -r1.61
--- qdepends.c	29 Sep 2013 09:14:14 -0000	1.60
+++ qdepends.c	29 Sep 2013 10:01:55 -0000	1.61
@@ -1,10 +1,10 @@
 /*
- * Copyright 2005-2010 Gentoo Foundation
+ * Copyright 2005-2013 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qdepends.c,v 1.60 2013/09/29 09:14:14 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qdepends.c,v 1.61 2013/09/29 10:01:55 vapier Exp $
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
- * Copyright 2005-2010 Mike Frysinger  - <vapier@gentoo.org>
+ * Copyright 2005-2013 Mike Frysinger  - <vapier@gentoo.org>
  */
 
 #ifdef APPLET_qdepends
@@ -32,7 +32,7 @@
 	"Pretty format specified depend strings",
 	COMMON_OPTS_HELP
 };
-static const char qdepends_rcsid[] = "$Id: qdepends.c,v 1.60 2013/09/29 09:14:14 vapier Exp $";
+static const char qdepends_rcsid[] = "$Id: qdepends.c,v 1.61 2013/09/29 10:01:55 vapier Exp $";
 #define qdepends_usage(ret) usage(ret, QDEPENDS_FLAGS, qdepends_long_opts, qdepends_opts_help, lookup_applet_idx("qdepends"))
 
 static char qdep_name_only = 0;
@@ -58,6 +58,10 @@
 };
 typedef struct _dep_node dep_node;
 
+static const dep_node null_node = {
+	.type = DEP_NULL,
+};
+
 /* prototypes */
 #ifdef NDEBUG
 # define dep_dump_tree(r)
@@ -246,7 +250,7 @@
 
 #undef _maybe_consume_word
 
-	return ret;
+	return ret ? : xmemdup(&null_node, sizeof(null_node));
 
 error_out:
 	warnf("DEPEND: %s", depend);
@@ -294,11 +298,13 @@
 		_dep_print_tree(fp, root->neighbor, space);
 }
 
-_q_static void dep_print_depend(FILE *fp, const char *depend)
+_q_static bool dep_print_depend(FILE *fp, const char *depend)
 {
-	dep_node *dep_tree = dep_grow_tree(depend);
+	dep_node *dep_tree;
+
+	dep_tree = dep_grow_tree(depend);
 	if (dep_tree == NULL)
-		return;
+		return false;
 
 	if (!quiet)
 		fprintf(fp, "DEPEND=\"\n");
@@ -308,6 +314,8 @@
 	dep_burn_tree(dep_tree);
 	if (!quiet)
 		fprintf(fp, "\"\n");
+
+	return true;
 }
 
 void dep_burn_tree(dep_node *root)
@@ -545,7 +553,8 @@
 
 	if (do_format) {
 		while (optind < argc) {
-			dep_print_depend(stdout, argv[optind++]);
+			if (!dep_print_depend(stdout, argv[optind++]))
+				return EXIT_FAILURE;
 			if (optind < argc)
 				fprintf(stdout, "\n");
 		}





^ permalink raw reply	[flat|nested] 11+ messages in thread

* [gentoo-commits] gentoo-projects commit in portage-utils: qdepends.c
@ 2013-09-29 10:03 Mike Frysinger (vapier)
  0 siblings, 0 replies; 11+ messages in thread
From: Mike Frysinger (vapier) @ 2013-09-29 10:03 UTC (permalink / raw
  To: gentoo-commits

vapier      13/09/29 10:03:06

  Modified:             qdepends.c
  Log:
  qdepends: check for whitespace around node elements as PMS requires it and it makes parsing of USE deps possible #470180

Revision  Changes    Path
1.62                 portage-utils/qdepends.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qdepends.c?rev=1.62&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qdepends.c?rev=1.62&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qdepends.c?r1=1.61&r2=1.62

Index: qdepends.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/qdepends.c,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -r1.61 -r1.62
--- qdepends.c	29 Sep 2013 10:01:55 -0000	1.61
+++ qdepends.c	29 Sep 2013 10:03:06 -0000	1.62
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2013 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qdepends.c,v 1.61 2013/09/29 10:01:55 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qdepends.c,v 1.62 2013/09/29 10:03:06 vapier Exp $
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2013 Mike Frysinger  - <vapier@gentoo.org>
@@ -32,7 +32,7 @@
 	"Pretty format specified depend strings",
 	COMMON_OPTS_HELP
 };
-static const char qdepends_rcsid[] = "$Id: qdepends.c,v 1.61 2013/09/29 10:01:55 vapier Exp $";
+static const char qdepends_rcsid[] = "$Id: qdepends.c,v 1.62 2013/09/29 10:03:06 vapier Exp $";
 #define qdepends_usage(ret) usage(ret, QDEPENDS_FLAGS, qdepends_long_opts, qdepends_opts_help, lookup_applet_idx("qdepends"))
 
 static char qdep_name_only = 0;
@@ -146,6 +146,7 @@
 
 _q_static dep_node *dep_grow_tree(const char *depend)
 {
+	bool saw_whitespace;
 	signed long paren_balanced;
 	const char *ptr, *word;
 	int curr_attach;
@@ -175,8 +176,10 @@
 	word = NULL; \
 	} while (0)
 
+	saw_whitespace = true;
 	for (ptr = depend; *ptr; ++ptr) {
 		if (isspace(*ptr)) {
+			saw_whitespace = true;
 			_maybe_consume_word(DEP_NORM);
 			continue;
 		}
@@ -192,6 +195,8 @@
 			continue;
 		}
 		case '|': {
+			if (!saw_whitespace)
+				break;
 			if (ptr[1] != '|') {
 				warnf("Found a | but not ||");
 				goto error_out;
@@ -203,6 +208,8 @@
 		}
 		case '(': {
 			++paren_balanced;
+			if (!saw_whitespace)
+				break;
 			if (prev_type == DEP_OR || prev_type == DEP_USE) {
 				_maybe_consume_word(DEP_NORM);
 				prev_type = DEP_NULL;
@@ -219,6 +226,8 @@
 		}
 		case ')': {
 			--paren_balanced;
+			if (!saw_whitespace)
+				break;
 			_maybe_consume_word(DEP_NORM);
 
 			if (curr_node->parent == NULL) {
@@ -233,6 +242,7 @@
 			if (!word)
 				word = ptr;
 		}
+		saw_whitespace = false;
 
 		/* fall through to the paren failure below */
 		if (paren_balanced < 0)





^ permalink raw reply	[flat|nested] 11+ messages in thread

* [gentoo-commits] gentoo-projects commit in portage-utils: qdepends.c
@ 2013-09-29 10:36 Mike Frysinger (vapier)
  0 siblings, 0 replies; 11+ messages in thread
From: Mike Frysinger (vapier) @ 2013-09-29 10:36 UTC (permalink / raw
  To: gentoo-commits

vapier      13/09/29 10:36:08

  Modified:             qdepends.c
  Log:
  qdepends: include depend file in debug output

Revision  Changes    Path
1.65                 portage-utils/qdepends.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qdepends.c?rev=1.65&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qdepends.c?rev=1.65&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qdepends.c?r1=1.64&r2=1.65

Index: qdepends.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/qdepends.c,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -r1.64 -r1.65
--- qdepends.c	29 Sep 2013 10:10:51 -0000	1.64
+++ qdepends.c	29 Sep 2013 10:36:08 -0000	1.65
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2013 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qdepends.c,v 1.64 2013/09/29 10:10:51 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qdepends.c,v 1.65 2013/09/29 10:36:08 vapier Exp $
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2013 Mike Frysinger  - <vapier@gentoo.org>
@@ -32,7 +32,7 @@
 	"Pretty format specified depend strings",
 	COMMON_OPTS_HELP
 };
-static const char qdepends_rcsid[] = "$Id: qdepends.c,v 1.64 2013/09/29 10:10:51 vapier Exp $";
+static const char qdepends_rcsid[] = "$Id: qdepends.c,v 1.65 2013/09/29 10:36:08 vapier Exp $";
 #define qdepends_usage(ret) usage(ret, QDEPENDS_FLAGS, qdepends_long_opts, qdepends_opts_help, lookup_applet_idx("qdepends"))
 
 static char qdep_name_only = 0;
@@ -479,7 +479,7 @@
 	char depend[16384], use[8192];
 	dep_node *dep_tree;
 
-	IF_DEBUG(warn("matched %s/%s", catname, pkgname));
+	IF_DEBUG(warn("matched %s/%s for %s", catname, pkgname, state->depend_file));
 
 	if (!eat_file_at(pkg_ctx->fd, state->depend_file, depend, sizeof(depend)))
 		return 0;





^ permalink raw reply	[flat|nested] 11+ messages in thread

* [gentoo-commits] gentoo-projects commit in portage-utils: qdepends.c
@ 2013-09-29 22:19 Mike Frysinger (vapier)
  0 siblings, 0 replies; 11+ messages in thread
From: Mike Frysinger (vapier) @ 2013-09-29 22:19 UTC (permalink / raw
  To: gentoo-commits

vapier      13/09/29 22:19:39

  Modified:             qdepends.c
  Log:
  qdepends: warn if no matches were found #459970

Revision  Changes    Path
1.66                 portage-utils/qdepends.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qdepends.c?rev=1.66&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qdepends.c?rev=1.66&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qdepends.c?r1=1.65&r2=1.66

Index: qdepends.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/qdepends.c,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -r1.65 -r1.66
--- qdepends.c	29 Sep 2013 10:36:08 -0000	1.65
+++ qdepends.c	29 Sep 2013 22:19:39 -0000	1.66
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2013 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qdepends.c,v 1.65 2013/09/29 10:36:08 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qdepends.c,v 1.66 2013/09/29 22:19:39 vapier Exp $
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2013 Mike Frysinger  - <vapier@gentoo.org>
@@ -32,7 +32,7 @@
 	"Pretty format specified depend strings",
 	COMMON_OPTS_HELP
 };
-static const char qdepends_rcsid[] = "$Id: qdepends.c,v 1.65 2013/09/29 10:36:08 vapier Exp $";
+static const char qdepends_rcsid[] = "$Id: qdepends.c,v 1.66 2013/09/29 22:19:39 vapier Exp $";
 #define qdepends_usage(ret) usage(ret, QDEPENDS_FLAGS, qdepends_long_opts, qdepends_opts_help, lookup_applet_idx("qdepends"))
 
 static char qdep_name_only = 0;
@@ -465,7 +465,7 @@
 
 	dep_burn_tree(dep_tree);
 
-	return EXIT_SUCCESS;
+	return 1;
 }
 
 _q_static int qdepends_vdb_deep_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
@@ -523,7 +523,7 @@
 	}
 	dep_burn_tree(dep_tree);
 
-	return EXIT_SUCCESS;
+	return 1;
 }
 
 int qdepends_main(int argc, char **argv)
@@ -533,7 +533,7 @@
 		.argv = argv,
 	};
 	q_vdb_pkg_cb *cb;
-	int i;
+	int i, ret;
 	bool do_format = false;
 	const char *query = NULL;
 	const char *depend_file;
@@ -576,16 +576,18 @@
 	cb = query ? qdepends_vdb_deep_cb : qdepends_main_vdb_cb;
 
 	if (!depend_file) {
-		int ret = 0;
+		ret = 0;
 		for (i = 0; depend_files[i]; ++i) {
 			printf(" %s*%s %s\n", GREEN, NORM, depend_files[i]);
 			state.depend_file = depend_files[i];
-			ret += q_vdb_foreach_pkg(cb, &state, NULL);
+			ret |= q_vdb_foreach_pkg(cb, &state, NULL);
 		}
-		return ret;
-	}
+	} else
+		ret = q_vdb_foreach_pkg(cb, &state, NULL);
 
-	return q_vdb_foreach_pkg(cb, &state, NULL);
+	if (!ret && !quiet)
+		warn("no matches found for your query");
+	return ret ? EXIT_SUCCESS : EXIT_FAILURE;
 }
 
 #else





^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2013-09-29 22:19 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-21 21:54 [gentoo-commits] gentoo-projects commit in portage-utils: qdepends.c Mike Frysinger (vapier)
  -- strict thread matches above, loose matches on Subject: below --
2013-09-29 22:19 Mike Frysinger (vapier)
2013-09-29 10:36 Mike Frysinger (vapier)
2013-09-29 10:03 Mike Frysinger (vapier)
2013-09-29 10:01 Mike Frysinger (vapier)
2013-09-29  9:14 Mike Frysinger (vapier)
2013-09-29  6:44 Mike Frysinger (vapier)
2013-09-29  5:09 Mike Frysinger (vapier)
2012-11-10  6:35 Mike Frysinger (vapier)
2009-08-29 19:43 Ned Ludd (solar)
2008-03-14 23:24 Ned Ludd (solar)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox