importing my current diff
authorDuncan Mac-Vicar P <dmacvicar@suse.de>
Fri, 10 Aug 2007 14:08:27 +0000 (14:08 +0000)
committerDuncan Mac-Vicar P <dmacvicar@suse.de>
Fri, 10 Aug 2007 14:08:27 +0000 (14:08 +0000)
19 files changed:
CMakeLists.txt
zypp/CMakeLists.txt
zypp/Dep.h
zypp/Edition.cc
zypp/KVMap.h
zypp/KeyRing.cc
zypp/MediaSetAccess.cc
zypp/Pathname.h
zypp/PublicKey.cc
zypp/Url.cc
zypp/base/Regex.cc
zypp/base/Regex.h
zypp/base/String.cc
zypp/base/String.h
zypp/capability/CapabilityImpl.cc
zypp/parser/plaindir/RepoParser.cc
zypp/repo/Applydeltarpm.cc
zypp/target/rpm/RpmDb.cc
zypp/url/UrlBase.cc

index 3fb4432..4750bcb 100644 (file)
@@ -27,8 +27,8 @@ MATH( EXPR LIBZYPP_SO_FIRST  "${LIBZYPP_CURRENT}-${LIBZYPP_AGE}" )
 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}" )
index ef789d9..4ffd1c6 100644 (file)
@@ -201,6 +201,7 @@ SET( zypp_base_SRCS
   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 @@ SET( zypp_base_HEADERS
   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 @@ ADD_LIBRARY(zypp SHARED ${zypp_lib_SRCS})
 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} )
index 5982a1e..e2d694c 100644 (file)
@@ -12,7 +12,7 @@
 #ifndef ZYPP_DEP_H
 #define ZYPP_DEP_H
 
-#include <iosfwd>
+#include <iostream>
 #include <string>
 
 ///////////////////////////////////////////////////////////////////
index e7f645f..bab580c 100644 (file)
@@ -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 @@ namespace zypp
     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 @@ namespace zypp
   };
   ///////////////////////////////////////////////////////////////////
 
-  const str::regex Edition::Impl::_rxEdition( "(([0-9]+):)?([^-]*)(-([^-]*))?" );
+  const str::regex Edition::Impl::_rxEdition( "([0-9]+:)?([^-]*)(-[^-]*)?" );
 
   ///////////////////////////////////////////////////////////////////
 
index ff22f86..4846e9b 100644 (file)
@@ -22,6 +22,7 @@
 #define KVMap_h
 
 #include <iosfwd>
+#include <vector>
 #include <map>
 
 #include "zypp/base/String.h"
index 9fd0b03..b287d37 100644 (file)
@@ -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 @@ namespace zypp
     {
       //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 @@ namespace zypp
           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 @@ namespace zypp
     {
       //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];
index 019a7d0..c340fb6 100644 (file)
@@ -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 @@ IMPL_PTR_TYPE(MediaSetAccess);
       // 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 @@ IMPL_PTR_TYPE(MediaSetAccess);
     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];
index 494fee4..cdd061e 100644 (file)
@@ -12,7 +12,7 @@
 #ifndef ZYPP_PATHNAME_H
 #define ZYPP_PATHNAME_H
 
-#include <iosfwd>
+#include <iostream>
 #include <string>
 
 ///////////////////////////////////////////////////////////////////
index 9241066..da77013 100644 (file)
@@ -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 @@ namespace zypp
         {
         //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" )
             {
index 5eaed4b..a56c76e 100644 (file)
@@ -12,7 +12,9 @@
 #include <zypp/Url.h>
 #include <zypp/base/Gettext.h>
 #include <zypp/base/String.h>
+#include <zypp/base/Regex.h>
 #include <stdexcept>
+#include <iostream>
 
 
 //////////////////////////////////////////////////////////////////////
@@ -27,11 +29,11 @@ namespace zypp
   /*
    * url       = [scheme:] [//authority] /path [?query] [#fragment]
    */
-  #define RX_SPLIT_URL                       "^(([^:/?#]+):)?" \
-                                             "(//([^/?#]*))?"  \
+  #define RX_SPLIT_URL                       "^([^:/?#]+:|)" \
+                                             "(//[^/?#]*|)"  \
                                              "([^?#]*)"        \
-                                             "([?]([^#]*))?"   \
-                                             "(#(.*))?"
+                                             "([?][^#]*|)"   \
+                                             "(#.*|)"
 
 
   ////////////////////////////////////////////////////////////////////
@@ -374,18 +376,33 @@ namespace zypp
     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;
   }
index 03f0f79..be6cd8f 100644 (file)
@@ -76,3 +76,81 @@ unsigned smatch::size() const
 
     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(&regex.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(&regex.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(&regex.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;
+}
index 650d5f8..fe8d510 100644 (file)
@@ -71,3 +71,76 @@ namespace zypp
 } // 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 <regex.h>
+
+///////////////////////////////////////////////////////////////////
+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
index e342e2c..7bb7948 100644 (file)
@@ -188,15 +188,6 @@ namespace zypp
       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
   ///////////////////////////////////////////////////////////////////
index 8a33a0f..dff3b37 100644 (file)
@@ -14,7 +14,6 @@
 
 #include <iosfwd>
 #include <string>
-#include <boost/regex.hpp>
 
 #include "zypp/base/PtrTypes.h"
 
@@ -100,6 +99,7 @@ namespace zypp
 
     //@{
     /** regex */
+#if 0    
     using boost::regex;
     using boost::regex_match;
     using boost::regex_search;
@@ -116,6 +116,7 @@ namespace zypp
      * 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 @@ namespace zypp
             // 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 @@ namespace zypp
 
     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 @@ namespace zypp
     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
   ///////////////////////////////////////////////////////////////////
index f7bd3d0..802fdd4 100644 (file)
@@ -10,6 +10,7 @@
  *
 */
 #include <iostream>
+#include <vector>
 
 #include "zypp/base/Logger.h"
 #include "zypp/base/Exception.h"
@@ -156,11 +157,10 @@ namespace zypp
       }
 
       //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::vector<std::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 @@ namespace zypp
        }
 
       //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::vector<std::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 @@ namespace zypp
        }
 
       //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::vector<std::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 @@ namespace zypp
                                       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::vector<std::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 @@ namespace zypp
         }
 
       // 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::vector<std::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 @@ namespace zypp
 
           // Valid 'op edition'
           return buildVersioned( refers_r,
-                                 what[1].str(), op, edition );
+                                 what[0], op, edition );
         }
       //else
       // not a VersionedCap
