- Timestamp:
- Mar 10, 2011, 7:35:02 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/src/RpDiffview.c
r2125 r2132 83 83 int index1; /* index in buffer #1 */ 84 84 int index2; /* index in buffer #2 */ 85 struct subseq *subseqPtr; /* LCS indices for buffer #1*/85 int next; /* next candidate match in the chain */ 86 86 } DiffviewSubseq; 87 87 … … 2389 2389 Tcl_HashEntry *entryPtr; 2390 2390 Tcl_DString buffer; 2391 DiffviewSubseq *K, *newK, *candidate,newCandidate; int Kmax; int Klen;2391 DiffviewSubseq *K, *newK, newCandidate; int Kmax; int Klen; 2392 2392 Tcl_Obj *listPtr, **objv; 2393 int i, j, subseqLen, longestMatch, max, min, mid, midval, sLen, del; 2393 int i, j, candidateIdx, subseqLen, longestMatch; 2394 int max, min, mid, midval, sLen, del; 2394 2395 int len, created, o, objc, index1, *lcsIndex1, index2, *lcsIndex2; 2395 2396 char *key; … … 2428 2429 K[0].index1 = -1; 2429 2430 K[0].index2 = -1; 2430 K[0]. subseqPtr = NULL;2431 K[0].next = -1; 2431 2432 K[1].index1 = limsPtr1->numLines; 2432 2433 K[1].index2 = limsPtr2->numLines; 2433 K[1]. subseqPtr = NULL;2434 K[1].next = -1; 2434 2435 Klen = 2; 2435 2436 longestMatch = 0; … … 2448 2449 if (entryPtr) { 2449 2450 subseqLen = 0; 2450 candidate = &K[0];2451 candidateIdx = 0; 2451 2452 2452 2453 listPtr = (Tcl_Obj*)Tcl_GetHashValue(entryPtr); … … 2489 2490 */ 2490 2491 if (subseqLen >= 0) { 2491 K[subseqLen].index1 = candidate->index1; 2492 K[subseqLen].index2 = candidate->index2; 2493 K[subseqLen].subseqPtr = candidate->subseqPtr; 2492 if (candidateIdx >= 0) { 2493 K[subseqLen].index1 = K[candidateIdx].index1; 2494 K[subseqLen].index2 = K[candidateIdx].index2; 2495 K[subseqLen].next = K[candidateIdx].next; 2496 } else { 2497 K[subseqLen].index1 = newCandidate.index1; 2498 K[subseqLen].index2 = newCandidate.index2; 2499 K[subseqLen].next = newCandidate.next; 2500 } 2494 2501 } 2495 2502 newCandidate.index1 = i; 2496 2503 newCandidate.index2 = j; 2497 newCandidate. subseqPtr = &K[sLen];2498 candidate = &newCandidate;2504 newCandidate.next = sLen; 2505 candidateIdx = -1; /* use newCandidate info */ 2499 2506 subseqLen = sLen + 1; 2500 2507 … … 2512 2519 K = newK; 2513 2520 } 2514 K[Klen].index1 2515 K[Klen].index2 2516 K[Klen]. subseqPtr = K[Klen-1].subseqPtr;2521 K[Klen].index1 = K[Klen-1].index1; 2522 K[Klen].index2 = K[Klen-1].index2; 2523 K[Klen].next = K[Klen-1].next; 2517 2524 Klen++; 2518 2525 … … 2523 2530 2524 2531 /* put the last candidate into the array */ 2525 K[subseqLen].index1 = candidate->index1; 2526 K[subseqLen].index2 = candidate->index2; 2527 K[subseqLen].subseqPtr = candidate->subseqPtr; 2532 if (candidateIdx >= 0) { 2533 K[subseqLen].index1 = K[candidateIdx].index1; 2534 K[subseqLen].index2 = K[candidateIdx].index2; 2535 K[subseqLen].next = K[candidateIdx].next; 2536 } else { 2537 K[subseqLen].index1 = newCandidate.index1; 2538 K[subseqLen].index2 = newCandidate.index2; 2539 K[subseqLen].next = newCandidate.next; 2540 } 2528 2541 } 2529 2542 } … … 2538 2551 len = longestMatch; 2539 2552 2540 candidate = &K[longestMatch]; 2541 while (candidate->index1 >= 0) { 2542 longestMatch--; 2543 lcsIndex1[longestMatch] = candidate->index1; 2544 lcsIndex2[longestMatch] = candidate->index2; 2545 candidate = candidate->subseqPtr; 2553 candidateIdx = longestMatch; 2554 while (K[candidateIdx].index1 >= 0) { 2555 if (longestMatch-- < 0) { 2556 Tcl_Panic("internal mismatch in diff algorithm"); 2557 } 2558 lcsIndex1[longestMatch] = K[candidateIdx].index1; 2559 lcsIndex2[longestMatch] = K[candidateIdx].index2; 2560 candidateIdx = K[candidateIdx].next; 2546 2561 } 2547 2562
Note: See TracChangeset
for help on using the changeset viewer.