Match all the chars in multichar terminators that are prefixed with '&'.

r981 | ffr | 2006-05-08 13:39:25 +1000 (Mon, 08 May 2006) | 2 lines
This commit is contained in:
Ferdi Franceschini
2006-05-08 13:39:25 +10:00
committed by Douglas Clowes
parent d4923a14d8
commit 1152141fa2

View File

@@ -555,7 +555,7 @@ int NETReadTillTerm(mkChannel *self, long timeout,
char *pTerm, char *pBuffer, int iBufLen) char *pTerm, char *pBuffer, int iBufLen)
{ {
struct timeval start, now; struct timeval start, now;
int bufPtr = 0, status, i, length; int bufPtr = 0, status, i, length, matchIndex=1;
char c; char c;
long dif; long dif;
@@ -583,6 +583,7 @@ int NETReadTillTerm(mkChannel *self, long timeout,
{ {
return status; return status;
} }
if ('&' != pTerm[0]) {
for(i = 0; i < length; i++) for(i = 0; i < length; i++)
{ {
if(c == pTerm[i]) if(c == pTerm[i])
@@ -590,6 +591,23 @@ int NETReadTillTerm(mkChannel *self, long timeout,
return bufPtr+1; return bufPtr+1;
} }
} }
} else {
if (matchIndex == 1 && c == pTerm[1]) {
matchIndex++;
} else {
if (c== pTerm[matchIndex] && matchIndex < length -1) {
matchIndex++;
} else {
if (c == pTerm[matchIndex] && matchIndex == length - 1) {
bufPtr = bufPtr - matchIndex + 1;
pBuffer[bufPtr] = '\0';
return bufPtr;
} else {
matchIndex == 1;
}
}
}
}
if (c == 0 && *pTerm != 0) if (c == 0 && *pTerm != 0)
{ {
/* a null character is an error, except when no terminator is defined (binary data) */ /* a null character is an error, except when no terminator is defined (binary data) */