diff options
author | Daniel Hartwig <mandyke@gmail.com> | 2012-06-08 17:12:32 +0800 |
---|---|---|
committer | Daniel Hartwig <mandyke@gmail.com> | 2012-06-08 17:12:32 +0800 |
commit | cc6370366dfab801233d7aa99f7b1900125185c6 (patch) | |
tree | d1fe67925ff69fc8fb88d01a1758005ff2a8420a | |
parent | 24e4c8dab029ac59437f9392a8d3732c6893a3e3 (diff) | |
download | aptitude-cc6370366dfab801233d7aa99f7b1900125185c6.tar.gz |
Regex strings count as search patterns
Apt-utils treat regex strings as a search pattern, we should
too.
-rw-r--r-- | NEWS | 10 | ||||
-rw-r--r-- | src/generic/apt/matching/pattern.cc | 4 | ||||
-rw-r--r-- | src/generic/apt/matching/pattern.h | 4 |
3 files changed, 15 insertions, 3 deletions
@@ -1,6 +1,16 @@ [6/8/2012] Version 0.6.9 "All in a days work" +- New features: + + * [cmdline]: Regular expressions are now supported to match names + (same as apt-utils): + + $ aptitude show ^tf$ + + Previously this would result in a "no such package" + error. + - Internal changes: * Unified the way packages are selected from command line diff --git a/src/generic/apt/matching/pattern.cc b/src/generic/apt/matching/pattern.cc index 5743a2a7..75339e1d 100644 --- a/src/generic/apt/matching/pattern.cc +++ b/src/generic/apt/matching/pattern.cc @@ -79,7 +79,9 @@ namespace aptitude bool is_pattern(const std::string &s) { - return s.find_first_of("~?") != s.npos; + // regex characters are ".?+*|[^$" + // pattern characters are "~?" + return s.find_first_of("~?.?+*|[^$") != s.npos; } } } diff --git a/src/generic/apt/matching/pattern.h b/src/generic/apt/matching/pattern.h index 5aad42f8..96d48550 100644 --- a/src/generic/apt/matching/pattern.h +++ b/src/generic/apt/matching/pattern.h @@ -2021,8 +2021,8 @@ namespace aptitude * This is used in situations where it would be counterintuitive * for all strings to be treated as search patterns, but where we * want search patterns to be available. Strings are considered - * to be seach patterns if they contain a tilde (~) or a question - * mark (?). + * to be seach patterns if they contain a tilde (~), a question + * mark (?), or any regex characters (.?+*|[^$). * * \return \b true if the string qualifies as a search pattern. */ |