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;
--iPattern;
}
- if(-1 == iPattern && (iBuffer + 1) % byteAlign == 0)
+ if(-1 == iPattern && (iBuffer + 1 - offset) % byteAlign == 0)
return iBuffer + 1;
}
/*!
* 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;
* 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;