int pivSubCompare(char *strInput1, int intSP1, int intEP1, char *strInput2, int intSP2, int intEP2) { int intLoop1, intLoop2; int intMax = 0; int intCnt, intNS1, intNS2; char *p1, *p2; intNS1 = intNS2 = -1; intCnt = 0; if((intSP1 > intEP1) || (intSP2 > intEP2) || (intSP1 < 0) || (intSP2 < 0)) return 0; for(intLoop1 = intSP1; intLoop1 < intEP1; intLoop1++) { for(intLoop2 = intSP2; intLoop2 < intEP2; intLoop2++) { p1 = strInput1 + intLoop1; p2 = strInput2 + intLoop2; intCnt = 0; while((*p1 == *p2) && (*p1 != '\0') && (*p2 != '\0')) { intCnt++; if(intCnt > intMax) { intNS1 = intLoop1; intNS2 = intLoop2; intMax = intCnt; if(intMax == (intEP2 - intSP2)) return intMax; } p1++; p2++; } } } intMax += pivSubCompare(strInput1, intNS1 + intMax, intEP1, strInput2, intNS2 + intMax, intEP2); intMax += pivSubCompare(strInput1, intSP1, intNS1 - 1, strInput2, intSP2, intNS2 - 1); return intMax; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)