diff options
Diffstat (limited to 'apt-pkg/deb')
-rw-r--r-- | apt-pkg/deb/debrecords.cc | 28 | ||||
-rw-r--r-- | apt-pkg/deb/debrecords.h | 1 | ||||
-rw-r--r-- | apt-pkg/deb/debsrcrecords.cc | 2 | ||||
-rw-r--r-- | apt-pkg/deb/debsrcrecords.h | 2 |
4 files changed, 30 insertions, 3 deletions
diff --git a/apt-pkg/deb/debrecords.cc b/apt-pkg/deb/debrecords.cc index 5421b3db7..8a5b6e215 100644 --- a/apt-pkg/deb/debrecords.cc +++ b/apt-pkg/deb/debrecords.cc @@ -108,18 +108,44 @@ string debRecordParser::LongDesc() return orig; } /*}}}*/ + +static const char *SourceVerSeparators = " ()"; + // RecordParser::SourcePkg - Return the source package name if any /*{{{*/ // --------------------------------------------------------------------- /* */ string debRecordParser::SourcePkg() { string Res = Section.FindS("Source"); - string::size_type Pos = Res.find(' '); + string::size_type Pos = Res.find_first_of(SourceVerSeparators); if (Pos == string::npos) return Res; return string(Res,0,Pos); } /*}}}*/ +// RecordParser::SourceVer - Return the source version number if present /*{{{*/ +// --------------------------------------------------------------------- +/* */ +string debRecordParser::SourceVer() +{ + string Pkg = Section.FindS("Source"); + string::size_type Pos = Pkg.find_first_of(SourceVerSeparators); + if (Pos == string::npos) + return ""; + + string::size_type VerStart = Pkg.find_first_not_of(SourceVerSeparators, Pos); + if(VerStart == string::npos) + return ""; + + string::size_type VerEnd = Pkg.find_first_of(SourceVerSeparators, VerStart); + if(VerEnd == string::npos) + // Corresponds to the case of, e.g., "foo (1.2" without a closing + // paren. Be liberal and guess what it means. + return string(Pkg, VerStart); + else + return string(Pkg, VerStart, VerEnd - VerStart); +} + /*}}}*/ // RecordParser::GetRec - Return the whole record /*{{{*/ // --------------------------------------------------------------------- /* */ diff --git a/apt-pkg/deb/debrecords.h b/apt-pkg/deb/debrecords.h index fdf8d762b..df21931a8 100644 --- a/apt-pkg/deb/debrecords.h +++ b/apt-pkg/deb/debrecords.h @@ -36,6 +36,7 @@ class debRecordParser : public pkgRecords::Parser virtual string MD5Hash(); virtual string SHA1Hash(); virtual string SourcePkg(); + virtual string SourceVer(); // These are some general stats about the package virtual string Maintainer(); diff --git a/apt-pkg/deb/debsrcrecords.cc b/apt-pkg/deb/debsrcrecords.cc index 7338de15d..fcd9bb901 100644 --- a/apt-pkg/deb/debsrcrecords.cc +++ b/apt-pkg/deb/debsrcrecords.cc @@ -36,7 +36,7 @@ const char **debSrcRecordParser::Binaries() { delete [] Buffer; // allocate new size based on buffer (but never smaller than 4000) - BufSize = max((unsigned long)4000, max((unsigned long)Bins.length()+1,2*BufSize)); + BufSize = max((unsigned int)4000, max((unsigned int)Bins.length()+1,2*BufSize)); Buffer = new char[BufSize]; } diff --git a/apt-pkg/deb/debsrcrecords.h b/apt-pkg/deb/debsrcrecords.h index 55fdcb667..8b1237ccd 100644 --- a/apt-pkg/deb/debsrcrecords.h +++ b/apt-pkg/deb/debsrcrecords.h @@ -24,7 +24,7 @@ class debSrcRecordParser : public pkgSrcRecords::Parser char *StaticBinList[400]; unsigned long iOffset; char *Buffer; - unsigned long BufSize; + unsigned int BufSize; public: |