summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2013-03-18 12:10:35 +0100
committerMichael Vogt <michael.vogt@ubuntu.com>2013-03-18 12:10:35 +0100
commitc8b860fb8d0f1531f99db4fad74f5892c6806f1b (patch)
treeb85add0077c0e280d44292073bb68a250f543101 /apt-pkg
parent55971004215609a02ca19c59bd058da20729ba11 (diff)
fix pkgTagSection::Exists() and add test
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/tagfile.cc9
-rw-r--r--apt-pkg/tagfile.h4
2 files changed, 10 insertions, 3 deletions
diff --git a/apt-pkg/tagfile.cc b/apt-pkg/tagfile.cc
index 79811899a..1c79ee74f 100644
--- a/apt-pkg/tagfile.cc
+++ b/apt-pkg/tagfile.cc
@@ -282,10 +282,17 @@ void pkgTagSection::Trim()
for (; Stop > Section + 2 && (Stop[-2] == '\n' || Stop[-2] == '\r'); Stop--);
}
/*}}}*/
+// TagSection::Exists - return True if a tag exists /*{{{*/
+bool pkgTagSection::Exists(const char* const Tag)
+{
+ unsigned int tmp;
+ return Find(Tag, tmp);
+}
+ /*}}}*/
// TagSection::Find - Locate a tag /*{{{*/
// ---------------------------------------------------------------------
/* This searches the section for a tag that matches the given string. */
-bool pkgTagSection::Find(const char *Tag,unsigned &Pos) const
+bool pkgTagSection::Find(const char *Tag,unsigned int &Pos) const
{
unsigned int Length = strlen(Tag);
unsigned int I = AlphaIndexes[AlphaHash(Tag)];
diff --git a/apt-pkg/tagfile.h b/apt-pkg/tagfile.h
index fd24471c1..4718f5101 100644
--- a/apt-pkg/tagfile.h
+++ b/apt-pkg/tagfile.h
@@ -59,7 +59,7 @@ class pkgTagSection
inline bool operator !=(const pkgTagSection &rhs) {return Section != rhs.Section;};
bool Find(const char *Tag,const char *&Start, const char *&End) const;
- bool Find(const char *Tag,unsigned &Pos) const;
+ bool Find(const char *Tag,unsigned int &Pos) const;
std::string FindS(const char *Tag) const;
signed int FindI(const char *Tag,signed long Default = 0) const ;
unsigned long long FindULL(const char *Tag, unsigned long long const &Default = 0) const;
@@ -73,7 +73,7 @@ class pkgTagSection
virtual void TrimRecord(bool BeforeRecord, const char* &End);
inline unsigned int Count() const {return TagCount;};
- inline bool Exists(const char* const Tag) {return AlphaIndexes[AlphaHash(Tag)] != 0;}
+ bool Exists(const char* const Tag);
inline void Get(const char *&Start,const char *&Stop,unsigned int I) const
{Start = Section + Indexes[I]; Stop = Section + Indexes[I+1];}