index 61e91d6..c3efa9e 100644 (file)
@@ -154,15 +154,17 @@ data::Package_Ptr makePackageDataFromHeader( const RpmHeader::constPtr header,
 
   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 ));
index ccd3e1a..4f79a13 100644 (file)
@@ -32,7 +32,6 @@ namespace zypp
     { /////////////////////////////////////////////////////////////////
 
       const Pathname   applydeltarpm_prog( "/usr/bin/applydeltarpm" );
-      const str::regex applydeltarpm_tick ( "([0-9]+) percent finished" );
 
       /******************************************************************
        **
@@ -43,16 +42,13 @@ namespace zypp
                           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 );
       }
 
index dcc519a..4d2ed77 100644 (file)
@@ -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 @@ Package::Ptr RpmDb::makePackageFromHeader( const RpmHeader::constPtr header,
        filename != filenames.end();
        ++filename)
   {
-    if ( str::regex_search( filename->begin(), filename->end(), what, filenameRegex ) )
+    if ( str::regex_match( *filename, what, filenameRegex ) )
     {
       try
       {
index 887b3f3..6c9b002 100644 (file)
@@ -12,7 +12,8 @@
 #include <zypp/url/UrlBase.h>
 #include <zypp/base/String.h>
 #include <zypp/base/Gettext.h>
+#include <zypp/base/Regex.h>
+
 #include <stdexcept>
 #include <climits>
 #include <errno.h>
@@ -20,6 +21,7 @@
 #include <sys/socket.h>
 #include <arpa/inet.h>
 
+#include <iostream>
 
 // ---------------------------------------------------------------
 /*
 **
 ** 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 @@ namespace zypp
           try
           {
             str::regex rex(regx);
+            std::cout << "testing *" << data << "* against *" << regx << "*" << std::endl;
             valid = str::regex_match(data, rex);
           }
           catch( ... )
@@ -441,6 +439,8 @@ namespace zypp
       std::string   url;
       UrlBaseData   tmp;
 
+      std::cout << "UrlBase:.asString()" << std::endl;
+
       if( opts.has(ViewOptions::WITH_SCHEME))
       {
         tmp.scheme = getScheme();
@@ -474,6 +474,8 @@ namespace zypp
                 }
               }
 
+              std::cout << "tmp.host: *" << tmp.host << "*" << std::endl;
+
               url += tmp.host;
 
               if( opts.has(ViewOptions::WITH_PORT))
@@ -500,6 +502,7 @@ namespace zypp
       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 @@ namespace zypp
     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 @@ namespace zypp
           ));
         }
 
+        std::cout << "host: *" << host << "*" << std::endl;
+
         if( isValidHost(host))
         {
           std::string temp;
@@ -1337,17 +1346,10 @@ namespace zypp
     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;
     }