Brian is right. It makes more sense to compute the alignment based on the offset than the the beginning of the vector.

CCBUG:135123


git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib@689545 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
This commit is contained in:
Scott Wheeler 2007-07-18 14:38:40 +00:00
parent 951ef149d2
commit 61fcb74d49
2 changed files with 5 additions and 5 deletions

View File

@ -100,7 +100,7 @@ namespace TagLib {
if(pattern.size() == 1) {
char p = pattern[0];
for(uint i = offset; i < v.size(); i++) {
if(v[i] == p && i % byteAlign == 0)
if(v[i] == p && (i - offset) % byteAlign == 0)
return i;
}
return -1;
@ -123,7 +123,7 @@ namespace TagLib {
--iPattern;
}
if(-1 == iPattern && (iBuffer + 1) % byteAlign == 0)
if(-1 == iPattern && (iBuffer + 1 - offset) % byteAlign == 0)
return iBuffer + 1;
}

View File

@ -124,8 +124,8 @@ namespace TagLib {
/*!
* Searches the ByteVector for \a pattern starting at \a offset and returns
* the offset. Returns -1 if the pattern was not found. If \a byteAlign is
* specified the pattern will only be matched if it starts on a byteDivisible
* by \a byteAlign.
* specified the pattern will only be matched if it starts on a byte divisible
* by \a byteAlign (starting from \a offset).
*/
int find(const ByteVector &pattern, uint offset = 0, int byteAlign = 1) const;
@ -133,7 +133,7 @@ namespace TagLib {
* Searches the ByteVector for \a pattern starting from either the end of the
* vector or \a offset and returns the offset. Returns -1 if the pattern was
* not found. If \a byteAlign is specified the pattern will only be matched
* if it starts on a byteDivisible by \a byteAlign.
* if it starts on a byte divisible by \a byteAlign (starting from \a offset).
*/
int rfind(const ByteVector &pattern, uint offset = 0, int byteAlign = 1) const;