main: fix up depth traversal nonsense, set to depth 2 for pkg-config mode

feature/tap-sh
William Pitcock 2011-07-25 01:48:40 -05:00
parent abf49c541f
commit 9f0521ec90
2 changed files with 22 additions and 1 deletions

22
main.c
View File

@ -21,6 +21,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <libgen.h>
#include <popt.h>
#include "pkg.h"
@ -89,7 +90,7 @@ pkg_queue_walk(pkg_queue_t *head)
*/
if (!maximum_traverse_depth)
maximum_traverse_depth = -1;
else if (maximum_traverse_depth)
else if (maximum_traverse_depth > 0)
maximum_traverse_depth++;
foreach_list_entry(head, pkgq)
@ -130,6 +131,22 @@ version(void)
printf("%s %s\n", PACKAGE_NAME, PACKAGE_VERSION);
}
static bool
check_pkgconfig(const char *progname)
{
char *prognm = strdup(progname);
char *name = basename(prognm);
if (!strcasecmp(name, "pkg-config"))
{
free(prognm);
return true;
}
free(prognm);
return false;
}
int
main(int argc, const char *argv[])
{
@ -162,6 +179,9 @@ main(int argc, const char *argv[])
return EXIT_FAILURE;
}
if (check_pkgconfig(argv[0]))
maximum_traverse_depth = 2;
if (want_version)
{
version();

1
pkg.h
View File

@ -29,6 +29,7 @@
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#ifndef BUFSIZ