From 557aed9806b59bebac33f4589bafc25fcb8a2728 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 27 Feb 2023 14:41:52 +0100 Subject: Use a more gitignore style matching Use a rightmost match for / so that if we end up with a Section: a/b/c, a 'c' matcher still matches. If the section does not contain any /, it can be matched using /pattern, e.g. /c only matches Section: c, but not Section: a/b/c. --- cmdline/apt-mark.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-mark.cc b/cmdline/apt-mark.cc index 46d3ca5b8..3f3b008ba 100644 --- a/cmdline/apt-mark.cc +++ b/cmdline/apt-mark.cc @@ -163,10 +163,10 @@ static bool SectionInSubTree(char const * const SubTree, std::string_view Needle { if (ConfigValueInSubTree(SubTree, Needle)) return true; - auto const sub = Needle.find('/'); + auto const sub = Needle.rfind('/'); if (sub == std::string_view::npos) { - std::string special{"/"}; + std::string special{"/"}; special.append(Needle); return ConfigValueInSubTree(SubTree, special); } -- cgit v1.2.3-70-g09d2