OSDN Git Service

PATCH: [ 849138 ] Fix stringdiffs for diff in first word
authorPerry Rapp <elsapo@users.sourceforge.net>
Tue, 25 Nov 2003 18:23:10 +0000 (18:23 +0000)
committerPerry Rapp <elsapo@users.sourceforge.net>
Tue, 25 Nov 2003 18:23:10 +0000 (18:23 +0000)
  (Code was trying to access word#-1 when diff hit in first word)

Src/readme.txt
Src/stringdiffs.cpp
Src/stringdiffsi.h

index 8247b6b..5b88834 100644 (file)
@@ -1,3 +1,8 @@
+2003-11-25 Perry
+ PATCH: [ 849138 ] Fix stringdiffs for diff in first word
+  (Code was trying to access word#-1 when diff hit in first word)
+  WinMerge: stringdiffs.cpp stringdiffs.h
+
 2003-11-25 Kimmo
  Missed one diff in PATCH: [ 847697 ] Move desc texts into doc classes
  WinMerge: MergeDoc.cpp
index 405f1f1..48fe84d 100644 (file)
@@ -135,9 +135,9 @@ startdiff:
 
                // Add a diff from start to before sync
                int s1 = m_words1[bw1].start;
-               int e1 = m_words1[w1-1].end;
+               int e1 = w1 ? m_words1[w1-1].end : 0;
                int s2 = m_words2[bw2].start;
-               int e2 = m_words2[w2-1].end;
+               int e2 = w2 ? m_words2[w2-1].end : 0;
                if (m_whitespace == 0)
                {
                        // Compare all whitespace
@@ -283,8 +283,8 @@ inword:
                if (begin<i)
                {
                        // just finished a word
-                       // e is last nonspace character
-                       int e = (i<str.GetLength() ? i-1 : i);
+                       // e is first non-word character (space or at end)
+                       int e = i-1;
                        word wd(begin, e, hash(str, begin, e));
                        words->Add(wd);
                }
index fd27f7d..2eb791e 100644 (file)
@@ -26,8 +26,8 @@ public:
 // Implementation types
 private:
        struct word {
-               int start;
-               int end;
+               int start; // index of first character of word in original string
+               int end;   // index of last character of word in original string
                int hash;
                word(int s=0, int e=0, int h=0) : start(s), end(e), hash(h) { }
                int length() const { return end+1-start; }