From 61fcb74d49060187d38e8807a4fbc2302df7e39f Mon Sep 17 00:00:00 2001 From: Scott Wheeler Date: Wed, 18 Jul 2007 14:38:40 +0000 Subject: [PATCH] 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 --- taglib/toolkit/tbytevector.cpp | 4 ++-- taglib/toolkit/tbytevector.h | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/taglib/toolkit/tbytevector.cpp b/taglib/toolkit/tbytevector.cpp index 363b7685..26dd18cb 100644 --- a/taglib/toolkit/tbytevector.cpp +++ b/taglib/toolkit/tbytevector.cpp @@ -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; } diff --git a/taglib/toolkit/tbytevector.h b/taglib/toolkit/tbytevector.h index 5dbab36b..462b0d1d 100644 --- a/taglib/toolkit/tbytevector.h +++ b/taglib/toolkit/tbytevector.h @@ -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;