[zypp-commit] r9966 - /trunk/sat-solver/testsuite/gimmick.c
Author: mlschroe Date: Tue May 6 18:22:53 2008 New Revision: 9966 URL: http://svn.opensuse.org/viewcvs/zypp?rev=9966&view=rev Log: - use getopt - add '-n' option to test nevr matching Modified: trunk/sat-solver/testsuite/gimmick.c Modified: trunk/sat-solver/testsuite/gimmick.c URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/testsuite/gimmick.c?rev=9966&r1=9965&r2=9966&view=diff ============================================================================== --- trunk/sat-solver/testsuite/gimmick.c (original) +++ trunk/sat-solver/testsuite/gimmick.c Tue May 6 18:22:53 2008 @@ -31,28 +31,54 @@ Repo *repo; Id id; Id p, *pp; - Id arch = 0; + char *arch = 0; + int debuglevel = 0; + int nevr = 0; + int c; pool = pool_create(); - repo = repo_create(pool, "<stdin>"); - repo_add_solv(repo, stdin); - if (argc > 2 && !strcmp(argv[1], "-a")) + while ((c = getopt(argc, argv, "vna:")) >= 0) { - arch = str2id(pool, argv[2], 1); - argc -= 2; - argv += 2; + switch(c) + { + case 'n': + nevr = 1; + break; + case 'a': + arch = optarg; + break; + case 'v': + debuglevel++; + break; + default: + exit(1); + } } + pool_setdebuglevel(pool, debuglevel); + repo = repo_create(pool, "<stdin>"); + repo_add_solv(repo, stdin); + argc -= optind - 1; + argv += optind - 1; id = str2id(pool, argv[1], 1); if (arch) - id = rel2id(pool, id, arch, REL_ARCH, 1); + id = rel2id(pool, id, str2id(pool, arch, 1), REL_ARCH, 1); if (argc > 2) id = rel2id(pool, id, str2id(pool, argv[2], 1), atoi(argv[3]), 1); pool_createwhatprovides(pool); printf("%s:\n", dep2str(pool, id)); - FOR_PROVIDES(p, pp, id) - printf(" %s\n", solvable2str(pool, pool->solvables + p)); + if (nevr) + { + for (p = 1; p < pool->nsolvables; p++) + if (pool_match_nevr(pool, pool->solvables + p, id)) + printf(" %s\n", solvable2str(pool, pool->solvables + p)); + } + else + { + FOR_PROVIDES(p, pp, id) + printf(" %s\n", solvable2str(pool, pool->solvables + p)); + } pool_free(pool); return 0; } -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org
participants (1)
-
mlschroe@svn.opensuse.org