CharBufferCore:

- Bug fix - FindStr() for input marker not matching correctly
SeletableBare/Core:
- Reformat code - eliminate & compact {} where needed
This commit is contained in:
2021-10-12 10:14:35 -05:00
parent c4fc72ca23
commit e5f8a8347a
3 changed files with 304 additions and 517 deletions

View File

@@ -266,10 +266,10 @@ int CRollingBuffer::PeekCopy( char ** Data, int PeekPos, int MaxLen )
// Look for first occurrence of character in buffer
bool CRollingBuffer::FindStr( const char * SearchStr, int SearchLen, int &FoundPos, int StartPos )
{
char * CheckPos = NULL;
char * CheckLimit = NULL;
char * MatchPos = NULL;
char * MatchLimit = NULL;
const char * CheckPos = NULL;
const char * CheckLimit = NULL;
const char * MatchPos = NULL;
const char * MatchLimit = NULL;
// Check if buffer exists
if (!BufSize || !SearchStr || !SearchLen) {
@@ -288,8 +288,8 @@ bool CRollingBuffer::FindStr( const char * SearchStr, int SearchLen, int &FoundP
CheckLimit = &Buffer[BufSize-1];
// Set Match start point and limit
MatchPos = (char*)SearchStr;
MatchLimit = (char*)&SearchStr[SearchLen-1];
MatchPos = SearchStr;
MatchLimit = &SearchStr[SearchLen-1];
// Search for char
FoundPos = StartPos;
@@ -307,9 +307,10 @@ bool CRollingBuffer::FindStr( const char * SearchStr, int SearchLen, int &FoundP
MatchPos++;
}
}
else {
else if (MatchPos != SearchStr){
// Reset match point
MatchPos = (char*)SearchStr;
FoundPos -= MatchPos - SearchStr;
MatchPos = SearchStr;
}
// Next char