Author: jkupec
Date: Sat Apr 12 00:02:48 2008
New Revision: 9563
URL: http://svn.opensuse.org/viewcvs/zypp?rev=9563&view=rev
Log:
- use str::regex wrapper instead of ::regex_t
Modified:
trunk/libzypp/zypp/PoolQuery.cc
trunk/libzypp/zypp/PoolQuery.h
Modified: trunk/libzypp/zypp/PoolQuery.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/PoolQuery.cc?rev=9563&r1=9562&r2=9563&view=diff
==============================================================================
--- trunk/libzypp/zypp/PoolQuery.cc (original)
+++ trunk/libzypp/zypp/PoolQuery.cc Sat Apr 12 00:02:48 2008
@@ -68,14 +68,15 @@
public:
/** Raw search strings. */
StrContainer _strings;
- /** Regex-compiled search strings. */
+ /** Compiled search strings. */
mutable string _rcstrings;
- mutable regex_t _regex;
+ /** Compiled regex struct */
+ mutable str::regex _regex;
/** Raw attributes */
AttrMap _attrs;
/** Regex-compiled attributes */
mutable CompiledAttrMap _rcattrs;
- mutable map _rattrs;
+ mutable map _rattrs;
/** Repos to search. */
StrContainer _repos;
@@ -105,17 +106,6 @@
};
- static void
- compileRegex(regex_t * regex, const string & str, bool nocase)
- {
- /* We feed multiple lines eventually (e.g. authors or descriptions),
- so set REG_NEWLINE. */
- if (regcomp(regex, str.c_str(),
- REG_EXTENDED | REG_NOSUB | REG_NEWLINE | (nocase ? REG_ICASE : 0)) != 0)
- ZYPP_THROW(Exception(
- str::form(_("Invalid regular expression '%s'"), str.c_str())));
- }
-
struct MyInserter
{
MyInserter(PoolQuery::StrContainer & cont) : _cont(cont) {}
@@ -230,7 +220,8 @@
_rcattrs.insert(pair(ai->first, string()));
if ((_cflags & SEARCH_STRINGMASK) == SEARCH_REGEX)
- compileRegex(&_regex, _rcstrings, _cflags & SEARCH_NOCASE);
+ /* We feed multiple lines eventually (e.g. authors or descriptions), so set REG_NEWLINE. */
+ _regex = str::regex(_rcstrings, REG_EXTENDED | REG_NOSUB | REG_NEWLINE | (_cflags & SEARCH_NOCASE ? REG_ICASE : 0));
}
// // DIFFERENT STRINGS FOR DIFFERENT ATTRS
@@ -249,9 +240,8 @@
if ((_cflags & SEARCH_STRINGMASK) == SEARCH_REGEX)
{
- regex_t regex;
- compileRegex(®ex, s, _cflags & SEARCH_NOCASE);
- _rattrs.insert(pair(ai->first, regex));
+ str::regex regex(s, REG_EXTENDED | REG_NOSUB | REG_NEWLINE | (_cflags & SEARCH_NOCASE ? REG_ICASE : 0));
+ _rattrs.insert(pair(ai->first, regex));
}
}
}
@@ -640,12 +630,12 @@
{
if ((_pqimpl->_cflags & SEARCH_STRINGMASK) == SEARCH_REGEX)
{
- const regex_t * regex;
+ const regex_t * regex_p;
if (_pqimpl->_rcstrings.empty())
{
- map::const_iterator rai = _pqimpl->_rattrs.find(attr);
+ map::iterator rai = _pqimpl->_rattrs.find(attr);
if (rai != _pqimpl->_rattrs.end())
- regex = &rai->second;
+ regex_p = rai->second.get();
else
{
ERR << "no compiled regex found for " << attr << endl;
@@ -653,8 +643,8 @@
}
}
else
- regex = &_pqimpl->_regex;
- matches = ::dataiterator_match(base().get(), _pqimpl->_cflags, regex);
+ regex_p = _pqimpl->_regex.get();
+ matches = ::dataiterator_match(base().get(), _pqimpl->_cflags, regex_p);
}
else
{
Modified: trunk/libzypp/zypp/PoolQuery.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/PoolQuery.h?rev=9563&r1=9562&r2=9563&view=diff
==============================================================================
--- trunk/libzypp/zypp/PoolQuery.h (original)
+++ trunk/libzypp/zypp/PoolQuery.h Sat Apr 12 00:02:48 2008
@@ -343,6 +343,14 @@
bool _has_next;
/** whether to do text matching on our own (true) or the Dataiterator already did it */
bool _do_matching;
+
+ // flags
+ // str
+ // regex
+ // attrs_regex
+ // attrs_str
+
+
/** used to copy current iterator in order to forward check for next attributes */
sat::LookupAttr::iterator _tmpit;
};
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org