summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Hartwig <mandyke@gmail.com>2012-03-27 16:40:24 +0800
committerDaniel Hartwig <mandyke@gmail.com>2012-03-27 16:40:24 +0800
commite1772941b9bd291ec8f71eab4ae9080e127308cc (patch)
tree3287293f5239719166b4f89f9de36bed38357c4d
parent2b991acae3c5c90fd119871f1b0a543c47d4dcc4 (diff)
downloadaptitude-e1772941b9bd291ec8f71eab4ae9080e127308cc.tar.gz
Support non-regex terms generating titles for 'pattern' grouping policy
Previously non-regex terms had to use a grouping policy such as: pattern(~ramd64 => amd64) to specify the title. This change permits some terms to define the title, and using shorter grouping policies like: pattern(~ramd64) pattern(~r) * src/generic/apt/matching/match.{cc,h}: - support non-regex terms generating titles;
-rw-r--r--src/generic/apt/matching/match.cc6
-rw-r--r--src/generic/apt/matching/match.h11
2 files changed, 16 insertions, 1 deletions
diff --git a/src/generic/apt/matching/match.cc b/src/generic/apt/matching/match.cc
index 84fb97fc..9556aee0 100644
--- a/src/generic/apt/matching/match.cc
+++ b/src/generic/apt/matching/match.cc
@@ -255,7 +255,7 @@ namespace aptitude
case atomic:
// TODO: do something special based on the type, like we
// used to before the recent changes.
- return 0;
+ return match_string.empty() ? 0 : 1;
case regexp:
return regexp_matches.size();
@@ -281,6 +281,10 @@ namespace aptitude
switch(tp)
{
case atomic:
+ if(group_num >= (match_string.empty() ? 0 : 1))
+ throw MatchingException("Can't retrieve match information: the group number is out of bounds.");
+ return std::string(match_string);
+
case dependency:
case provides:
throw MatchingException("Can't retrieve match information: the group number is out of bounds.");
diff --git a/src/generic/apt/matching/match.h b/src/generic/apt/matching/match.h
index b13a4cdc..8be78aa8 100644
--- a/src/generic/apt/matching/match.h
+++ b/src/generic/apt/matching/match.h
@@ -267,6 +267,17 @@ namespace aptitude
(regexp_match *)0, (regexp_match *)0);
}
+ static cwidget::util::ref_ptr<match> make_atomic(const cwidget::util::ref_ptr<pattern> &p,
+ const std::string &match_string)
+ {
+ return new match(atomic, p,
+ cwidget::util::ref_ptr<structural_match>(),
+ pkgCache::DepIterator(),
+ pkgCache::PrvIterator(),
+ match_string,
+ (regexp_match *)0, (regexp_match *)0);
+ }
+
/** \brief Create a new regular expression match.
*
* \param p The pattern that produced this match.