diff options
-rw-r--r-- | apt-pkg/contrib/strutl.h | 18 | ||||
-rw-r--r-- | apt-pkg/pkgcachegen.cc | 8 | ||||
-rw-r--r-- | apt-pkg/version.h | 21 |
3 files changed, 17 insertions, 30 deletions
diff --git a/apt-pkg/contrib/strutl.h b/apt-pkg/contrib/strutl.h index 715812a80..7112c8da7 100644 --- a/apt-pkg/contrib/strutl.h +++ b/apt-pkg/contrib/strutl.h @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: strutl.h,v 1.18 2001/05/27 05:19:30 jgg Exp $ +// $Id: strutl.h,v 1.19 2001/05/27 05:55:27 jgg Exp $ /* ###################################################################### String Util - These are some useful string functions @@ -59,15 +59,17 @@ bool TokSplitString(char Tok,char *Input,char **List, void ioprintf(ostream &out,const char *format,...) APT_FORMAT2; bool CheckDomainList(string Host,string List); -int stringcmp(const char *A,const char *AEnd,const char *B,const char *BEnd); -inline int stringcmp(const char *A,const char *AEnd,const char *B) {return stringcmp(A,AEnd,B,B+strlen(B));}; -inline int stringcmp(string A,const char *B) {return stringcmp(A.c_str(),A.c_str()+A.length(),B,B+strlen(B));}; +#define APT_MKSTRCMP(name,func) \ +inline int name(const char *A,const char *AEnd,const char *B) {return func(A,AEnd,B,B+strlen(B));}; \ +inline int name(string A,const char *B) {return func(A.c_str(),A.c_str()+A.length(),B,B+strlen(B));}; \ +inline int name(string A,string B) {return func(A.c_str(),A.c_str()+A.length(),B.c_str(),B.c_str()+B.length());}; \ +inline int name(string A,const char *B,const char *BEnd) {return func(A.c_str(),A.c_str()+A.length(),B,BEnd);}; +int stringcmp(const char *A,const char *AEnd,const char *B,const char *BEnd); int stringcasecmp(const char *A,const char *AEnd,const char *B,const char *BEnd); -inline int stringcasecmp(const char *A,const char *AEnd,const char *B) {return stringcasecmp(A,AEnd,B,B+strlen(B));}; -inline int stringcasecmp(string A,const char *B) {return stringcasecmp(A.c_str(),A.c_str()+A.length(),B,B+strlen(B));}; -inline int stringcasecmp(string A,string B) {return stringcasecmp(A.c_str(),A.c_str()+A.length(),B.c_str(),B.c_str()+B.length());}; -inline int stringcasecmp(string A,const char *B,const char *BEnd) {return stringcasecmp(A.c_str(),A.c_str()+A.length(),B,BEnd);}; + +APT_MKSTRCMP(stringcmp,stringcmp); +APT_MKSTRCMP(stringcasecmp,stringcasecmp); inline const char *DeNull(const char *s) {return (s == 0?"(null)":s);}; diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc index 031f9b807..026f795eb 100644 --- a/apt-pkg/pkgcachegen.cc +++ b/apt-pkg/pkgcachegen.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: pkgcachegen.cc,v 1.48 2001/05/27 05:36:04 jgg Exp $ +// $Id: pkgcachegen.cc,v 1.49 2001/05/27 05:55:27 jgg Exp $ /* ###################################################################### Package Cache Generator - Generator for the cache structure. @@ -134,8 +134,7 @@ bool pkgCacheGenerator::MergeList(ListParser &List, int Res = 1; for (; Ver.end() == false; Last = &Ver->NextVer, Ver++) { - Res = Cache.VS->DoCmpVersion(Version.c_str(),Version.c_str()+Version.length(),Ver.VerStr(), - Ver.VerStr() + strlen(Ver.VerStr())); + Res = Cache.VS->CmpVersion(Version,Ver.VerStr()); if (Res >= 0) break; } @@ -166,8 +165,7 @@ bool pkgCacheGenerator::MergeList(ListParser &List, { for (; Ver.end() == false; Last = &Ver->NextVer, Ver++) { - Res = Cache.VS->DoCmpVersion(Version.c_str(),Version.c_str()+Version.length(),Ver.VerStr(), - Ver.VerStr() + strlen(Ver.VerStr())); + Res = Cache.VS->CmpVersion(Version,Ver.VerStr()); if (Res != 0) break; } diff --git a/apt-pkg/version.h b/apt-pkg/version.h index 4c37ba8f8..071dba3e2 100644 --- a/apt-pkg/version.h +++ b/apt-pkg/version.h @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: version.h,v 1.7 2001/05/14 05:58:33 jgg Exp $ +// $Id: version.h,v 1.8 2001/05/27 05:55:27 jgg Exp $ /* ###################################################################### Version - Versioning system.. @@ -24,6 +24,7 @@ #pragma interface "apt-pkg/version.h" #endif +#include <apt-pkg/strutl.h> #include <string> using std::string; @@ -52,22 +53,8 @@ class pkgVersioningSystem {return this == &Against;}; // Shortcuts - inline int CmpVersion(const char *A, const char *B) - { - return DoCmpVersion(A,A+strlen(A),B,B+strlen(B)); - }; - inline int CmpVersion(string A,string B) - { - return DoCmpVersion(A.c_str(),A.c_str()+A.length(),B.c_str(),B.c_str()+B.length()); - }; - inline int CmpReleaseVer(const char *A, const char *B) - { - return DoCmpReleaseVer(A,A+strlen(A),B,B+strlen(B)); - }; - inline int CmpReleaseVer(string A,string B) - { - return DoCmpReleaseVer(A.c_str(),A.c_str()+A.length(),B.c_str(),B.c_str()+B.length()); - }; + APT_MKSTRCMP(CmpVersion,DoCmpVersion); + APT_MKSTRCMP(CmpReleaseVer,DoCmpReleaseVer); pkgVersioningSystem(); virtual ~pkgVersioningSystem() {}; |