rendered paste bodyvoid GetNextToken(inputPtr *p, lzToken *pTok)
{
uint8_t *pStart = p->p + p->pos;
uint8_t *pBestFind=pStart;
uint16_t bestLen=0;
uint16_t histSize = (uint16_t)(GetHistSize(p));
uint8_t *pHistStart = pStart-histSize;
uint16_t i;
uint16_t maxSearch;
uint8_t len;
if (histSize > 0){
for(i=histSize-1;i>0;i--){//go backwards so we fins the closest
maxSearch = rcMin(histSize+LOOKAHEAD_LEN-i-1,MAX_MATCH);
if (maxSearch < 3)
continue;
len = matchlen(pStart,pHistStart+i,maxSearch);
if ((len > 3) && (len > bestLen)){
bestLen = len;
pBestFind = pHistStart+i;
if (len == MAX_MATCH)
break;
if (SKIP_PAST_MATCH && (i>len))
i-=len;
}
}
}
pTok->length = bestLen;
pTok->offset = (uint16_t)(pStart - pBestFind);
}