From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 89A051382C5 for ; Fri, 23 Mar 2018 15:27:44 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 71460E084E; Fri, 23 Mar 2018 15:27:43 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 4601AE084E for ; Fri, 23 Mar 2018 15:27:43 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id D3DE7335C0A for ; Fri, 23 Mar 2018 15:27:41 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 05016239 for ; Fri, 23 Mar 2018 15:27:40 +0000 (UTC) From: "Fabian Groffen" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Fabian Groffen" Message-ID: <1521817675.967b86446d70038ccdf3d014d5554be41d981edc.grobian@gentoo> Subject: [gentoo-commits] proj/portage-utils:master commit in: / X-VCS-Repository: proj/portage-utils X-VCS-Files: qdepends.c X-VCS-Directories: / X-VCS-Committer: grobian X-VCS-Committer-Name: Fabian Groffen X-VCS-Revision: 967b86446d70038ccdf3d014d5554be41d981edc X-VCS-Branch: master Date: Fri, 23 Mar 2018 15:27:40 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 21036fa3-f4ff-44ff-bfa4-2ddcd4738865 X-Archives-Hash: 009597740db46aea8bcd0d87061e3512 commit: 967b86446d70038ccdf3d014d5554be41d981edc Author: Fabian Groffen gentoo org> AuthorDate: Fri Mar 23 15:07:55 2018 +0000 Commit: Fabian Groffen gentoo org> CommitDate: Fri Mar 23 15:07:55 2018 +0000 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=967b8644 qdepends_vdb_deep_cb: show atom that matched This extracts the atom that matched the regular expression. qdepends.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/qdepends.c b/qdepends.c index e8b2190..117ca71 100644 --- a/qdepends.c +++ b/qdepends.c @@ -479,6 +479,9 @@ qdepends_vdb_deep_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv) static char *depend, *use; static size_t depend_len, use_len; dep_node *dep_tree; + int ret; + regex_t preg; + regmatch_t match; if (!q_vdb_pkg_eat(pkg_ctx, state->depend_file, &depend, &depend_len)) return 0; @@ -506,7 +509,14 @@ qdepends_vdb_deep_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv) dep_prune_use(dep_tree, use); ptr = dep_flatten_tree(dep_tree); - if (ptr && rematch(state->query, ptr, REG_EXTENDED) == 0) { + + ret = -2; + if (ptr && wregcomp(&preg, state->query, REG_EXTENDED) == 0) + ret = regexec(&preg, ptr, 1, &match, 0); + if (ret > -2) + regfree(&preg); + + if (ptr && ret == 0) { if (qdep_name_only) { depend_atom *atom = NULL; snprintf(buf, sizeof(buf), "%s/%s", catname, pkgname); @@ -517,8 +527,16 @@ qdepends_vdb_deep_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv) } else { printf("%s%s/%s%s%s%c", BOLD, catname, BLUE, pkgname, NORM, verbose ? ':' : '\n'); } - if (verbose) - printf(" %s\n", ptr); + if (verbose) { + /* find the boundaries for this atom */ + while (match.rm_so > 0 && !isspace(ptr[match.rm_so - 1])) + match.rm_so--; + while (ptr[match.rm_eo] != '\0' && !isspace(ptr[match.rm_eo])) + match.rm_eo++; + printf(" %.*s\n", + (int)(match.rm_eo - match.rm_so), + ptr + match.rm_so); + } } dep_burn_tree(dep_tree);