8 Commits

9 changed files with 33 additions and 16 deletions

View File

@ -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

1
.gitignore vendored
View File

@ -9,6 +9,7 @@ examples/intdiff3
examples/patch
examples/fpatch
examples/st2ses
examples/strdiff_storage
test/strdiff3_test
test/*/*/*_
*.o

View File

@ -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.

View File

@ -1,7 +1,5 @@
# dtl
[![Build Status](https://travis-ci.org/cubicdaiya/dtl.png?branch=master)](https://travis-ci.org/cubicdaiya/dtl)
`dtl` is the diff template library written in C++. The name of template is derived C++'s Template.
# Table of contents
@ -253,7 +251,7 @@ dtl::Diff<elem, sequence> d(A, B);
d.compose();
d.composeUnifiedHunks()
string s1(A);
string s2 = d.UniPatch(s1);
string s2 = d.uniPatch(s1);
```
When the above code is run, s2 becomes "abd".

View File

@ -67,6 +67,8 @@ namespace dtl {
bool editDistanceOnly;
uniHunkVec uniHunks;
comparator cmp;
long long ox;
long long oy;
public :
Diff () {}
@ -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);
@ -595,18 +598,18 @@ 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;
@ -614,10 +617,10 @@ namespace dtl {
} 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;
@ -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;

View File

@ -63,7 +63,7 @@ namespace dtl {
/**
* version string
*/
const string version = "1.19";
const string version = "1.20";
/**
* type of edit for SES

View File

@ -15,13 +15,13 @@ if os.sys.platform != "win32":
conf = Configure(env);
if not conf.CheckCXX():
print "The C++ compiler is not installed!"
print("The C++ compiler is not installed!")
Exit(1)
libs = ['stdc++']
for lib in libs:
if not conf.CheckLib(lib):
print "library " + lib + " not installed!"
print("library " + lib + " not installed!")
Exit(1)
conf.Finish()

View File

@ -35,6 +35,7 @@ protected :
cases.push_back(createCase("abcdefq3wefarhgorequgho4euhfteowauhfwehogfewrquhoi23hroewhoahfotrhguoiewahrgqqabcdef",
"3abcdef4976fd86ouofita67t85r876e5e746578tgliuhopoqqabcdef")); // 8
cases.push_back(createCase("abcqqqeqqqccc", "abdqqqeqqqddd")); // 9
cases.push_back(createCase("aaaaaaaa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&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&saaabcaaaaaaccc")); // 10
}
void TearDown () {}
@ -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));
}

View File

@ -11,6 +11,7 @@ def path_chomp(path):
env = Environment(
CPPFLAGS=['-Wall', '-O2'],
CPPPATH=['..'],
CXXFLAGS="-std=c++11",
)
conf = Configure(env);