Skip to content

Commit

Permalink
Merge tag 'v1.20'
Browse files Browse the repository at this point in the history
  • Loading branch information
GerHobbelt committed Sep 9, 2022
2 parents 5f0f6bc + cd45dd4 commit 62689d5
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 11 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ jobs:
run: |
sudo apt-get install -y scons
sudo apt-get install -y cmake scons
wget https://github.com/google/googletest/archive/release-1.8.0.zip
unzip -q release-1.8.0.zip
cd googletest-release-1.8.0
wget https://github.com/google/googletest/archive/release-1.11.0.zip
unzip -q release-1.11.0.zip
cd googletest-release-1.11.0
cmake .
make
sudo make install
Expand Down
6 changes: 6 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
2022-04-11 Tatsuhiko Kubo <cubicdaiya@gmail.com>

* bugfix: fixed invalid offset in unified format difference when difference is too large.

* 1.20 released

2015-05-03 Tatsuhiko Kubo <cubicdaiya@gmail.com>

* added some minor changes.
Expand Down
19 changes: 12 additions & 7 deletions dtl/Diff.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ namespace dtl {
bool editDistanceOnly;
uniHunkVec uniHunks;
comparator cmp;
long long ox;
long long oy;
public :
Diff () {}

Expand Down Expand Up @@ -260,7 +262,8 @@ namespace dtl {
if (isHuge()) {
pathCordinates.reserve(MAX_CORDINATES_SIZE);
}

ox = 0;
oy = 0;
long long p = -1;
fp = new long long[M + N + 3];
fill(&fp[0], &fp[M + N + 3], -1);
Expand Down Expand Up @@ -595,29 +598,29 @@ namespace dtl {
while(px_idx < v[i].x || py_idx < v[i].y) {
if (v[i].y - v[i].x > py_idx - px_idx) {
if (!wasSwapped()) {
ses.addSequence(*y, 0, y_idx, SES_ADD);
ses.addSequence(*y, 0, y_idx + oy, SES_ADD);
} else {
ses.addSequence(*y, y_idx, 0, SES_DELETE);
ses.addSequence(*y, y_idx + oy, 0, SES_DELETE);
}
++y;
++y_idx;
++py_idx;
} else if (v[i].y - v[i].x < py_idx - px_idx) {
if (!wasSwapped()) {
ses.addSequence(*x, x_idx, 0, SES_DELETE);
ses.addSequence(*x, x_idx + ox, 0, SES_DELETE);
} else {
ses.addSequence(*x, 0, x_idx, SES_ADD);
ses.addSequence(*x, 0, x_idx + ox, SES_ADD);
}
++x;
++x_idx;
++px_idx;
} else {
if (!wasSwapped()) {
lcs.addSequence(*x);
ses.addSequence(*x, x_idx, y_idx, SES_COMMON);
ses.addSequence(*x, x_idx + ox, y_idx + oy, SES_COMMON);
} else {
lcs.addSequence(*y);
ses.addSequence(*y, y_idx, x_idx, SES_COMMON);
ses.addSequence(*y, y_idx + oy, x_idx + ox, SES_COMMON);
}
++x;
++y;
Expand Down Expand Up @@ -658,6 +661,8 @@ namespace dtl {
fp = new long long[M + N + 3];
fill(&fp[0], &fp[M + N + 3], -1);
fill(path.begin(), path.end(), -1);
ox = x_idx - 1;
oy = y_idx - 1;
return false;
}
return true;
Expand Down
2 changes: 1 addition & 1 deletion dtl/variables.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ namespace dtl {
/**
* version string
*/
const string version = "1.19";
const string version = "1.20";

/**
* type of edit for SES
Expand Down
6 changes: 6 additions & 0 deletions test/Patchtest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ protected :
cases.push_back(createCase("abcdefq3wefarhgorequgho4euhfteowauhfwehogfewrquhoi23hroewhoahfotrhguoiewahrgqqabcdef",
"3abcdef4976fd86ouofita67t85r876e5e746578tgliuhopoqqabcdef")); // 8
cases.push_back(createCase("abcqqqeqqqccc", "abdqqqeqqqddd")); // 9
cases.push_back(createCase("aaaaaaaaaaaaa>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>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&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&saaabcaaaaaaccc")); // 10
}

void TearDown () {}
Expand Down Expand Up @@ -96,3 +97,8 @@ TEST_F (Patchtest, patch_test9) {
ASSERT_EQ(cases[9].B, cases[9].diff.patch(cases[9].A));
ASSERT_EQ(cases[9].B, cases[9].diff.uniPatch(cases[9].A));
}

TEST_F (Patchtest, patch_test10) {
ASSERT_EQ(cases[10].B, cases[10].diff.patch(cases[10].A));
ASSERT_EQ(cases[10].B, cases[10].diff.uniPatch(cases[10].A));
}
1 change: 1 addition & 0 deletions test/SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def path_chomp(path):
env = Environment(
CPPFLAGS=['-Wall', '-O2'],
CPPPATH=['..'],
CXXFLAGS="-std=c++11",
)

conf = Configure(env);
Expand Down

0 comments on commit 62689d5

Please sign in to comment.