summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Andres Klode <julian.klode@canonical.com>2023-02-27 14:41:52 +0100
committerJulian Andres Klode <julian.klode@canonical.com>2023-02-27 14:44:12 +0100
commit557aed9806b59bebac33f4589bafc25fcb8a2728 (patch)
tree22548c3b5b03d548beae306091f5cd08f02c732b
parent0899b69b2b613f8b28e270f49d8a2fd23cbfbd77 (diff)
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.
-rw-r--r--apt-pkg/depcache.cc4
-rw-r--r--cmdline/apt-mark.cc4
2 files changed, 4 insertions, 4 deletions
diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc
index b19d180a4..322bf1bbe 100644
--- a/apt-pkg/depcache.cc
+++ b/apt-pkg/depcache.cc
@@ -90,10 +90,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{"<undefined>/"};
+ std::string special{"/"};
special.append(Needle);
return ConfigValueInSubTree(SubTree, special);
}
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{"<undefined>/"};
+ std::string special{"/"};
special.append(Needle);
return ConfigValueInSubTree(SubTree, special);
}