• StringDiff: whitespace matches

    By Andre Guirard 1 decade ago

    This was my very crude fix for the "too much whitespace in diff node"-problem:



    aaa bbb ccc

    aaa ddd ccc

    -> aaa- bbb -+ ddd +ccc ' wrong

    -> aaa -bbb-+ddd+ ccc ' right





    Sub Process(Byval bWords As Boolean)

        On Error Goto errorHandle<br/>
        Dim lBegin1 As Long, lBegin2 As Long, lLen As Long<br/>
    


        If Len(val1) = 0 Then Exit Sub<br/>
        If Len(val2) = 0 Then Exit Sub<br/>
        Call lcs(val1, val2, lBegin1, lBegin2, llen, bWords)<br/>
        If llen Then<br/>
    




                                        ' FIX: there is a space too many around each difference, so cut it here<br/>
            If lBegin1 &gt; 1 And lBegin2 &gt;1 Then<br/>
                If  (Mid$(val1, lBegin1 - 1, 1) Like WORDBREAKMATCH) Then<br/>
                    If  (Mid$(val2, lBegin2 - 1, 1) Like WORDBREAKMATCH) Then<br/>
                ' we know that there are WS in front of them, so get them!<br/>
                        lBegin1 = lBegin1 -1<br/>
                        lBegin2 = lBegin2 -1<br/>
                        llen = llen + 1<br/>
                        'Print &quot;WS before&quot;<br/>
                    End If<br/>
    


                End If<br/>
            End If <br/>
            If  (Mid$(val1, lBegin1 + llen, 1) Like WORDBREAKMATCH) Then<br/>
                If  (Mid$(val2, lBegin2 + llen , 1) Like WORDBREAKMATCH) Then<br/>
                ' we know that there are WS after it, so get them too!<br/>
                    llen = llen + 1<br/>
                    'Print &quot;WS after&quot;<br/>
                End If      <br/>
            End If<br/>
            Call splitnode(lBegin1, lBegin2, llen)<br/>
        End If<br/>
        Exit Sub<br/>
    

    errorHandle:

        Call addToStackTrace()<br/>
    End Sub<br/>
    



    Compared to the current version, it properly only needs a to add a "node." before each valX…