From 22d91c257916ee775a9116f9a1bae88001af9ad2 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Thu, 17 Mar 2011 03:01:19 +0000 Subject: combine the portroot/portvdb chdirs to avoid leading slash issues in portvdb itself --- qcheck.c | 8 ++++---- qdepends.c | 12 ++++++------ qgrep.c | 9 +++++---- qsize.c | 14 +++++++------- 4 files changed, 22 insertions(+), 21 deletions(-) diff --git a/qcheck.c b/qcheck.c index cd7eb1e..49fc855 100644 --- a/qcheck.c +++ b/qcheck.c @@ -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/qcheck.c,v 1.46 2011/02/21 01:33:47 vapier Exp $ + * $Header: /var/cvsroot/gentoo-projects/portage-utils/qcheck.c,v 1.47 2011/03/17 03:01:19 vapier Exp $ * * Copyright 2005-2010 Ned Ludd - * Copyright 2005-2010 Mike Frysinger - @@ -32,7 +32,7 @@ static const char * const qcheck_opts_help[] = { "Ignore differing file mtimes", COMMON_OPTS_HELP }; -static const char qcheck_rcsid[] = "$Id: qcheck.c,v 1.46 2011/02/21 01:33:47 vapier Exp $"; +static const char qcheck_rcsid[] = "$Id: qcheck.c,v 1.47 2011/03/17 03:01:19 vapier Exp $"; #define qcheck_usage(ret) usage(ret, QCHECK_FLAGS, qcheck_long_opts, qcheck_opts_help, lookup_applet_idx("qcheck")) short bad_only = 0; @@ -100,8 +100,8 @@ int qcheck_main(int argc, char **argv) if ((argc == optind) && !search_all) qcheck_usage(EXIT_FAILURE); - xchdir(portroot); - xchdir(portvdb); + snprintf(buf, sizeof(buf), "%s/%s", portroot, portvdb); + xchdir(buf); if ((dir = opendir(".")) == NULL) errp("unable to read '.' !?"); diff --git a/qdepends.c b/qdepends.c index 7611dcb..cd1ed51 100644 --- a/qdepends.c +++ b/qdepends.c @@ -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.51 2011/02/21 01:33:47 vapier Exp $ + * $Header: /var/cvsroot/gentoo-projects/portage-utils/qdepends.c,v 1.52 2011/03/17 03:01:19 vapier Exp $ * * Copyright 2005-2010 Ned Ludd - * Copyright 2005-2010 Mike Frysinger - @@ -30,7 +30,7 @@ static const char * const qdepends_opts_help[] = { "Show all DEPEND info", COMMON_OPTS_HELP }; -static const char qdepends_rcsid[] = "$Id: qdepends.c,v 1.51 2011/02/21 01:33:47 vapier Exp $"; +static const char qdepends_rcsid[] = "$Id: qdepends.c,v 1.52 2011/03/17 03:01:19 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; @@ -355,8 +355,8 @@ int qdepends_main_vdb(const char *depend_file, int argc, char **argv) dep_node *dep_tree; struct stat st; - xchdir(portroot); - xchdir(portvdb); + snprintf(buf, sizeof(buf), "%s/%s", portroot, portvdb); + xchdir(buf); if ((dir = opendir(".")) == NULL) return EXIT_FAILURE; @@ -466,8 +466,8 @@ int qdepends_vdb_deep(const char *depend_file, const char *query) char depend[16384], use[8192]; dep_node *dep_tree; - xchdir(portroot); - xchdir(portvdb); + snprintf(buf, sizeof(buf), "%s/%s", portroot, portvdb); + xchdir(buf); if ((dir = opendir(".")) == NULL) return EXIT_FAILURE; diff --git a/qgrep.c b/qgrep.c index 14facff..11dc6aa 100644 --- a/qgrep.c +++ b/qgrep.c @@ -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/qgrep.c,v 1.28 2011/02/21 01:33:47 vapier Exp $ + * $Header: /var/cvsroot/gentoo-projects/portage-utils/qgrep.c,v 1.29 2011/03/17 03:01:19 vapier Exp $ * * Copyright 2005-2010 Ned Ludd - * Copyright 2005-2010 Mike Frysinger - @@ -47,7 +47,7 @@ static const char * const qgrep_opts_help[] = { "Print lines of trailing context", COMMON_OPTS_HELP }; -static const char qgrep_rcsid[] = "$Id: qgrep.c,v 1.28 2011/02/21 01:33:47 vapier Exp $"; +static const char qgrep_rcsid[] = "$Id: qgrep.c,v 1.29 2011/03/17 03:01:19 vapier Exp $"; #define qgrep_usage(ret) usage(ret, QGREP_FLAGS, qgrep_long_opts, qgrep_opts_help, lookup_applet_idx("qgrep")) char qgrep_name_match(const char*, const int, depend_atom**); @@ -392,8 +392,9 @@ int qgrep_main(int argc, char **argv) if ((eclass_dir = opendir("eclass")) == NULL) errp("opendir(\"%s/eclass\") failed", portdir); } else { /* if (do_install) */ - xchdir(portroot); - xchdir(portvdb); + char buf[_Q_PATH_MAX]; + snprintf(buf, sizeof(buf), "%s/%s", portroot, portvdb); + xchdir(buf); if ((vdb_dir = opendir(".")) == NULL) errp("could not opendir(%s/%s) for ROOT/VDB", portroot, portvdb); } diff --git a/qsize.c b/qsize.c index b4d4546..cbbb3bb 100644 --- a/qsize.c +++ b/qsize.c @@ -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/qsize.c,v 1.37 2011/02/21 07:33:21 vapier Exp $ + * $Header: /var/cvsroot/gentoo-projects/portage-utils/qsize.c,v 1.38 2011/03/17 03:01:19 vapier Exp $ * * Copyright 2005-2010 Ned Ludd - * Copyright 2005-2010 Mike Frysinger - @@ -32,7 +32,7 @@ static const char * const qsize_opts_help[] = { "Ignore regexp string", COMMON_OPTS_HELP }; -static const char qsize_rcsid[] = "$Id: qsize.c,v 1.37 2011/02/21 07:33:21 vapier Exp $"; +static const char qsize_rcsid[] = "$Id: qsize.c,v 1.38 2011/03/17 03:01:19 vapier Exp $"; #define qsize_usage(ret) usage(ret, QSIZE_FLAGS, qsize_long_opts, qsize_opts_help, lookup_applet_idx("qsize")) int qsize_main(int argc, char **argv) @@ -72,11 +72,6 @@ int qsize_main(int argc, char **argv) if ((argc == optind) && !search_all) qsize_usage(EXIT_FAILURE); - xchdir(portroot); - xchdir(portvdb); - if ((dir = opendir(".")) == NULL) - return EXIT_FAILURE; - num_all_bytes = num_all_files = num_all_nonfiles = num_all_ignored = 0; strcpy(filename, portroot); @@ -84,6 +79,11 @@ int qsize_main(int argc, char **argv) buflen = _Q_PATH_MAX; buf = xmalloc(buflen); + snprintf(buf, buflen, "%s/%s", portroot, portvdb); + xchdir(buf); + if ((dir = opendir(".")) == NULL) + return EXIT_FAILURE; + /* open /var/db/pkg */ while ((dentry = q_vdb_get_next_dir(dir))) { -- cgit v1.2.3-65-gdbad