Author: dmacvicar
Date: Fri Aug 10 16:08:27 2007
New Revision: 6586
URL: http://svn.opensuse.org/viewcvs/zypp?rev=6586&view=rev
Log:
importing my current diff
Modified:
trunk/libzypp/CMakeLists.txt
trunk/libzypp/zypp/CMakeLists.txt
trunk/libzypp/zypp/Dep.h
trunk/libzypp/zypp/Edition.cc
trunk/libzypp/zypp/KVMap.h
trunk/libzypp/zypp/KeyRing.cc
trunk/libzypp/zypp/MediaSetAccess.cc
trunk/libzypp/zypp/Pathname.h
trunk/libzypp/zypp/PublicKey.cc
trunk/libzypp/zypp/Url.cc
trunk/libzypp/zypp/base/Regex.cc
trunk/libzypp/zypp/base/Regex.h
trunk/libzypp/zypp/base/String.cc
trunk/libzypp/zypp/base/String.h
trunk/libzypp/zypp/capability/CapabilityImpl.cc
trunk/libzypp/zypp/parser/plaindir/RepoParser.cc
trunk/libzypp/zypp/repo/Applydeltarpm.cc
trunk/libzypp/zypp/target/rpm/RpmDb.cc
trunk/libzypp/zypp/url/UrlBase.cc
Modified: trunk/libzypp/CMakeLists.txt
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/CMakeLists.txt?rev=6586&r1=6585&r2=6586&view=diff
==============================================================================
--- trunk/libzypp/CMakeLists.txt (original)
+++ trunk/libzypp/CMakeLists.txt Fri Aug 10 16:08:27 2007
@@ -27,8 +27,8 @@
SET( PACKAGE "libzypp" )
SET( VERSION "${LIBZYPP_MAJOR}.${LIBZYPP_MINOR}.${LIBZYPP_PATCH}" )
-SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O3 -Wall -Woverloaded-virtual" )
-SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O3 -Wall" )
+SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -Wall -Woverloaded-virtual" )
+SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -Wall" )
ADD_DEFINITIONS( -D_FILE_OFFSET_BITS=64 )
ADD_DEFINITIONS( -DVERSION=\\\"${VERSION}\\\" )
SET( LIBZYPP_VERSION_INFO "${LIBZYPP_SO_FIRST}.${LIBZYPP_AGE}.${LIBZYPP_PATCH}" )
Modified: trunk/libzypp/zypp/CMakeLists.txt
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/CMakeLists.txt?rev=6586&r1=6585&r2=6586&view=diff
==============================================================================
--- trunk/libzypp/zypp/CMakeLists.txt (original)
+++ trunk/libzypp/zypp/CMakeLists.txt Fri Aug 10 16:08:27 2007
@@ -201,6 +201,7 @@
base/InputStream.cc
base/ReferenceCounted.cc
base/String.cc
+ base/Regex.cc
base/Unit.cc
base/ExternalDataSource.cc
base/Exception.cc
@@ -245,6 +246,7 @@
base/ReferenceCounted.h
base/SafeBool.h
base/String.h
+ base/Regex.h
base/Sysconfig.h
base/UniqueString.h
base/Unit.h
@@ -1141,7 +1143,7 @@
SET_TARGET_PROPERTIES( zypp PROPERTIES VERSION "${LIBZYPP_VERSION_INFO}" )
ADD_DEPENDENCIES(zypp schema_header)
# System libraries
-TARGET_LINK_LIBRARIES(zypp boost_filesystem boost_regex util )
+TARGET_LINK_LIBRARIES(zypp boost_filesystem util )
TARGET_LINK_LIBRARIES(zypp ${DBUS_LIBRARY} )
TARGET_LINK_LIBRARIES(zypp dbus-glib-1 )
TARGET_LINK_LIBRARIES(zypp ${GLIB_LIBRARY} )
Modified: trunk/libzypp/zypp/Dep.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/Dep.h?rev=6586&r1=6585&r2=6586&view=diff
==============================================================================
--- trunk/libzypp/zypp/Dep.h (original)
+++ trunk/libzypp/zypp/Dep.h Fri Aug 10 16:08:27 2007
@@ -12,7 +12,7 @@
#ifndef ZYPP_DEP_H
#define ZYPP_DEP_H
-#include <iosfwd>
+#include <iostream>
#include <string>
///////////////////////////////////////////////////////////////////
Modified: trunk/libzypp/zypp/Edition.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/Edition.cc?rev=6586&r1=6585&r2=6586&view=diff
==============================================================================
--- trunk/libzypp/zypp/Edition.cc (original)
+++ trunk/libzypp/zypp/Edition.cc Fri Aug 10 16:08:27 2007
@@ -13,6 +13,7 @@
#include "zypp/base/Logger.h"
#include "base/String.h"
+#include "base/Regex.h"
#include "base/Exception.h"
#include "zypp/Edition.h"
@@ -146,19 +147,27 @@
Impl( const std::string & edition_r )
: _epoch( noepoch )
{
+ //[0-9]+:)?([^-]*)(-([^-]*))?" );
str::smatch what;
- if( str::regex_match( edition_r.begin(), edition_r.end(),
- what, _rxEdition ) )
+
+ std::cout << "edition: " << edition_r << std::endl;
+
+ std::cout << str::regex_match( edition_r, what, _rxEdition ) << std::endl;
+
+ std::cout << "size: " << what.size() << std::endl;
+
+ for (int i = 1; i < what.size(); ++i)
+ std::cout << i << ": " << what[i] << std::endl;
+
+
+ if( str::regex_match( edition_r, what, _rxEdition ) && what.size() >= 3)
{
- // what[2] contains the epoch
- // what[3] contains the version
- // what[5] contains the release
- if ( what[2].matched )
- _epoch = strtoul( what[2].str().c_str(), NULL, 10 );
- if ( what[3].matched )
- _version = what[3].str();
- if ( what[5].matched )
- _release = what[5].str();
+ if ( what[1].size() > 1 )
+ _epoch = strtoul( what[1].c_str(), NULL, 10 );
+ if ( what[2].size() )
+ _version = what[2];
+ if ( what[3].size() )
+ _release = what[3];
}
else
{
@@ -216,7 +225,7 @@
};
///////////////////////////////////////////////////////////////////
- const str::regex Edition::Impl::_rxEdition( "(([0-9]+):)?([^-]*)(-([^-]*))?" );
+ const str::regex Edition::Impl::_rxEdition( "([0-9]+:)?([^-]*)(-[^-]*)?" );
///////////////////////////////////////////////////////////////////
Modified: trunk/libzypp/zypp/KVMap.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/KVMap.h?rev=6586&r1=6585&r2=6586&view=diff
==============================================================================
--- trunk/libzypp/zypp/KVMap.h (original)
+++ trunk/libzypp/zypp/KVMap.h Fri Aug 10 16:08:27 2007
@@ -22,6 +22,7 @@
#define KVMap_h
#include <iosfwd>
+#include <vector>
#include <map>
#include "zypp/base/String.h"
Modified: trunk/libzypp/zypp/KeyRing.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/KeyRing.cc?rev=6586&r1=6585&r2=6586&view=diff
==============================================================================
--- trunk/libzypp/zypp/KeyRing.cc (original)
+++ trunk/libzypp/zypp/KeyRing.cc Fri Aug 10 16:08:27 2007
@@ -22,6 +22,7 @@
#include "zypp/base/Logger.h"
#include "zypp/base/IOStream.h"
#include "zypp/base/String.h"
+#include "zypp/base/Regex.h"
#include "zypp/PathInfo.h"
#include "zypp/KeyRing.h"
#include "zypp/ExternalProgram.h"
@@ -424,7 +425,7 @@
{
//MIL << line << endl;
str::smatch what;
- if(str::regex_match(line, what, rxColons, str::match_extra))
+ if(str::regex_match(line, what, rxColons))
{
string id;
string fingerprint;
@@ -436,7 +437,7 @@
for(line2 = prog.receiveLine(); !line2.empty(); line2 = prog.receiveLine(), count++ )
{
str::smatch what2;
- if (str::regex_match(line2, what2, rxColonsFpr, str::match_extra))
+ if (str::regex_match(line2, what2, rxColonsFpr))
{
if ( (what2[1] == "fpr") && (what2[1] != "pub") && (what2[1] !="sub"))
{
@@ -567,7 +568,7 @@
{
//MIL << "[" << line << "]" << endl;
str::smatch what;
- if(str::regex_match(line, what, rxNoKey, str::match_extra))
+ if(str::regex_search(line, what, rxNoKey))
{
if ( what.size() > 1 )
id = what[1];
Modified: trunk/libzypp/zypp/MediaSetAccess.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/MediaSetAccess.cc?rev=6586&r1=6585&r2=6586&view=diff
==============================================================================
--- trunk/libzypp/zypp/MediaSetAccess.cc (original)
+++ trunk/libzypp/zypp/MediaSetAccess.cc Fri Aug 10 16:08:27 2007
@@ -11,6 +11,7 @@
#include <fstream>
#include "zypp/base/LogTools.h"
+#include "zypp/base/Regex.h"
#include "zypp/base/UserRequestException.h"
#include "zypp/ZYppCallbacks.h"
#include "zypp/MediaSetAccess.h"
@@ -499,9 +500,10 @@
// code has to be adapted together with the MediaISO change.
// maybe some MediaISOURL interface should be used.
std::string isofile = url_r.getQueryParam("iso");
- boost::regex e("^(.*(cd|dvd))([0-9]+)(\\.iso)$", boost::regex::icase);
- boost::smatch what;
- if(boost::regex_match(isofile, what, e, boost::match_extra))
+ str::regex e("^(.*(cd|dvd))([0-9]+)(\\.iso)$", str::regex::icase);
+
+ str::smatch what;
+ if(str::regex_match(isofile, what, e))
{
Url url( url_r);
isofile = what[1] + str::numstring(medianr) + what[4];
@@ -513,9 +515,9 @@
else
{
std::string pathname = url_r.getPathName();
- boost::regex e("^(.*(cd|dvd))([0-9]+)(/?)$", boost::regex::icase);
- boost::smatch what;
- if(boost::regex_match(pathname, what, e, boost::match_extra))
+ str::regex e("^(.*(cd|dvd))([0-9]+)(/?)$", str::regex::icase);
+ str::smatch what;
+ if(str::regex_match(pathname, what, e))
{
Url url( url_r);
pathname = what[1] + str::numstring(medianr) + what[4];
Modified: trunk/libzypp/zypp/Pathname.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/Pathname.h?rev=6586&r1=6585&r2=6586&view=diff
==============================================================================
--- trunk/libzypp/zypp/Pathname.h (original)
+++ trunk/libzypp/zypp/Pathname.h Fri Aug 10 16:08:27 2007
@@ -12,7 +12,7 @@
#ifndef ZYPP_PATHNAME_H
#define ZYPP_PATHNAME_H
-#include <iosfwd>
+#include <iostream>
#include <string>
///////////////////////////////////////////////////////////////////
Modified: trunk/libzypp/zypp/PublicKey.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/PublicKey.cc?rev=6586&r1=6585&r2=6586&view=diff
==============================================================================
--- trunk/libzypp/zypp/PublicKey.cc (original)
+++ trunk/libzypp/zypp/PublicKey.cc Fri Aug 10 16:08:27 2007
@@ -13,6 +13,7 @@
//#include "zypp/base/Logger.h"
#include "zypp/base/String.h"
+#include "zypp/base/Regex.h"
#include "zypp/PublicKey.h"
#include "zypp/ExternalProgram.h"
#include "zypp/TmpPath.h"
@@ -118,7 +119,7 @@
{
//MIL << "[" << line << "]" << std::endl;
str::smatch what;
- if(str::regex_match(line, what, rxColons, str::match_extra))
+ if(str::regex_match(line, what, rxColons))
{
if ( what[1] == "pub" )
{
Modified: trunk/libzypp/zypp/Url.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/Url.cc?rev=6586&r1=6585&r2=6586&view=diff
==============================================================================
--- trunk/libzypp/zypp/Url.cc (original)
+++ trunk/libzypp/zypp/Url.cc Fri Aug 10 16:08:27 2007
@@ -12,7 +12,9 @@
#include
#include
#include
+#include
#include <stdexcept>
+#include <iostream>
//////////////////////////////////////////////////////////////////////
@@ -27,11 +29,11 @@
/*
* url = [scheme:] [//authority] /path [?query] [#fragment]
*/
- #define RX_SPLIT_URL "^(([^:/?#]+):)?" \
- "(//([^/?#]*))?" \
+ #define RX_SPLIT_URL "^([^:/?#]+:|)" \
+ "(//[^/?#]*|)" \
"([^?#]*)" \
- "([?]([^#]*))?" \
- "(#(.*))?"
+ "([?][^#]*|)" \
+ "(#.*|)"
////////////////////////////////////////////////////////////////////
@@ -374,18 +376,33 @@
catch( ... )
{}
- if(ret && out.size() == 10)
+ if(ret && out.size() == 5)
{
- url = g_urlSchemeRepository().getUrlByScheme(out[2].str());
+ std::string scheme = out[1];
+ if (scheme.size() > 1)
+ scheme = scheme.substr(0, scheme.size()-1);
+ std::string authority = out[2];
+ if (authority.size() >= 2)
+ authority = authority.substr(2);
+ std::string query = out[4];
+ if (query.size() > 1)
+ query = query.substr(1);
+ std::string fragment = out[5];
+ if (fragment.size() > 1)
+ fragment = fragment.substr(1);
+
+ std::cout << "scheme: " << scheme << " authority: " << authority
+ << " query " << query << " fragment " << fragment << std::endl;
+
+ std::cout << "out[3] " << out[3] << std::endl;
+
+ url = g_urlSchemeRepository().getUrlByScheme(scheme);
if( !url)
{
url.reset( new UrlBase());
}
- url->init(out[2].str(),
- out[4].str(),
- out[5].str(),
- out[7].str(),
- out[9].str());
+ url->init(scheme, authority, out[3],
+ query, fragment);
}
return url;
}
Modified: trunk/libzypp/zypp/base/Regex.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/base/Regex.cc?rev=6586&r1=6585&r2=6586&view=diff
==============================================================================
--- trunk/libzypp/zypp/base/Regex.cc (original)
+++ trunk/libzypp/zypp/base/Regex.cc Fri Aug 10 16:08:27 2007
@@ -76,3 +76,81 @@
return matches;
}
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/base/Regex.cc
+ *
+*/
+#include <cstdio>
+#include <cstdarg>
+
+#include <iostream>
+
+#include "zypp/base/Regex.h"
+
+using namespace zypp::str;
+
+regex::regex(const std::string& str, int flags)
+{
+ m_valid = true;
+ if (regcomp(&m_preg, str.c_str(), REG_EXTENDED))
+ m_valid = false;
+}
+
+regex::~regex() throw()
+{
+ if (m_valid)
+ regfree(&m_preg);
+}
+
+bool zypp::str::regex_match(const std::string& s, smatch& matches, const regex& regex)
+{
+ bool r = regex.m_valid && !regexec(®ex.m_preg, s.c_str(), 12, &matches.pmatch[0], 0);
+ if (r)
+ matches.match_str = s;
+ return r;
+}
+
+bool zypp::str::regex_match(const std::string& s, const regex& regex)
+{
+ return !regexec(®ex.m_preg, s.c_str(), 0, NULL, 0);
+}
+
+bool zypp::str::regex_search(const std::string& s, smatch& matches, const regex& regex)
+{
+ bool r= regex.m_valid && !regexec(®ex.m_preg, s.c_str(), 12, &matches.pmatch[0], 0);
+ if (r)
+ matches.match_str = s;
+ return r;
+}
+
+smatch::smatch()
+{
+ memset(&pmatch, -1, sizeof(pmatch));
+}
+
+std::string smatch::operator[](unsigned i) const
+{
+ if (i < 12 && pmatch[i].rm_so != -1)
+ return match_str.substr(pmatch[i].rm_so, pmatch[i].rm_eo-pmatch[i].rm_so);
+ return std::string();
+}
+
+
+unsigned smatch::size() const
+{
+ unsigned matches = 0;
+ while (matches < 12 && pmatch[matches+1].rm_so != -1) {
+ // std::cout << "match[" << matches << "]: *" << (*this)[matches
+ // +1] << "*" << std::endl;
+ matches++;
+ }
+
+ return matches;
+}
Modified: trunk/libzypp/zypp/base/Regex.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/base/Regex.h?rev=6586&r1=6585&r2=6586&view=diff
==============================================================================
--- trunk/libzypp/zypp/base/Regex.h (original)
+++ trunk/libzypp/zypp/base/Regex.h Fri Aug 10 16:08:27 2007
@@ -71,3 +71,76 @@
} // namespace zypp
///////////////////////////////////////////////////////////////////
#endif // ZYPP_BASE_STRING_H
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/base/Regex.h
+ *
+*/
+#ifndef ZYPP_BASE_REGEX_H
+#define ZYPP_BASE_REGEX_H
+
+#include <iosfwd>
+#include <string>
+
+#include
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////
+ /** String related utilities and \ref ZYPP_STR_REGEX.
+ \see \ref ZYPP_STR_REGEX
+ */
+ namespace str
+ { /////////////////////////////////////////////////////////////////
+
+ class regex {
+ public:
+
+ enum RegFlags {
+ optimize = 0,
+ match_extra = 0,
+ icase = REG_ICASE,
+ nosubs = REG_NOSUB,
+ match_extended = REG_EXTENDED
+ };
+
+ regex(const std::string& s,int flags = match_extended);
+ ~regex() throw();
+
+
+ public:
+ regex_t m_preg;
+ bool m_valid;
+ };
+
+
+ class smatch {
+ public:
+ smatch();
+
+ std::string operator[](unsigned i) const;
+
+ unsigned size() const;
+
+ std::string match_str;
+ regmatch_t pmatch[12];
+ };
+
+ bool regex_match(const std::string& s, str::smatch& matches, const regex& regex);
+ bool regex_match(const std::string& s, const regex& regex);
+ bool regex_search(const std::string& s, str::smatch& matches, const regex& regex);
+
+ /////////////////////////////////////////////////////////////////
+ } // namespace str
+ ///////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_BASE_STRING_H
Modified: trunk/libzypp/zypp/base/String.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/base/String.cc?rev=6586&r1=6585&r2=6586&view=diff
==============================================================================
--- trunk/libzypp/zypp/base/String.cc (original)
+++ trunk/libzypp/zypp/base/String.cc Fri Aug 10 16:08:27 2007
@@ -188,15 +188,6 @@
return _getline(str, trim?TRIM:NO_TRIM);
}
- std::ostream & dumpRegexpResult( const boost::smatch &what, std::ostream & str )
- {
- for ( unsigned int k=0; k < what.size(); k++)
- {
- str << "[match "<< k << "] [" << what[k] << "]" << std::endl;
- }
-
- return str;
- }
/////////////////////////////////////////////////////////////////
} // namespace str
///////////////////////////////////////////////////////////////////
Modified: trunk/libzypp/zypp/base/String.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/base/String.h?rev=6586&r1=6585&r2=6586&view=diff
==============================================================================
--- trunk/libzypp/zypp/base/String.h (original)
+++ trunk/libzypp/zypp/base/String.h Fri Aug 10 16:08:27 2007
@@ -14,7 +14,6 @@
#include <iosfwd>
#include <string>
-#include
#include "zypp/base/PtrTypes.h"
@@ -100,6 +99,7 @@
//@{
/** regex */
+#if 0
using boost::regex;
using boost::regex_match;
using boost::regex_search;
@@ -116,6 +116,7 @@
* helper to debug regular expressions matches
*/
std::ostream & dumpRegexpResult( const boost::smatch &what, std::ostream & str );
+#endif
///////////////////////////////////////////////////////////////////
/** \name String representation of number.
@@ -263,7 +264,7 @@
// build string
*result_r = std::string( beg, cur-beg );
// skip sepchars
- while ( sepchars_r.find( *cur ) != std::string::npos )
+ while ( cur != beg && sepchars_r.find( *cur ) != std::string::npos )
++cur;
}
return ret;
@@ -338,6 +339,9 @@
std::string getline( std::istream & str, const Trim trim_r );
+ inline bool startsWith(const std::string& s, const char* str) { return s.find(str) == 0; }
+ inline bool contains(const std::string& s, const char* str) { return s.find(str) != std::string::npos; }
+
///////////////////////////////////////////////////////////////////
/** \name String prefix handling.
@@ -351,7 +355,6 @@
inline std::string stripPrefix( const std::string & str_r, const std::string & prefix_r )
{ return( hasPrefix( str_r, prefix_r ) ? str_r.substr( prefix_r.size() ) : str_r ); }
//@}
-
/////////////////////////////////////////////////////////////////
} // namespace str
///////////////////////////////////////////////////////////////////
Modified: trunk/libzypp/zypp/capability/CapabilityImpl.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/capability/CapabilityImpl.cc?rev=6586&r1=6585&r2=6586&view=diff
==============================================================================
--- trunk/libzypp/zypp/capability/CapabilityImpl.cc (original)
+++ trunk/libzypp/zypp/capability/CapabilityImpl.cc Fri Aug 10 16:08:27 2007
@@ -10,6 +10,7 @@
*
*/
#include <iostream>
+#include <vector>
#include "zypp/base/Logger.h"
#include "zypp/base/Exception.h"
@@ -156,11 +157,10 @@
}
//split: name:/absolute/path
- static const str::regex rx( "([^/]*):(/.*)" );
- str::smatch what;
- if( str::regex_match( name_r.begin(), name_r.end(), what, rx ) )
+ std::vectorstd::string what;
+ if (str::split( name_r, std::back_inserter(what), ":") >= 2)
{
- return new capability::SplitCap( refers_r, what[1].str(), what[2].str() );
+ return new capability::SplitCap( refers_r, what[0], what[1] );
}
//name: name
@@ -196,13 +196,12 @@
}
//split: hal(name) [op string]
- static const str::regex rx( "hal\\(([^)]*)\\)" );
- str::smatch what;
- if( str::regex_match( name_r.begin(), name_r.end(), what, rx ) )
+ std::vectorstd::string what;
+ if (str::split( name_r, std::back_inserter(what), ")"))
{
// Hal always refers to 'System' kind of Resolvable.
return new capability::HalCap( ResTraits<SystemResObject>::kind,
- what[1].str() );
+ what[0].substr(strlen("hal(")) );
}
// otherwise
ZYPP_THROW( Exception("Unsupported kind of Hal Capability '" + name_r + "'") );
@@ -220,13 +219,12 @@
}
//split: modalias(name) [op string]
- static const str::regex rx( "modalias\\(([^)]*)\\)" );
- str::smatch what;
- if( str::regex_match( name_r.begin(), name_r.end(), what, rx ) )
+ std::vectorstd::string what;
+ if (str::split( name_r, std::back_inserter(what), ")"))
{
// Modalias always refers to 'System' kind of Resolvable
return new capability::ModaliasCap( ResTraits<SystemResObject>::kind,
- what[1].str() );
+ what[0].substr(strlen("modalias(")));
}
// otherwise
ZYPP_THROW( Exception("Unsupported kind of Modalias Capability'" + name_r + "'") );
@@ -242,13 +240,12 @@
const std::string & name_r )
{
//split: filesystem(name) [op string]
- static const str::regex rx( "filesystem\\(([^)]*)\\)" );
- str::smatch what;
- if( str::regex_match( name_r.begin(), name_r.end(), what, rx ) )
+ std::vectorstd::string what;
+ if (str::split( name_r, std::back_inserter(what), ")"))
{
// Filesystem always refers to 'System' kind of Resolvable
return new capability::FilesystemCap( ResTraits<SystemResObject>::kind,
- what[1].str() );
+ what[0].substr(strlen("filesystem(")) );
}
// otherwise
ZYPP_THROW( Exception("Unsupported kind of Filesystem Capability'" + name_r + "'") );
@@ -278,17 +275,15 @@
}
// strval_r has at least two words which could make 'op edition'?
- // improve regex!
- static const str::regex rx( "(.*[^ \t])([ \t]+)([^ \t]+)([ \t]+)([^ \t]+)" );
- str::smatch what;
- if( str::regex_match( strval_r.begin(), strval_r.end(),what, rx ) )
+ std::vectorstd::string what;
+ if (str::split( strval_r, std::back_inserter(what)) >= 2)
{
Rel op;
Edition edition;
try
{
- op = Rel(what[3].str());
- edition = Edition(what[5].str());
+ op = Rel(what[1]);
+ edition = Edition(what[2]);
}
catch ( Exception & excpt )
{
@@ -301,7 +296,7 @@
// Valid 'op edition'
return buildVersioned( refers_r,
- what[1].str(), op, edition );
+ what[0], op, edition );
}
//else
// not a VersionedCap
Modified: trunk/libzypp/zypp/parser/plaindir/RepoParser.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/parser/plaindir/RepoParser.cc?rev=6586&r1=6585&r2=6586&view=diff
==============================================================================
--- trunk/libzypp/zypp/parser/plaindir/RepoParser.cc (original)
+++ trunk/libzypp/zypp/parser/plaindir/RepoParser.cc Fri Aug 10 16:08:27 2007
@@ -154,15 +154,17 @@
list<string> filenames = header->tag_filenames();
pkg->deps[Dep::PROVIDES] = header->tag_provides ( filerequires );
- static str::smatch what;
- static const str::regex filenameRegex( "/(s?bin|lib(64)?|etc)/|^/usr/(games/|share/(dict/words|magic\\.mime)$)|^/opt/gnome/games/",
- str::regex::optimize|str::regex::nosubs );
-
for (list<string>::const_iterator filename = filenames.begin();
filename != filenames.end();
++filename)
{
- if ( str::regex_search( filename->begin(), filename->end(), what, filenameRegex ) )
+ if (str::contains(*filename, "/bin/")
+ || str::contains(*filename, "/sbin")
+ || str::contains(*filename, "/lib") || str::contains(*filename, "/lib64/")
+ || str::contains(*filename, "/etc/")
+ || str::startsWith(*filename, "/usr/games")
+ || str::startsWith(*filename, "/usr/share/dict/words")
+ || str::startsWith(*filename, "/opt/gnome/games/"))
{
try {
pkg->deps[Dep::PROVIDES].insert(capability::buildFile( ResTraits<Package>::kind, *filename ));
Modified: trunk/libzypp/zypp/repo/Applydeltarpm.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/repo/Applydeltarpm.cc?rev=6586&r1=6585&r2=6586&view=diff
==============================================================================
--- trunk/libzypp/zypp/repo/Applydeltarpm.cc (original)
+++ trunk/libzypp/zypp/repo/Applydeltarpm.cc Fri Aug 10 16:08:27 2007
@@ -32,7 +32,6 @@
{ /////////////////////////////////////////////////////////////////
const Pathname applydeltarpm_prog( "/usr/bin/applydeltarpm" );
- const str::regex applydeltarpm_tick ( "([0-9]+) percent finished" );
/******************************************************************
**
@@ -43,16 +42,13 @@
const Progress & report_r = Progress() )
{
ExternalProgram prog( argv_r, ExternalProgram::Stderr_To_Stdout );
- str::smatch what;
for ( std::string line = prog.receiveLine(); ! line.empty(); line = prog.receiveLine() )
{
- if ( report_r && str::regex_search( line, what, applydeltarpm_tick ) )
- {
- report_r( str::strtonum<unsigned>( what[1] ) );
- }
+ if ( report_r )
+ report_r( str::strtonum<unsigned>( line ));
else
DBG << "Applydeltarpm : " << line;
- }
+ }
return( prog.close() == 0 );
}
Modified: trunk/libzypp/zypp/target/rpm/RpmDb.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/target/rpm/RpmDb.cc?rev=6586&r1=6585&r2=6586&view=diff
==============================================================================
--- trunk/libzypp/zypp/target/rpm/RpmDb.cc (original)
+++ trunk/libzypp/zypp/target/rpm/RpmDb.cc Fri Aug 10 16:08:27 2007
@@ -26,6 +26,7 @@
#include "zypp/base/Logger.h"
#include "zypp/base/String.h"
+#include "zypp/base/Regex.h"
#include "zypp/Date.h"
#include "zypp/Pathname.h"
@@ -1188,7 +1189,7 @@
filename != filenames.end();
++filename)
{
- if ( str::regex_search( filename->begin(), filename->end(), what, filenameRegex ) )
+ if ( str::regex_match( *filename, what, filenameRegex ) )
{
try
{
Modified: trunk/libzypp/zypp/url/UrlBase.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/url/UrlBase.cc?rev=6586&r1=6585&r2=6586&view=diff
==============================================================================
--- trunk/libzypp/zypp/url/UrlBase.cc (original)
+++ trunk/libzypp/zypp/url/UrlBase.cc Fri Aug 10 16:08:27 2007
@@ -12,7 +12,8 @@
#include
#include
#include
-
+#include
+
#include <stdexcept>
#include <climits>
#include
@@ -20,6 +21,7 @@
#include
#include
+#include <iostream>
// ---------------------------------------------------------------
/*
@@ -27,13 +29,8 @@
**
** host = hostname | IPv4 | "[" IPv6-IP "]" | "[v...]"
*/
-#define RX_SPLIT_AUTHORITY \
- "^(([^:@]*)([:]([^@]*))?@)?(\\[[^]]+\\]|[^:]+)?([:](.*))?"
-
#define RX_VALID_SCHEME "^[a-zA-Z][a-zA-Z0-9\\.+-]*$"
-#define RX_VALID_PORT "^[0-9]{1,5}$"
-
#define RX_VALID_HOSTNAME "^[[:alnum:]]+([\\.-][[:alnum:]]+)*$"
#define RX_VALID_HOSTIPV4 \
@@ -157,6 +154,7 @@
try
{
str::regex rex(regx);
+ std::cout << "testing *" << data << "* against *" << regx << "*" << std::endl;
valid = str::regex_match(data, rex);
}
catch( ... )
@@ -441,6 +439,8 @@
std::string url;
UrlBaseData tmp;
+ std::cout << "UrlBase:.asString()" << std::endl;
+
if( opts.has(ViewOptions::WITH_SCHEME))
{
tmp.scheme = getScheme();
@@ -474,6 +474,8 @@
}
}
+ std::cout << "tmp.host: *" << tmp.host << "*" << std::endl;
+
url += tmp.host;
if( opts.has(ViewOptions::WITH_PORT))
@@ -500,6 +502,7 @@
if( opts.has(ViewOptions::WITH_PATH_NAME))
{
tmp.pathname = getPathName(zypp::url::E_ENCODED);
+ std::cout << "pathname: *" << tmp.pathname << "*" << std::endl;
if( !tmp.pathname.empty())
{
if(url.find("/") != std::string::npos)
@@ -830,30 +833,34 @@
void
UrlBase::setAuthority(const std::string &authority)
{
- str::smatch out;
- bool ret = false;
+ std::string s = authority;
+ std::string::size_type p,q;
- try
- {
- str::regex rex(RX_SPLIT_AUTHORITY);
- ret = str::regex_match(authority, out, rex);
- }
- catch( ... )
- {}
+ std::string username, password, host, port;
- if( ret && out.size() == 8)
+ std::cout << "authority: " << authority << "*" << std::endl;
+
+ if ((p=s.find('@')) != std::string::npos)
{
- setUsername(out[2].str(), zypp::url::E_ENCODED);
- setPassword(out[4].str(), zypp::url::E_ENCODED);
- setHost(out[5].str());
- setPort(out[7].str());
+ q = s.find(':');
+ if (q != std::string::npos && q < p)
+ {
+ setUsername(s.substr(0, q), zypp::url::E_ENCODED);
+ setPassword(s.substr(q+1, p-q-1), zypp::url::E_ENCODED);
+ }
+ else
+ setUsername(s.substr(0, p), zypp::url::E_ENCODED);
+ s = s.substr(p+1);
}
- else
+ q = s.rfind(']');
+ if ((p = s.rfind(':')) != std::string::npos && p > q+1)
{
- ZYPP_THROW(UrlParsingException(
- _("Unable to parse Url authority")
- ));
+
+ setHost(s.substr(0, p));
+ setPort(s.substr(p+1));
}
+ else
+ setHost(s);
}
// ---------------------------------------------------------------
@@ -1016,6 +1023,8 @@
));
}
+ std::cout << "host: *" << host << "*" << std::endl;
+
if( isValidHost(host))
{
std::string temp;
@@ -1337,17 +1346,10 @@
bool
UrlBase::isValidPort(const std::string &port) const
{
- try
- {
- str::regex regx(RX_VALID_PORT);
- if( str::regex_match(port, regx))
- {
- long pnum = str::strtonum<long>(port);
- return ( pnum >= 1 && pnum <= USHRT_MAX);
- }
- }
- catch( ... )
- {}
+ char* endptr;
+ long pnum = strtol(port.c_str(), &endptr, 10);
+ return ( !port.empty() && !*endptr
+ && pnum >= 1 && pnum <= USHRT_MAX);
return false;
}
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org