move to cmake
This commit is contained in:
parent
d1c056e734
commit
087f132a32
11
.cspell/words.txt
Normal file
11
.cspell/words.txt
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
bdiff
|
||||||
|
cmake_current_source_dir
|
||||||
|
fpatch
|
||||||
|
intdiff
|
||||||
|
intdifftest
|
||||||
|
kubo
|
||||||
|
st2ses
|
||||||
|
strdiff
|
||||||
|
tatsuhiko
|
||||||
|
unidiff
|
||||||
|
unistrdiff
|
47
.gitignore
vendored
47
.gitignore
vendored
@ -1,32 +1,35 @@
|
|||||||
examples/unidiff
|
|
||||||
examples/unistrdiff
|
|
||||||
examples/strdiff
|
|
||||||
examples/strdiff_cp
|
|
||||||
examples/strdiff3
|
|
||||||
examples/intdiff
|
|
||||||
examples/bdiff
|
|
||||||
examples/intdiff3
|
|
||||||
examples/patch
|
|
||||||
examples/fpatch
|
|
||||||
examples/st2ses
|
|
||||||
examples/strdiff_storage
|
|
||||||
test/strdiff3_test
|
|
||||||
test/*/*/*_
|
|
||||||
*.o
|
*.o
|
||||||
*.orig
|
*.orig
|
||||||
*~
|
|
||||||
.semantic.cache
|
|
||||||
.DS_Store
|
|
||||||
*.swp
|
*.swp
|
||||||
|
*~
|
||||||
|
.DS_Store
|
||||||
|
.cache/
|
||||||
|
.sconf_temp
|
||||||
|
.sconsign.dblite
|
||||||
|
.semantic.cache
|
||||||
GPATH
|
GPATH
|
||||||
GRTAGS
|
GRTAGS
|
||||||
GSYMS
|
GSYMS
|
||||||
GTAGS
|
GTAGS
|
||||||
TAGS
|
TAGS
|
||||||
dtl_test
|
|
||||||
.sconsign.dblite
|
|
||||||
.sconf_temp
|
|
||||||
config.log
|
|
||||||
^\#
|
|
||||||
\#$
|
\#$
|
||||||
\.\#
|
\.\#
|
||||||
|
^\#
|
||||||
|
build/
|
||||||
|
config.log
|
||||||
|
cspell.json
|
||||||
|
dtl_test
|
||||||
|
examples/bdiff
|
||||||
|
examples/fpatch
|
||||||
|
examples/intdiff
|
||||||
|
examples/intdiff3
|
||||||
|
examples/patch
|
||||||
|
examples/st2ses
|
||||||
|
examples/strdiff
|
||||||
|
examples/strdiff3
|
||||||
|
examples/strdiff_cp
|
||||||
|
examples/strdiff_storage
|
||||||
|
examples/unidiff
|
||||||
|
examples/unistrdiff
|
||||||
|
test/*/*/*_
|
||||||
|
test/strdiff3_test
|
||||||
|
24
CMakeLists.txt
Normal file
24
CMakeLists.txt
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.20)
|
||||||
|
cmake_policy(SET CMP0048 NEW)
|
||||||
|
|
||||||
|
project(
|
||||||
|
dtl
|
||||||
|
VERSION 1.21
|
||||||
|
)
|
||||||
|
|
||||||
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
|
|
||||||
|
include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||||
|
|
||||||
|
option(DTL_ENABLE_TESTING "Enable DTL unit tests" OFF)
|
||||||
|
if(DTL_ENABLE_TESTING)
|
||||||
|
include(test/CMakeLists.txt)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
option(DTL_ENABLE_EXAMPLES "Enable DTL examples" OFF)
|
||||||
|
if(DTL_ENABLE_EXAMPLES)
|
||||||
|
include(examples/CMakeLists.txt)
|
||||||
|
endif()
|
@ -1,10 +1,12 @@
|
|||||||
2024-06-03 Scott E. Graves
|
2024-06-03 Scott E. Graves <scott.e.graves@protonmail.com>
|
||||||
|
|
||||||
* bugfix pr's: fixed compilation issues with GCC 14
|
* pr: fixed compilation issues
|
||||||
* https://github.com/cubicdaiya/dtl/pull/22
|
* https://github.com/cubicdaiya/dtl/pull/22
|
||||||
* https://github.com/cubicdaiya/dtl/pull/18
|
* https://github.com/cubicdaiya/dtl/pull/18
|
||||||
* pr: initialize variables to prevent warnings
|
* pr: initialize variables
|
||||||
* https://github.com/cubicdaiya/dtl/pull/16
|
* https://github.com/cubicdaiya/dtl/pull/16
|
||||||
|
* move to CMake build system
|
||||||
|
* added clang-format and clang-tidy
|
||||||
|
|
||||||
* 1.21 released
|
* 1.21 released
|
||||||
|
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
import os
|
|
||||||
|
|
||||||
# install script
|
|
||||||
|
|
||||||
prefix = ARGUMENTS.get('prefix', '/usr/local')
|
|
||||||
headers = Glob('dtl/*.hpp')
|
|
||||||
Alias('install', Install(os.path.join(prefix, 'dtl', 'include'), headers))
|
|
188
compile_commands.json
Normal file
188
compile_commands.json
Normal file
@ -0,0 +1,188 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"directory": "C:/src/dtl/build",
|
||||||
|
"command": "C:/Users/sgra3018/scoop/apps/msys2/2024-05-07/mingw64/bin/c++.exe -DGTEST_LINKED_AS_SHARED_LIBRARY=1 @CMakeFiles/dtl_test.dir/includes_CXX.rsp -std=gnu++14 -o CMakeFiles/dtl_test.dir/test/Intdifftest.cpp.obj -c C:/src/dtl/test/Intdifftest.cpp",
|
||||||
|
"file": "C:/src/dtl/test/Intdifftest.cpp",
|
||||||
|
"output": "CMakeFiles/dtl_test.dir/test/Intdifftest.cpp.obj"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "C:/src/dtl/build",
|
||||||
|
"command": "C:/Users/sgra3018/scoop/apps/msys2/2024-05-07/mingw64/bin/c++.exe -DGTEST_LINKED_AS_SHARED_LIBRARY=1 @CMakeFiles/dtl_test.dir/includes_CXX.rsp -std=gnu++14 -o CMakeFiles/dtl_test.dir/test/Objdifftest.cpp.obj -c C:/src/dtl/test/Objdifftest.cpp",
|
||||||
|
"file": "C:/src/dtl/test/Objdifftest.cpp",
|
||||||
|
"output": "CMakeFiles/dtl_test.dir/test/Objdifftest.cpp.obj"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "C:/src/dtl/build",
|
||||||
|
"command": "C:/Users/sgra3018/scoop/apps/msys2/2024-05-07/mingw64/bin/c++.exe -DGTEST_LINKED_AS_SHARED_LIBRARY=1 @CMakeFiles/dtl_test.dir/includes_CXX.rsp -std=gnu++14 -o CMakeFiles/dtl_test.dir/test/Patchtest.cpp.obj -c C:/src/dtl/test/Patchtest.cpp",
|
||||||
|
"file": "C:/src/dtl/test/Patchtest.cpp",
|
||||||
|
"output": "CMakeFiles/dtl_test.dir/test/Patchtest.cpp.obj"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "C:/src/dtl/build",
|
||||||
|
"command": "C:/Users/sgra3018/scoop/apps/msys2/2024-05-07/mingw64/bin/c++.exe -DGTEST_LINKED_AS_SHARED_LIBRARY=1 @CMakeFiles/dtl_test.dir/includes_CXX.rsp -std=gnu++14 -o CMakeFiles/dtl_test.dir/test/Strdiff3test.cpp.obj -c C:/src/dtl/test/Strdiff3test.cpp",
|
||||||
|
"file": "C:/src/dtl/test/Strdiff3test.cpp",
|
||||||
|
"output": "CMakeFiles/dtl_test.dir/test/Strdiff3test.cpp.obj"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "C:/src/dtl/build",
|
||||||
|
"command": "C:/Users/sgra3018/scoop/apps/msys2/2024-05-07/mingw64/bin/c++.exe -DGTEST_LINKED_AS_SHARED_LIBRARY=1 @CMakeFiles/dtl_test.dir/includes_CXX.rsp -std=gnu++14 -o CMakeFiles/dtl_test.dir/test/Strdifftest.cpp.obj -c C:/src/dtl/test/Strdifftest.cpp",
|
||||||
|
"file": "C:/src/dtl/test/Strdifftest.cpp",
|
||||||
|
"output": "CMakeFiles/dtl_test.dir/test/Strdifftest.cpp.obj"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "C:/src/dtl/build",
|
||||||
|
"command": "C:/Users/sgra3018/scoop/apps/msys2/2024-05-07/mingw64/bin/c++.exe -DGTEST_LINKED_AS_SHARED_LIBRARY=1 @CMakeFiles/dtl_test.dir/includes_CXX.rsp -std=gnu++14 -o CMakeFiles/dtl_test.dir/test/dtl_test.cpp.obj -c C:/src/dtl/test/dtl_test.cpp",
|
||||||
|
"file": "C:/src/dtl/test/dtl_test.cpp",
|
||||||
|
"output": "CMakeFiles/dtl_test.dir/test/dtl_test.cpp.obj"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "C:/src/dtl/build",
|
||||||
|
"command": "C:/Users/sgra3018/scoop/apps/msys2/2024-05-07/mingw64/bin/c++.exe -DGTEST_LINKED_AS_SHARED_LIBRARY=1 @CMakeFiles/dtl_test.dir/includes_CXX.rsp -std=gnu++14 -o CMakeFiles/dtl_test.dir/test/dtl_test_common.cpp.obj -c C:/src/dtl/test/dtl_test_common.cpp",
|
||||||
|
"file": "C:/src/dtl/test/dtl_test_common.cpp",
|
||||||
|
"output": "CMakeFiles/dtl_test.dir/test/dtl_test_common.cpp.obj"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "C:/src/dtl/build",
|
||||||
|
"command": "C:/Users/sgra3018/scoop/apps/msys2/2024-05-07/mingw64/bin/c++.exe @CMakeFiles/bdiff.dir/includes_CXX.rsp -std=gnu++11 -o CMakeFiles/bdiff.dir/examples/bdiff.cpp.obj -c C:/src/dtl/examples/bdiff.cpp",
|
||||||
|
"file": "C:/src/dtl/examples/bdiff.cpp",
|
||||||
|
"output": "CMakeFiles/bdiff.dir/examples/bdiff.cpp.obj"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "C:/src/dtl/build",
|
||||||
|
"command": "C:/Users/sgra3018/scoop/apps/msys2/2024-05-07/mingw64/bin/c++.exe @CMakeFiles/bdiff.dir/includes_CXX.rsp -std=gnu++11 -o CMakeFiles/bdiff.dir/examples/common.cpp.obj -c C:/src/dtl/examples/common.cpp",
|
||||||
|
"file": "C:/src/dtl/examples/common.cpp",
|
||||||
|
"output": "CMakeFiles/bdiff.dir/examples/common.cpp.obj"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "C:/src/dtl/build",
|
||||||
|
"command": "C:/Users/sgra3018/scoop/apps/msys2/2024-05-07/mingw64/bin/c++.exe @CMakeFiles/fpatch.dir/includes_CXX.rsp -std=gnu++11 -o CMakeFiles/fpatch.dir/examples/fpatch.cpp.obj -c C:/src/dtl/examples/fpatch.cpp",
|
||||||
|
"file": "C:/src/dtl/examples/fpatch.cpp",
|
||||||
|
"output": "CMakeFiles/fpatch.dir/examples/fpatch.cpp.obj"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "C:/src/dtl/build",
|
||||||
|
"command": "C:/Users/sgra3018/scoop/apps/msys2/2024-05-07/mingw64/bin/c++.exe @CMakeFiles/fpatch.dir/includes_CXX.rsp -std=gnu++11 -o CMakeFiles/fpatch.dir/examples/common.cpp.obj -c C:/src/dtl/examples/common.cpp",
|
||||||
|
"file": "C:/src/dtl/examples/common.cpp",
|
||||||
|
"output": "CMakeFiles/fpatch.dir/examples/common.cpp.obj"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "C:/src/dtl/build",
|
||||||
|
"command": "C:/Users/sgra3018/scoop/apps/msys2/2024-05-07/mingw64/bin/c++.exe @CMakeFiles/intdiff.dir/includes_CXX.rsp -std=gnu++11 -o CMakeFiles/intdiff.dir/examples/intdiff.cpp.obj -c C:/src/dtl/examples/intdiff.cpp",
|
||||||
|
"file": "C:/src/dtl/examples/intdiff.cpp",
|
||||||
|
"output": "CMakeFiles/intdiff.dir/examples/intdiff.cpp.obj"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "C:/src/dtl/build",
|
||||||
|
"command": "C:/Users/sgra3018/scoop/apps/msys2/2024-05-07/mingw64/bin/c++.exe @CMakeFiles/intdiff.dir/includes_CXX.rsp -std=gnu++11 -o CMakeFiles/intdiff.dir/examples/common.cpp.obj -c C:/src/dtl/examples/common.cpp",
|
||||||
|
"file": "C:/src/dtl/examples/common.cpp",
|
||||||
|
"output": "CMakeFiles/intdiff.dir/examples/common.cpp.obj"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "C:/src/dtl/build",
|
||||||
|
"command": "C:/Users/sgra3018/scoop/apps/msys2/2024-05-07/mingw64/bin/c++.exe @CMakeFiles/intdiff3.dir/includes_CXX.rsp -std=gnu++11 -o CMakeFiles/intdiff3.dir/examples/intdiff3.cpp.obj -c C:/src/dtl/examples/intdiff3.cpp",
|
||||||
|
"file": "C:/src/dtl/examples/intdiff3.cpp",
|
||||||
|
"output": "CMakeFiles/intdiff3.dir/examples/intdiff3.cpp.obj"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "C:/src/dtl/build",
|
||||||
|
"command": "C:/Users/sgra3018/scoop/apps/msys2/2024-05-07/mingw64/bin/c++.exe @CMakeFiles/intdiff3.dir/includes_CXX.rsp -std=gnu++11 -o CMakeFiles/intdiff3.dir/examples/common.cpp.obj -c C:/src/dtl/examples/common.cpp",
|
||||||
|
"file": "C:/src/dtl/examples/common.cpp",
|
||||||
|
"output": "CMakeFiles/intdiff3.dir/examples/common.cpp.obj"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "C:/src/dtl/build",
|
||||||
|
"command": "C:/Users/sgra3018/scoop/apps/msys2/2024-05-07/mingw64/bin/c++.exe @CMakeFiles/patch.dir/includes_CXX.rsp -std=gnu++11 -o CMakeFiles/patch.dir/examples/patch.cpp.obj -c C:/src/dtl/examples/patch.cpp",
|
||||||
|
"file": "C:/src/dtl/examples/patch.cpp",
|
||||||
|
"output": "CMakeFiles/patch.dir/examples/patch.cpp.obj"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "C:/src/dtl/build",
|
||||||
|
"command": "C:/Users/sgra3018/scoop/apps/msys2/2024-05-07/mingw64/bin/c++.exe @CMakeFiles/patch.dir/includes_CXX.rsp -std=gnu++11 -o CMakeFiles/patch.dir/examples/common.cpp.obj -c C:/src/dtl/examples/common.cpp",
|
||||||
|
"file": "C:/src/dtl/examples/common.cpp",
|
||||||
|
"output": "CMakeFiles/patch.dir/examples/common.cpp.obj"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "C:/src/dtl/build",
|
||||||
|
"command": "C:/Users/sgra3018/scoop/apps/msys2/2024-05-07/mingw64/bin/c++.exe @CMakeFiles/st2ses.dir/includes_CXX.rsp -std=gnu++11 -o CMakeFiles/st2ses.dir/examples/st2ses.cpp.obj -c C:/src/dtl/examples/st2ses.cpp",
|
||||||
|
"file": "C:/src/dtl/examples/st2ses.cpp",
|
||||||
|
"output": "CMakeFiles/st2ses.dir/examples/st2ses.cpp.obj"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "C:/src/dtl/build",
|
||||||
|
"command": "C:/Users/sgra3018/scoop/apps/msys2/2024-05-07/mingw64/bin/c++.exe @CMakeFiles/st2ses.dir/includes_CXX.rsp -std=gnu++11 -o CMakeFiles/st2ses.dir/examples/common.cpp.obj -c C:/src/dtl/examples/common.cpp",
|
||||||
|
"file": "C:/src/dtl/examples/common.cpp",
|
||||||
|
"output": "CMakeFiles/st2ses.dir/examples/common.cpp.obj"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "C:/src/dtl/build",
|
||||||
|
"command": "C:/Users/sgra3018/scoop/apps/msys2/2024-05-07/mingw64/bin/c++.exe @CMakeFiles/strdiff.dir/includes_CXX.rsp -std=gnu++11 -o CMakeFiles/strdiff.dir/examples/strdiff.cpp.obj -c C:/src/dtl/examples/strdiff.cpp",
|
||||||
|
"file": "C:/src/dtl/examples/strdiff.cpp",
|
||||||
|
"output": "CMakeFiles/strdiff.dir/examples/strdiff.cpp.obj"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "C:/src/dtl/build",
|
||||||
|
"command": "C:/Users/sgra3018/scoop/apps/msys2/2024-05-07/mingw64/bin/c++.exe @CMakeFiles/strdiff.dir/includes_CXX.rsp -std=gnu++11 -o CMakeFiles/strdiff.dir/examples/common.cpp.obj -c C:/src/dtl/examples/common.cpp",
|
||||||
|
"file": "C:/src/dtl/examples/common.cpp",
|
||||||
|
"output": "CMakeFiles/strdiff.dir/examples/common.cpp.obj"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "C:/src/dtl/build",
|
||||||
|
"command": "C:/Users/sgra3018/scoop/apps/msys2/2024-05-07/mingw64/bin/c++.exe @CMakeFiles/strdiff3.dir/includes_CXX.rsp -std=gnu++11 -o CMakeFiles/strdiff3.dir/examples/strdiff3.cpp.obj -c C:/src/dtl/examples/strdiff3.cpp",
|
||||||
|
"file": "C:/src/dtl/examples/strdiff3.cpp",
|
||||||
|
"output": "CMakeFiles/strdiff3.dir/examples/strdiff3.cpp.obj"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "C:/src/dtl/build",
|
||||||
|
"command": "C:/Users/sgra3018/scoop/apps/msys2/2024-05-07/mingw64/bin/c++.exe @CMakeFiles/strdiff3.dir/includes_CXX.rsp -std=gnu++11 -o CMakeFiles/strdiff3.dir/examples/common.cpp.obj -c C:/src/dtl/examples/common.cpp",
|
||||||
|
"file": "C:/src/dtl/examples/common.cpp",
|
||||||
|
"output": "CMakeFiles/strdiff3.dir/examples/common.cpp.obj"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "C:/src/dtl/build",
|
||||||
|
"command": "C:/Users/sgra3018/scoop/apps/msys2/2024-05-07/mingw64/bin/c++.exe @CMakeFiles/strdiff_cp.dir/includes_CXX.rsp -std=gnu++11 -o CMakeFiles/strdiff_cp.dir/examples/strdiff_cp.cpp.obj -c C:/src/dtl/examples/strdiff_cp.cpp",
|
||||||
|
"file": "C:/src/dtl/examples/strdiff_cp.cpp",
|
||||||
|
"output": "CMakeFiles/strdiff_cp.dir/examples/strdiff_cp.cpp.obj"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "C:/src/dtl/build",
|
||||||
|
"command": "C:/Users/sgra3018/scoop/apps/msys2/2024-05-07/mingw64/bin/c++.exe @CMakeFiles/strdiff_cp.dir/includes_CXX.rsp -std=gnu++11 -o CMakeFiles/strdiff_cp.dir/examples/common.cpp.obj -c C:/src/dtl/examples/common.cpp",
|
||||||
|
"file": "C:/src/dtl/examples/common.cpp",
|
||||||
|
"output": "CMakeFiles/strdiff_cp.dir/examples/common.cpp.obj"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "C:/src/dtl/build",
|
||||||
|
"command": "C:/Users/sgra3018/scoop/apps/msys2/2024-05-07/mingw64/bin/c++.exe @CMakeFiles/strdiff_storage.dir/includes_CXX.rsp -std=gnu++11 -o CMakeFiles/strdiff_storage.dir/examples/strdiff_storage.cpp.obj -c C:/src/dtl/examples/strdiff_storage.cpp",
|
||||||
|
"file": "C:/src/dtl/examples/strdiff_storage.cpp",
|
||||||
|
"output": "CMakeFiles/strdiff_storage.dir/examples/strdiff_storage.cpp.obj"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "C:/src/dtl/build",
|
||||||
|
"command": "C:/Users/sgra3018/scoop/apps/msys2/2024-05-07/mingw64/bin/c++.exe @CMakeFiles/strdiff_storage.dir/includes_CXX.rsp -std=gnu++11 -o CMakeFiles/strdiff_storage.dir/examples/common.cpp.obj -c C:/src/dtl/examples/common.cpp",
|
||||||
|
"file": "C:/src/dtl/examples/common.cpp",
|
||||||
|
"output": "CMakeFiles/strdiff_storage.dir/examples/common.cpp.obj"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "C:/src/dtl/build",
|
||||||
|
"command": "C:/Users/sgra3018/scoop/apps/msys2/2024-05-07/mingw64/bin/c++.exe @CMakeFiles/unidiff.dir/includes_CXX.rsp -std=gnu++11 -o CMakeFiles/unidiff.dir/examples/unidiff.cpp.obj -c C:/src/dtl/examples/unidiff.cpp",
|
||||||
|
"file": "C:/src/dtl/examples/unidiff.cpp",
|
||||||
|
"output": "CMakeFiles/unidiff.dir/examples/unidiff.cpp.obj"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "C:/src/dtl/build",
|
||||||
|
"command": "C:/Users/sgra3018/scoop/apps/msys2/2024-05-07/mingw64/bin/c++.exe @CMakeFiles/unidiff.dir/includes_CXX.rsp -std=gnu++11 -o CMakeFiles/unidiff.dir/examples/common.cpp.obj -c C:/src/dtl/examples/common.cpp",
|
||||||
|
"file": "C:/src/dtl/examples/common.cpp",
|
||||||
|
"output": "CMakeFiles/unidiff.dir/examples/common.cpp.obj"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "C:/src/dtl/build",
|
||||||
|
"command": "C:/Users/sgra3018/scoop/apps/msys2/2024-05-07/mingw64/bin/c++.exe @CMakeFiles/unistrdiff.dir/includes_CXX.rsp -std=gnu++11 -o CMakeFiles/unistrdiff.dir/examples/unistrdiff.cpp.obj -c C:/src/dtl/examples/unistrdiff.cpp",
|
||||||
|
"file": "C:/src/dtl/examples/unistrdiff.cpp",
|
||||||
|
"output": "CMakeFiles/unistrdiff.dir/examples/unistrdiff.cpp.obj"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "C:/src/dtl/build",
|
||||||
|
"command": "C:/Users/sgra3018/scoop/apps/msys2/2024-05-07/mingw64/bin/c++.exe @CMakeFiles/unistrdiff.dir/includes_CXX.rsp -std=gnu++11 -o CMakeFiles/unistrdiff.dir/examples/common.cpp.obj -c C:/src/dtl/examples/common.cpp",
|
||||||
|
"file": "C:/src/dtl/examples/common.cpp",
|
||||||
|
"output": "CMakeFiles/unistrdiff.dir/examples/common.cpp.obj"
|
||||||
|
}
|
||||||
|
]
|
107
examples/CMakeLists.txt
Normal file
107
examples/CMakeLists.txt
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
add_executable(bdiff
|
||||||
|
examples/bdiff.cpp
|
||||||
|
examples/common.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(bdiff BEFORE PRIVATE
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/examples
|
||||||
|
)
|
||||||
|
|
||||||
|
add_executable(fpatch
|
||||||
|
examples/fpatch.cpp
|
||||||
|
examples/common.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(fpatch BEFORE PRIVATE
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/examples
|
||||||
|
)
|
||||||
|
|
||||||
|
add_executable(intdiff
|
||||||
|
examples/intdiff.cpp
|
||||||
|
examples/common.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(intdiff BEFORE PRIVATE
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/examples
|
||||||
|
)
|
||||||
|
|
||||||
|
add_executable(intdiff3
|
||||||
|
examples/intdiff3.cpp
|
||||||
|
examples/common.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(intdiff3 BEFORE PRIVATE
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/examples
|
||||||
|
)
|
||||||
|
|
||||||
|
add_executable(patch
|
||||||
|
examples/patch.cpp
|
||||||
|
examples/common.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(patch BEFORE PRIVATE
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/examples
|
||||||
|
)
|
||||||
|
|
||||||
|
add_executable(st2ses
|
||||||
|
examples/st2ses.cpp
|
||||||
|
examples/common.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(st2ses BEFORE PRIVATE
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/examples
|
||||||
|
)
|
||||||
|
|
||||||
|
add_executable(strdiff
|
||||||
|
examples/strdiff.cpp
|
||||||
|
examples/common.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(strdiff BEFORE PRIVATE
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/examples
|
||||||
|
)
|
||||||
|
|
||||||
|
add_executable(strdiff3
|
||||||
|
examples/strdiff3.cpp
|
||||||
|
examples/common.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(strdiff3 BEFORE PRIVATE
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/examples
|
||||||
|
)
|
||||||
|
|
||||||
|
add_executable(strdiff_cp
|
||||||
|
examples/strdiff_cp.cpp
|
||||||
|
examples/common.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(strdiff_cp BEFORE PRIVATE
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/examples
|
||||||
|
)
|
||||||
|
|
||||||
|
add_executable(strdiff_storage
|
||||||
|
examples/strdiff_storage.cpp
|
||||||
|
examples/common.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(strdiff_storage BEFORE PRIVATE
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/examples
|
||||||
|
)
|
||||||
|
|
||||||
|
add_executable(unidiff
|
||||||
|
examples/unidiff.cpp
|
||||||
|
examples/common.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(unidiff BEFORE PRIVATE
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/examples
|
||||||
|
)
|
||||||
|
|
||||||
|
add_executable(unistrdiff
|
||||||
|
examples/unistrdiff.cpp
|
||||||
|
examples/common.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(unistrdiff BEFORE PRIVATE
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/examples
|
||||||
|
)
|
@ -1,43 +0,0 @@
|
|||||||
import os
|
|
||||||
|
|
||||||
# SConstruct for dtl examples
|
|
||||||
|
|
||||||
env = Environment(CPPPATH='..')
|
|
||||||
debug = ARGUMENTS.get('debug', 'n')
|
|
||||||
if debug == 'y' or debug == 'yes':
|
|
||||||
env.Append(CPPFLAGS = ['-Wall', '-g'])
|
|
||||||
else:
|
|
||||||
env.Append(CPPFLAGS = ['-Wall', '-O2'])
|
|
||||||
|
|
||||||
if os.sys.platform != "win32":
|
|
||||||
env.Append(CPPDEFINES = ['HAVE_UNISTD_H'])
|
|
||||||
|
|
||||||
conf = Configure(env);
|
|
||||||
|
|
||||||
if not conf.CheckCXX():
|
|
||||||
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!")
|
|
||||||
Exit(1)
|
|
||||||
|
|
||||||
conf.Finish()
|
|
||||||
|
|
||||||
targets = { 'strdiff' : ['strdiff.cpp', 'common.cpp'], # diff between two string sequences
|
|
||||||
'intdiff' : ['intdiff.cpp'], # diff between two integer sequences
|
|
||||||
'unidiff' : ['unidiff.cpp', 'common.cpp'], # unified diff between two files
|
|
||||||
'unistrdiff' : ['unistrdiff.cpp', 'common.cpp'], # unified diff between two strings
|
|
||||||
'bdiff' : ['bdiff.cpp', 'common.cpp'], # diff between two byte sequences
|
|
||||||
'strdiff3' : ['strdiff3.cpp', 'common.cpp'], # three-way string diff program using dtl
|
|
||||||
'intdiff3' : ['intdiff3.cpp'], # three-way integer diff program using dtl
|
|
||||||
'patch' : ['patch.cpp', 'common.cpp'], # string patch program using dtl
|
|
||||||
'fpatch' : ['fpatch.cpp', 'common.cpp'], # file patch program using dtl
|
|
||||||
'st2ses' : ['st2ses.cpp', 'common.cpp'], # convert SES format file to SES instance
|
|
||||||
'strdiff_cp' : ['strdiff_cp.cpp', 'common.cpp'], # diff between two string sequences with custom printer
|
|
||||||
'strdiff_storage' : ['strdiff_storage.cpp', 'common.cpp'], # diff between two string sequences with custom storage
|
|
||||||
}
|
|
||||||
|
|
||||||
[ env.Program(target, targets[target]) for target in targets ]
|
|
@ -1,24 +1,9 @@
|
|||||||
|
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
#include <dtl/dtl.hpp>
|
|
||||||
|
|
||||||
#include <cstdio>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <iostream>
|
|
||||||
#include <string>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <vector>
|
|
||||||
#ifdef HAVE_UNISTD_H
|
|
||||||
#include <unistd.h>
|
|
||||||
#endif // HAVE_UNISTD_H
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
using dtl::Diff;
|
using dtl::Diff;
|
||||||
|
|
||||||
typedef unsigned char elem;
|
typedef unsigned char elem;
|
||||||
typedef vector<elem> sequence;
|
typedef std::vector<elem> sequence;
|
||||||
|
|
||||||
static int create_byte_seq(const char *fs, sequence &seq);
|
static int create_byte_seq(const char *fs, sequence &seq);
|
||||||
static int create_byte_seq(const char *fs, sequence &seq) {
|
static int create_byte_seq(const char *fs, sequence &seq) {
|
||||||
@ -26,7 +11,7 @@ static int create_byte_seq(const char *fs, sequence &seq) {
|
|||||||
int siz;
|
int siz;
|
||||||
elem buf[BUFSIZ];
|
elem buf[BUFSIZ];
|
||||||
if ((fd = open(fs, O_RDONLY)) == -1) {
|
if ((fd = open(fs, O_RDONLY)) == -1) {
|
||||||
cout << "Opening failed." << endl;
|
std::cout << "Opening failed." << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
while ((siz = read(fd, buf, sizeof(buf))) > 0) {
|
while ((siz = read(fd, buf, sizeof(buf))) > 0) {
|
||||||
@ -36,7 +21,7 @@ static int create_byte_seq(const char *fs, sequence &seq) {
|
|||||||
}
|
}
|
||||||
if (siz < 0) {
|
if (siz < 0) {
|
||||||
close(fd);
|
close(fd);
|
||||||
cout << "Read error." << endl;
|
std::cout << "Read error." << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
close(fd);
|
close(fd);
|
||||||
@ -46,12 +31,12 @@ static int create_byte_seq(const char *fs, sequence &seq) {
|
|||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
if (isFewArgs(argc)) {
|
if (isFewArgs(argc)) {
|
||||||
cerr << "Too few arguments." << endl;
|
std::cerr << "Too few arguments." << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
string fs1(argv[1]);
|
std::string fs1(argv[1]);
|
||||||
string fs2(argv[2]);
|
std::string fs2(argv[2]);
|
||||||
sequence seq1;
|
sequence seq1;
|
||||||
sequence seq2;
|
sequence seq2;
|
||||||
|
|
||||||
@ -62,9 +47,9 @@ int main(int argc, char *argv[]) {
|
|||||||
d.compose();
|
d.compose();
|
||||||
|
|
||||||
if (d.getEditDistance() == 0) {
|
if (d.getEditDistance() == 0) {
|
||||||
cout << fs1 << " is the same as " << fs2 << endl;
|
std::cout << fs1 << " is the same as " << fs2 << std::endl;
|
||||||
} else {
|
} else {
|
||||||
cout << fs1 << " is different from " << fs2 << endl;
|
std::cout << fs1 << " is different from " << fs2 << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
|
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
|
|
||||||
bool isFileExist(string &fs) {
|
bool isFileExist(std::string &fs) {
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
if ((fp = fopen(fs.c_str(), "r")) == NULL) {
|
if ((fp = fopen(fs.c_str(), "r")) == NULL) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -1,13 +1,9 @@
|
|||||||
|
|
||||||
#ifndef DTL_EXAMPLE_COMMON_H
|
#ifndef DTL_EXAMPLE_COMMON_H
|
||||||
#define DTL_EXAMPLE_COMMON_H
|
#define DTL_EXAMPLE_COMMON_H
|
||||||
|
|
||||||
#include <cstdio>
|
#include "dtl.hpp"
|
||||||
#include <string>
|
|
||||||
|
|
||||||
using namespace std;
|
bool isFileExist(std::string &fs);
|
||||||
|
|
||||||
bool isFileExist(string &fs);
|
|
||||||
bool isFewArgs(int argc, int limit = 3);
|
bool isFewArgs(int argc, int limit = 3);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,34 +1,25 @@
|
|||||||
|
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
#include <cassert>
|
|
||||||
#include <dtl/dtl.hpp>
|
|
||||||
#include <fstream>
|
|
||||||
#include <iostream>
|
|
||||||
#include <sstream>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
using dtl::Diff;
|
using dtl::Diff;
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
if (isFewArgs(argc)) {
|
if (isFewArgs(argc)) {
|
||||||
cerr << "Too few arguments." << endl;
|
std::cerr << "Too few arguments." << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
string A(argv[1]);
|
std::string A(argv[1]);
|
||||||
string B(argv[2]);
|
std::string B(argv[2]);
|
||||||
bool fileExist = true;
|
bool fileExist = true;
|
||||||
|
|
||||||
if (!isFileExist(A)) {
|
if (!isFileExist(A)) {
|
||||||
cerr << "file A does not exist" << endl;
|
std::cerr << "file A does not exist" << std::endl;
|
||||||
fileExist = false;
|
fileExist = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isFileExist(B)) {
|
if (!isFileExist(B)) {
|
||||||
cerr << "file B does not exist" << endl;
|
std::cerr << "file B does not exist" << std::endl;
|
||||||
fileExist = false;
|
fileExist = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,14 +27,14 @@ int main(int argc, char *argv[]) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef string elem;
|
typedef std::string elem;
|
||||||
typedef vector<elem> sequence;
|
typedef std::vector<elem> sequence;
|
||||||
|
|
||||||
ifstream Aifs(A.c_str());
|
std::ifstream Aifs(A.c_str());
|
||||||
ifstream Bifs(B.c_str());
|
std::ifstream Bifs(B.c_str());
|
||||||
elem buf;
|
elem buf;
|
||||||
sequence ALines, BLines;
|
sequence ALines, BLines;
|
||||||
ostringstream ossLine, ossInfo;
|
std::ostringstream ossLine, ossInfo;
|
||||||
|
|
||||||
while (getline(Aifs, buf)) {
|
while (getline(Aifs, buf)) {
|
||||||
ALines.push_back(buf);
|
ALines.push_back(buf);
|
||||||
@ -60,14 +51,14 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
// fpatch
|
// fpatch
|
||||||
assert(BLines == s2);
|
assert(BLines == s2);
|
||||||
cout << "fpatch succeeded" << endl;
|
std::cout << "fpatch succeeded" << std::endl;
|
||||||
|
|
||||||
d.composeUnifiedHunks();
|
d.composeUnifiedHunks();
|
||||||
sequence s3 = d.uniPatch(s1);
|
sequence s3 = d.uniPatch(s1);
|
||||||
|
|
||||||
// unipatch
|
// unipatch
|
||||||
assert(BLines == s3);
|
assert(BLines == s3);
|
||||||
cout << "unipatch succeeded" << endl;
|
std::cout << "unipatch succeeded" << std::endl;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,4 @@
|
|||||||
|
#include "common.hpp"
|
||||||
#include <dtl/dtl.hpp>
|
|
||||||
#include <iostream>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
using dtl::Diff;
|
using dtl::Diff;
|
||||||
|
|
||||||
@ -14,16 +9,16 @@ int main(int, char **) {
|
|||||||
int asiz = sizeof(a) / sizeof(int);
|
int asiz = sizeof(a) / sizeof(int);
|
||||||
int bsiz = sizeof(b) / sizeof(int);
|
int bsiz = sizeof(b) / sizeof(int);
|
||||||
for (int i = 0; i < asiz; ++i) {
|
for (int i = 0; i < asiz; ++i) {
|
||||||
cout << a[i] << " ";
|
std::cout << a[i] << " ";
|
||||||
}
|
}
|
||||||
cout << endl;
|
std::cout << std::endl;
|
||||||
for (int i = 0; i < bsiz; ++i) {
|
for (int i = 0; i < bsiz; ++i) {
|
||||||
cout << b[i] << " ";
|
std::cout << b[i] << " ";
|
||||||
}
|
}
|
||||||
cout << endl;
|
std::cout << std::endl;
|
||||||
|
|
||||||
typedef int elem;
|
typedef int elem;
|
||||||
typedef vector<int> sequence;
|
typedef std::vector<int> sequence;
|
||||||
|
|
||||||
sequence A(&a[0], &a[asiz]);
|
sequence A(&a[0], &a[asiz]);
|
||||||
sequence B(&b[0], &b[bsiz]);
|
sequence B(&b[0], &b[bsiz]);
|
||||||
@ -31,18 +26,18 @@ int main(int, char **) {
|
|||||||
d.compose();
|
d.compose();
|
||||||
|
|
||||||
// editDistance
|
// editDistance
|
||||||
cout << "editDistance:" << d.getEditDistance() << endl;
|
std::cout << "editDistance:" << d.getEditDistance() << std::endl;
|
||||||
|
|
||||||
// Longest Common Subsequence
|
// Longest Common Subsequence
|
||||||
sequence lcs_v = d.getLcsVec();
|
sequence lcs_v = d.getLcsVec();
|
||||||
cout << "LCS: ";
|
std::cout << "LCS: ";
|
||||||
for (sequence::iterator vit = lcs_v.begin(); vit != lcs_v.end(); ++vit) {
|
for (sequence::iterator vit = lcs_v.begin(); vit != lcs_v.end(); ++vit) {
|
||||||
cout << *vit << " ";
|
std::cout << *vit << " ";
|
||||||
}
|
}
|
||||||
cout << endl;
|
std::cout << std::endl;
|
||||||
|
|
||||||
// Shortest Edit Script
|
// Shortest Edit Script
|
||||||
cout << "SES" << endl;
|
std::cout << "SES" << std::endl;
|
||||||
d.printSES();
|
d.printSES();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1,10 +1,4 @@
|
|||||||
|
#include "common.hpp"
|
||||||
#include <cassert>
|
|
||||||
#include <dtl/dtl.hpp>
|
|
||||||
#include <iostream>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
using dtl::Diff3;
|
using dtl::Diff3;
|
||||||
|
|
||||||
@ -15,24 +9,24 @@ int main(int, char **) {
|
|||||||
int c[10] = {1, 2, 3, 9, 5, 6, 7, 8, 9, 10};
|
int c[10] = {1, 2, 3, 9, 5, 6, 7, 8, 9, 10};
|
||||||
int answer[10] = {1, 2, 3, 9, 5, 6, 7, 3, 9, 10};
|
int answer[10] = {1, 2, 3, 9, 5, 6, 7, 3, 9, 10};
|
||||||
|
|
||||||
cout << "a:";
|
std::cout << "a:";
|
||||||
for (int i = 0; i < 10; ++i) {
|
for (int i = 0; i < 10; ++i) {
|
||||||
cout << a[i] << " ";
|
std::cout << a[i] << " ";
|
||||||
}
|
}
|
||||||
cout << endl;
|
std::cout << std::endl;
|
||||||
cout << "b:";
|
std::cout << "b:";
|
||||||
for (int i = 0; i < 10; ++i) {
|
for (int i = 0; i < 10; ++i) {
|
||||||
cout << b[i] << " ";
|
std::cout << b[i] << " ";
|
||||||
}
|
}
|
||||||
cout << endl;
|
std::cout << std::endl;
|
||||||
cout << "c:";
|
std::cout << "c:";
|
||||||
for (int i = 0; i < 10; ++i) {
|
for (int i = 0; i < 10; ++i) {
|
||||||
cout << c[i] << " ";
|
std::cout << c[i] << " ";
|
||||||
}
|
}
|
||||||
cout << endl;
|
std::cout << std::endl;
|
||||||
|
|
||||||
typedef int elem;
|
typedef int elem;
|
||||||
typedef vector<int> sequence;
|
typedef std::vector<int> sequence;
|
||||||
sequence A(&a[0], &a[10]);
|
sequence A(&a[0], &a[10]);
|
||||||
sequence B(&b[0], &b[10]);
|
sequence B(&b[0], &b[10]);
|
||||||
sequence C(&c[0], &c[10]);
|
sequence C(&c[0], &c[10]);
|
||||||
@ -40,18 +34,18 @@ int main(int, char **) {
|
|||||||
Diff3<elem> diff3(A, B, C);
|
Diff3<elem> diff3(A, B, C);
|
||||||
diff3.compose();
|
diff3.compose();
|
||||||
if (!diff3.merge()) {
|
if (!diff3.merge()) {
|
||||||
cerr << "conflict." << endl;
|
std::cerr << "conflict." << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
sequence s = diff3.getMergedSequence();
|
sequence s = diff3.getMergedSequence();
|
||||||
cout << "s:";
|
std::cout << "s:";
|
||||||
for (sequence::iterator it = s.begin(); it != s.end(); ++it) {
|
for (sequence::iterator it = s.begin(); it != s.end(); ++it) {
|
||||||
cout << *it << " ";
|
std::cout << *it << " ";
|
||||||
}
|
}
|
||||||
cout << endl;
|
std::cout << std::endl;
|
||||||
|
|
||||||
assert(s == Answer);
|
assert(s == Answer);
|
||||||
cout << "intdiff3 OK" << endl;
|
std::cout << "intdiff3 OK" << std::endl;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1,23 +1,16 @@
|
|||||||
|
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
#include <cassert>
|
|
||||||
#include <dtl/dtl.hpp>
|
|
||||||
#include <iostream>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
using dtl::Diff;
|
using dtl::Diff;
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
if (isFewArgs(argc)) {
|
if (isFewArgs(argc)) {
|
||||||
cerr << "Too few arguments." << endl;
|
std::cerr << "Too few arguments." << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef char elem;
|
typedef char elem;
|
||||||
typedef string sequence;
|
typedef std::string sequence;
|
||||||
|
|
||||||
sequence A(argv[1]);
|
sequence A(argv[1]);
|
||||||
sequence B(argv[2]);
|
sequence B(argv[2]);
|
||||||
@ -30,15 +23,15 @@ int main(int argc, char *argv[]) {
|
|||||||
d.composeUnifiedHunks();
|
d.composeUnifiedHunks();
|
||||||
sequence s3 = d.uniPatch(s1);
|
sequence s3 = d.uniPatch(s1);
|
||||||
|
|
||||||
cout << "before:" << s1 << endl;
|
std::cout << "before:" << s1 << std::endl;
|
||||||
cout << "after :" << s2 << endl;
|
std::cout << "after :" << s2 << std::endl;
|
||||||
assert(B == s2);
|
assert(B == s2);
|
||||||
cout << "patch succeeded" << endl;
|
std::cout << "patch succeeded" << std::endl;
|
||||||
|
|
||||||
cout << "before:" << s1 << endl;
|
std::cout << "before:" << s1 << std::endl;
|
||||||
cout << "after :" << s3 << endl;
|
std::cout << "after :" << s3 << std::endl;
|
||||||
assert(B == s3);
|
assert(B == s3);
|
||||||
cout << "unipatch succeeded" << endl;
|
std::cout << "unipatch succeeded" << std::endl;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
#ifndef DTL_PRINTERS
|
#ifndef DTL_PRINTERS
|
||||||
#define DTL_PRINTERS
|
#define DTL_PRINTERS
|
||||||
|
|
||||||
#include <dtl/dtl.hpp>
|
#include "common.hpp"
|
||||||
|
|
||||||
template <typename sesElem, typename stream = ostream>
|
template <typename sesElem, typename stream = std::ostream>
|
||||||
class customChangePrinter : public dtl::Printer<sesElem, stream> {
|
class customChangePrinter : public dtl::Printer<sesElem, stream> {
|
||||||
public:
|
public:
|
||||||
customChangePrinter() : dtl::Printer<sesElem, stream>() {}
|
customChangePrinter() : dtl::Printer<sesElem, stream>() {}
|
||||||
|
@ -1,35 +1,27 @@
|
|||||||
|
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
#include <dtl/dtl.hpp>
|
|
||||||
#include <fstream>
|
|
||||||
#include <iostream>
|
|
||||||
#include <sstream>
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
using namespace dtl;
|
using namespace dtl;
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
if (isFewArgs(argc, 2)) {
|
if (isFewArgs(argc, 2)) {
|
||||||
cerr << "Too few arguments." << endl;
|
std::cerr << "Too few arguments." << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef string elem;
|
typedef std::string elem;
|
||||||
typedef vector<string> sequence;
|
typedef std::vector<string> sequence;
|
||||||
|
|
||||||
string s(argv[1]);
|
std::string s(argv[1]);
|
||||||
|
|
||||||
if (!isFileExist(s)) {
|
if (!isFileExist(s)) {
|
||||||
cerr << s << " is invalid." << endl;
|
std::cerr << s << " is invalid." << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ifstream fs(s.c_str());
|
std::ifstream fs(s.c_str());
|
||||||
const Ses<elem> ses =
|
const Ses<elem> ses =
|
||||||
Diff<elem, sequence>::composeSesFromStream<ifstream>(fs);
|
Diff<elem, sequence>::composeSesFromStream<std::ifstream>(fs);
|
||||||
dtl::Diff<elem, sequence>::printSES(ses);
|
dtl::Diff<elem, sequence>::printSES(ses);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef DTL_STORAGE
|
#ifndef DTL_STORAGE
|
||||||
#define DTL_STORAGE
|
#define DTL_STORAGE
|
||||||
|
|
||||||
#include <dtl/dtl.hpp>
|
#include "common.hpp"
|
||||||
|
|
||||||
template <typename sesElem, typename storedData>
|
template <typename sesElem, typename storedData>
|
||||||
class CustomStorage : public dtl::Storage<sesElem, storedData> {
|
class CustomStorage : public dtl::Storage<sesElem, storedData> {
|
||||||
|
@ -1,23 +1,16 @@
|
|||||||
|
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
#include <dtl/dtl.hpp>
|
|
||||||
#include <iostream>
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
using dtl::Diff;
|
using dtl::Diff;
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
if (isFewArgs(argc)) {
|
if (isFewArgs(argc)) {
|
||||||
cerr << "Too few arguments." << endl;
|
std::cerr << "Too few arguments." << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef char elem;
|
typedef char elem;
|
||||||
typedef string sequence;
|
typedef std::string sequence;
|
||||||
|
|
||||||
sequence A(argv[1]);
|
sequence A(argv[1]);
|
||||||
sequence B(argv[2]);
|
sequence B(argv[2]);
|
||||||
@ -27,15 +20,15 @@ int main(int argc, char *argv[]) {
|
|||||||
d.compose();
|
d.compose();
|
||||||
|
|
||||||
// editDistance
|
// editDistance
|
||||||
cout << "editDistance:" << d.getEditDistance() << endl;
|
std::cout << "editDistance:" << d.getEditDistance() << std::endl;
|
||||||
|
|
||||||
// Longest Common Subsequence
|
// Longest Common Subsequence
|
||||||
vector<elem> lcs_v = d.getLcsVec();
|
std::vector<elem> lcs_v = d.getLcsVec();
|
||||||
sequence lcs_s(lcs_v.begin(), lcs_v.end());
|
sequence lcs_s(lcs_v.begin(), lcs_v.end());
|
||||||
cout << "LCS:" << lcs_s << endl;
|
std::cout << "LCS:" << lcs_s << std::endl;
|
||||||
|
|
||||||
// Shortest Edit Script
|
// Shortest Edit Script
|
||||||
cout << "SES" << endl;
|
std::cout << "SES" << std::endl;
|
||||||
d.printSES();
|
d.printSES();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1,23 +1,16 @@
|
|||||||
|
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
#include <dtl/dtl.hpp>
|
|
||||||
#include <iostream>
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
using dtl::Diff3;
|
using dtl::Diff3;
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
if (isFewArgs(argc, 4)) {
|
if (isFewArgs(argc, 4)) {
|
||||||
cerr << "Too few arguments." << endl;
|
std::cerr << "Too few arguments." << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef char elem;
|
typedef char elem;
|
||||||
typedef string sequence;
|
typedef std::string sequence;
|
||||||
|
|
||||||
sequence A(argv[1]);
|
sequence A(argv[1]);
|
||||||
sequence B(argv[2]);
|
sequence B(argv[2]);
|
||||||
@ -26,10 +19,10 @@ int main(int argc, char *argv[]) {
|
|||||||
Diff3<elem, sequence> diff3(A, B, C);
|
Diff3<elem, sequence> diff3(A, B, C);
|
||||||
diff3.compose();
|
diff3.compose();
|
||||||
if (!diff3.merge()) {
|
if (!diff3.merge()) {
|
||||||
cerr << "conflict." << endl;
|
std::cerr << "conflict." << std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
cout << "result:" << diff3.getMergedSequence() << endl;
|
std::cout << "result:" << diff3.getMergedSequence() << std::endl;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,18 @@
|
|||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
#include <dtl/dtl.hpp>
|
|
||||||
#include <iostream>
|
|
||||||
#include <sstream>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include "printers.hpp"
|
#include "printers.hpp"
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
using dtl::Diff;
|
using dtl::Diff;
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
if (isFewArgs(argc)) {
|
if (isFewArgs(argc)) {
|
||||||
cerr << "Too few arguments." << endl;
|
std::cerr << "Too few arguments." << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef char elem;
|
typedef char elem;
|
||||||
typedef string sequence;
|
typedef std::string sequence;
|
||||||
|
|
||||||
sequence A(argv[1]);
|
sequence A(argv[1]);
|
||||||
sequence B(argv[2]);
|
sequence B(argv[2]);
|
||||||
@ -27,9 +21,9 @@ int main(int argc, char *argv[]) {
|
|||||||
d.compose();
|
d.compose();
|
||||||
|
|
||||||
// Shortest Edit Script
|
// Shortest Edit Script
|
||||||
cout << "SES" << endl;
|
std::cout << "SES" << std::endl;
|
||||||
|
|
||||||
d.printSES<ostream, customChangePrinter>(cout);
|
d.printSES<std::ostream, customChangePrinter>(std::cout);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1,23 +1,18 @@
|
|||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
#include <dtl/dtl.hpp>
|
|
||||||
#include <iostream>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include "storage.hpp"
|
#include "storage.hpp"
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
using dtl::Diff;
|
using dtl::Diff;
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
if (isFewArgs(argc)) {
|
if (isFewArgs(argc)) {
|
||||||
cerr << "Too few arguments." << endl;
|
std::cerr << "Too few arguments." << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef char elem;
|
typedef char elem;
|
||||||
typedef string sequence;
|
typedef std::string sequence;
|
||||||
|
|
||||||
sequence A(argv[1]);
|
sequence A(argv[1]);
|
||||||
sequence B(argv[2]);
|
sequence B(argv[2]);
|
||||||
@ -26,13 +21,13 @@ int main(int argc, char *argv[]) {
|
|||||||
d.compose();
|
d.compose();
|
||||||
|
|
||||||
// Shortest Edit Script
|
// Shortest Edit Script
|
||||||
cout << "SES" << endl;
|
std::cout << "SES" << std::endl;
|
||||||
|
|
||||||
string result;
|
std::string result;
|
||||||
|
|
||||||
d.storeSES<string, CustomStorage>(result);
|
d.storeSES<std::string, CustomStorage>(result);
|
||||||
|
|
||||||
cout << result;
|
std::cout << result;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,13 @@
|
|||||||
|
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
#include <dtl/dtl.hpp>
|
|
||||||
#include <fstream>
|
|
||||||
#include <iostream>
|
|
||||||
#include <sstream>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
using dtl::Diff;
|
using dtl::Diff;
|
||||||
using dtl::elemInfo;
|
using dtl::elemInfo;
|
||||||
using dtl::uniHunk;
|
using dtl::uniHunk;
|
||||||
|
|
||||||
static void showStats(string fp1, string fp2);
|
static void showStats(std::string fp1, std::string fp2);
|
||||||
static void unifiedDiff(string fp1, string fp2);
|
static void unifiedDiff(std::string fp1, std::string fp2);
|
||||||
|
|
||||||
static void showStats(string fp1, string fp2) {
|
static void showStats(std::string fp1, std::string fp2) {
|
||||||
const int MAX_LENGTH = 255;
|
const int MAX_LENGTH = 255;
|
||||||
char time_format[] = "%Y-%m-%d %H:%M:%S %z";
|
char time_format[] = "%Y-%m-%d %H:%M:%S %z";
|
||||||
time_t rawtime[2];
|
time_t rawtime[2];
|
||||||
@ -26,11 +15,11 @@ static void showStats(string fp1, string fp2) {
|
|||||||
struct stat st[2];
|
struct stat st[2];
|
||||||
|
|
||||||
if (stat(fp1.c_str(), &st[0]) == -1) {
|
if (stat(fp1.c_str(), &st[0]) == -1) {
|
||||||
cerr << "argv1 is invalid." << endl;
|
std::cerr << "argv1 is invalid." << std::endl;
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
if (stat(fp2.c_str(), &st[1]) == -1) {
|
if (stat(fp2.c_str(), &st[1]) == -1) {
|
||||||
cerr << "argv2 is invalid" << endl;
|
std::cerr << "argv2 is invalid" << std::endl;
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,20 +27,20 @@ static void showStats(string fp1, string fp2) {
|
|||||||
rawtime[0] = st[0].st_mtime;
|
rawtime[0] = st[0].st_mtime;
|
||||||
timeinfo[0] = localtime(&rawtime[0]);
|
timeinfo[0] = localtime(&rawtime[0]);
|
||||||
strftime(buf[0], MAX_LENGTH, time_format, timeinfo[0]);
|
strftime(buf[0], MAX_LENGTH, time_format, timeinfo[0]);
|
||||||
cout << "--- " << fp1 << '\t' << buf[0] << endl;
|
std::cout << "--- " << fp1 << '\t' << buf[0] << std::endl;
|
||||||
rawtime[1] = st[1].st_mtime;
|
rawtime[1] = st[1].st_mtime;
|
||||||
timeinfo[1] = localtime(&rawtime[1]);
|
timeinfo[1] = localtime(&rawtime[1]);
|
||||||
strftime(buf[1], MAX_LENGTH, time_format, timeinfo[1]);
|
strftime(buf[1], MAX_LENGTH, time_format, timeinfo[1]);
|
||||||
cout << "+++ " << fp2 << '\t' << buf[1] << endl;
|
std::cout << "+++ " << fp2 << '\t' << buf[1] << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void unifiedDiff(string fp1, string fp2) {
|
static void unifiedDiff(std::string fp1, std::string fp2) {
|
||||||
typedef string elem;
|
typedef std::string elem;
|
||||||
typedef vector<elem> sequence;
|
typedef std::vector<elem> sequence;
|
||||||
typedef pair<elem, elemInfo> sesElem;
|
typedef std::pair<elem, elemInfo> sesElem;
|
||||||
|
|
||||||
ifstream Aifs(fp1.c_str());
|
std::ifstream Aifs(fp1.c_str());
|
||||||
ifstream Bifs(fp2.c_str());
|
std::ifstream Bifs(fp2.c_str());
|
||||||
elem buf;
|
elem buf;
|
||||||
sequence ALines, BLines;
|
sequence ALines, BLines;
|
||||||
|
|
||||||
@ -80,21 +69,21 @@ static void unifiedDiff(string fp1, string fp2) {
|
|||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
if (isFewArgs(argc)) {
|
if (isFewArgs(argc)) {
|
||||||
cerr << "Too few arguments." << endl;
|
std::cerr << "Too few arguments." << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
string s1(argv[1]);
|
std::string s1(argv[1]);
|
||||||
string s2(argv[2]);
|
std::string s2(argv[2]);
|
||||||
bool fileExist = true;
|
bool fileExist = true;
|
||||||
|
|
||||||
if (!isFileExist(s1)) {
|
if (!isFileExist(s1)) {
|
||||||
cerr << s1 << " is invalid." << endl;
|
std::cerr << s1 << " is invalid." << std::endl;
|
||||||
fileExist = false;
|
fileExist = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isFileExist(s2)) {
|
if (!isFileExist(s2)) {
|
||||||
cerr << s2 << " is invalid." << endl;
|
std::cerr << s2 << " is invalid." << std::endl;
|
||||||
fileExist = false;
|
fileExist = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,22 +1,16 @@
|
|||||||
|
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
#include <dtl/dtl.hpp>
|
|
||||||
#include <iostream>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
using dtl::Diff;
|
using dtl::Diff;
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
if (isFewArgs(argc)) {
|
if (isFewArgs(argc)) {
|
||||||
cerr << "Too few arguments." << endl;
|
std::cerr << "Too few arguments." << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef char elem;
|
typedef char elem;
|
||||||
typedef string sequence;
|
typedef std::string sequence;
|
||||||
|
|
||||||
sequence A(argv[1]);
|
sequence A(argv[1]);
|
||||||
sequence B(argv[2]);
|
sequence B(argv[2]);
|
||||||
@ -26,12 +20,12 @@ int main(int argc, char *argv[]) {
|
|||||||
d.composeUnifiedHunks();
|
d.composeUnifiedHunks();
|
||||||
|
|
||||||
// editDistance
|
// editDistance
|
||||||
cout << "editDistance:" << d.getEditDistance() << endl;
|
std::cout << "editDistance:" << d.getEditDistance() << std::endl;
|
||||||
|
|
||||||
// Longest Common Subsequence
|
// Longest Common Subsequence
|
||||||
vector<elem> lcs_v = d.getLcsVec();
|
std::vector<elem> lcs_v = d.getLcsVec();
|
||||||
sequence lcs_s(lcs_v.begin(), lcs_v.end());
|
sequence lcs_s(lcs_v.begin(), lcs_v.end());
|
||||||
cout << "LCS:" << lcs_s << endl;
|
std::cout << "LCS:" << lcs_s << std::endl;
|
||||||
|
|
||||||
// print Unified Format
|
// print Unified Format
|
||||||
d.printUnifiedFormat();
|
d.printUnifiedFormat();
|
||||||
|
@ -38,13 +38,19 @@
|
|||||||
#ifndef DTL_DIFF_H
|
#ifndef DTL_DIFF_H
|
||||||
#define DTL_DIFF_H
|
#define DTL_DIFF_H
|
||||||
|
|
||||||
|
#include "variables.hpp"
|
||||||
|
|
||||||
|
#include "Lcs.hpp"
|
||||||
|
#include "Ses.hpp"
|
||||||
|
#include "functors.hpp"
|
||||||
|
|
||||||
namespace dtl {
|
namespace dtl {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* diff class template
|
* diff class template
|
||||||
* sequence must support random_access_iterator.
|
* sequence must support random_access_iterator.
|
||||||
*/
|
*/
|
||||||
template <typename elem, typename sequence = vector<elem>,
|
template <typename elem, typename sequence = std::vector<elem>,
|
||||||
typename comparator = Compare<elem>>
|
typename comparator = Compare<elem>>
|
||||||
class Diff {
|
class Diff {
|
||||||
private:
|
private:
|
||||||
@ -225,7 +231,7 @@ public:
|
|||||||
oy = 0;
|
oy = 0;
|
||||||
long long p = -1;
|
long long p = -1;
|
||||||
fp = new long long[M + N + 3];
|
fp = new long long[M + N + 3];
|
||||||
fill(&fp[0], &fp[M + N + 3], -1);
|
std::fill(&fp[0], &fp[M + N + 3], -1);
|
||||||
path = editPath(M + N + 3);
|
path = editPath(M + N + 3);
|
||||||
fill(path.begin(), path.end(), -1);
|
fill(path.begin(), path.end(), -1);
|
||||||
ONP:
|
ONP:
|
||||||
@ -346,7 +352,7 @@ public:
|
|||||||
sesElemVec change;
|
sesElemVec change;
|
||||||
sesElemVec ses_v = ses.getSequence();
|
sesElemVec ses_v = ses.getSequence();
|
||||||
long long l_cnt = 1;
|
long long l_cnt = 1;
|
||||||
long long length = distance(ses_v.begin(), ses_v.end());
|
long long length = std::distance(ses_v.begin(), ses_v.end());
|
||||||
long long middle = 0;
|
long long middle = 0;
|
||||||
bool isMiddle, isAfter;
|
bool isMiddle, isAfter;
|
||||||
elemInfo einfo;
|
elemInfo einfo;
|
||||||
@ -407,7 +413,8 @@ public:
|
|||||||
}
|
}
|
||||||
common[0].push_back(*it);
|
common[0].push_back(*it);
|
||||||
} else {
|
} else {
|
||||||
rotate(common[0].begin(), common[0].begin() + 1, common[0].end());
|
std::rotate(common[0].begin(), common[0].begin() + 1,
|
||||||
|
common[0].end());
|
||||||
common[0].pop_back();
|
common[0].pop_back();
|
||||||
common[0].push_back(*it);
|
common[0].push_back(*it);
|
||||||
++a;
|
++a;
|
||||||
@ -463,7 +470,7 @@ public:
|
|||||||
if (c == 0)
|
if (c == 0)
|
||||||
++c;
|
++c;
|
||||||
if (wasSwapped())
|
if (wasSwapped())
|
||||||
swap(a, c);
|
std::swap(a, c);
|
||||||
hunk.a = a;
|
hunk.a = a;
|
||||||
hunk.b = b;
|
hunk.b = b;
|
||||||
hunk.c = c;
|
hunk.c = c;
|
||||||
@ -493,7 +500,7 @@ public:
|
|||||||
Ses<elem> ret;
|
Ses<elem> ret;
|
||||||
long long x_idx, y_idx;
|
long long x_idx, y_idx;
|
||||||
x_idx = y_idx = 1;
|
x_idx = y_idx = 1;
|
||||||
while (getline(st, line)) {
|
while (std::getline(st, line)) {
|
||||||
elem mark(line.begin(), line.begin() + 1);
|
elem mark(line.begin(), line.begin() + 1);
|
||||||
elem e(line.begin() + 1, line.end());
|
elem e(line.begin() + 1, line.end());
|
||||||
if (mark == SES_MARK_DELETE) {
|
if (mark == SES_MARK_DELETE) {
|
||||||
@ -517,12 +524,12 @@ private:
|
|||||||
*/
|
*/
|
||||||
void init() {
|
void init() {
|
||||||
M = distance(A.begin(), A.end());
|
M = distance(A.begin(), A.end());
|
||||||
N = distance(B.begin(), B.end());
|
N = std::distance(B.begin(), B.end());
|
||||||
if (M < N) {
|
if (M < N) {
|
||||||
swapped = false;
|
swapped = false;
|
||||||
} else {
|
} else {
|
||||||
swap(A, B);
|
swap(A, B);
|
||||||
swap(M, N);
|
std::swap(M, N);
|
||||||
swapped = true;
|
swapped = true;
|
||||||
}
|
}
|
||||||
editDistance = 0;
|
editDistance = 0;
|
||||||
@ -543,7 +550,7 @@ private:
|
|||||||
const long long &below) {
|
const long long &below) {
|
||||||
long long r = above > below ? path[(size_t)k - 1 + offset]
|
long long r = above > below ? path[(size_t)k - 1 + offset]
|
||||||
: path[(size_t)k + 1 + offset];
|
: path[(size_t)k + 1 + offset];
|
||||||
long long y = max(above, below);
|
long long y = std::max(above, below);
|
||||||
long long x = y - k;
|
long long x = y - k;
|
||||||
while ((size_t)x < M && (size_t)y < N &&
|
while ((size_t)x < M && (size_t)y < N &&
|
||||||
(swapped ? cmp.impl(B[(size_t)y], A[(size_t)x])
|
(swapped ? cmp.impl(B[(size_t)y], A[(size_t)x])
|
||||||
@ -636,12 +643,12 @@ private:
|
|||||||
A = A_;
|
A = A_;
|
||||||
B = B_;
|
B = B_;
|
||||||
M = distance(A.begin(), A.end());
|
M = distance(A.begin(), A.end());
|
||||||
N = distance(B.begin(), B.end());
|
N = std::distance(B.begin(), B.end());
|
||||||
delta = N - M;
|
delta = N - M;
|
||||||
offset = M + 1;
|
offset = M + 1;
|
||||||
delete[] fp;
|
delete[] fp;
|
||||||
fp = new long long[M + N + 3];
|
fp = new long long[M + N + 3];
|
||||||
fill(&fp[0], &fp[M + N + 3], -1);
|
std::fill(&fp[0], &fp[M + N + 3], -1);
|
||||||
fill(path.begin(), path.end(), -1);
|
fill(path.begin(), path.end(), -1);
|
||||||
ox = x_idx - 1;
|
ox = x_idx - 1;
|
||||||
oy = y_idx - 1;
|
oy = y_idx - 1;
|
@ -38,13 +38,15 @@
|
|||||||
#ifndef DTL_DIFF3_H
|
#ifndef DTL_DIFF3_H
|
||||||
#define DTL_DIFF3_H
|
#define DTL_DIFF3_H
|
||||||
|
|
||||||
|
#include "Diff.hpp"
|
||||||
|
|
||||||
namespace dtl {
|
namespace dtl {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* diff3 class template
|
* diff3 class template
|
||||||
* sequence must support random_access_iterator.
|
* sequence must support random_access_iterator.
|
||||||
*/
|
*/
|
||||||
template <typename elem, typename sequence = vector<elem>,
|
template <typename elem, typename sequence = std::vector<elem>,
|
||||||
typename comparator = Compare<elem>>
|
typename comparator = Compare<elem>>
|
||||||
class Diff3 {
|
class Diff3 {
|
||||||
private:
|
private:
|
@ -38,6 +38,9 @@
|
|||||||
#ifndef DTL_LCS_H
|
#ifndef DTL_LCS_H
|
||||||
#define DTL_LCS_H
|
#define DTL_LCS_H
|
||||||
|
|
||||||
|
#include "variables.hpp"
|
||||||
|
#include "Sequence.hpp"
|
||||||
|
|
||||||
namespace dtl {
|
namespace dtl {
|
||||||
|
|
||||||
/**
|
/**
|
@ -45,7 +45,7 @@ namespace dtl {
|
|||||||
*/
|
*/
|
||||||
template <typename elem> class Sequence {
|
template <typename elem> class Sequence {
|
||||||
public:
|
public:
|
||||||
typedef vector<elem> elemVec;
|
typedef std::vector<elem> elemVec;
|
||||||
Sequence() {}
|
Sequence() {}
|
||||||
virtual ~Sequence() {}
|
virtual ~Sequence() {}
|
||||||
|
|
@ -38,6 +38,9 @@
|
|||||||
#ifndef DTL_SES_H
|
#ifndef DTL_SES_H
|
||||||
#define DTL_SES_H
|
#define DTL_SES_H
|
||||||
|
|
||||||
|
#include "variables.hpp"
|
||||||
|
#include "Sequence.hpp"
|
||||||
|
|
||||||
namespace dtl {
|
namespace dtl {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -46,7 +49,7 @@ namespace dtl {
|
|||||||
template <typename elem> class Ses : public Sequence<elem> {
|
template <typename elem> class Ses : public Sequence<elem> {
|
||||||
private:
|
private:
|
||||||
typedef pair<elem, elemInfo> sesElem;
|
typedef pair<elem, elemInfo> sesElem;
|
||||||
typedef vector<sesElem> sesElemVec;
|
typedef std::vector<sesElem> sesElemVec;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Ses() : onlyAdd(true), onlyDelete(true), onlyCopy(true), deletesFirst(false) {
|
Ses() : onlyAdd(true), onlyDelete(true), onlyCopy(true), deletesFirst(false) {
|
@ -36,6 +36,24 @@
|
|||||||
#ifndef DTL_H
|
#ifndef DTL_H
|
||||||
#define DTL_H
|
#define DTL_H
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <cassert>
|
||||||
|
#include <cstdio>
|
||||||
|
#include <fstream>
|
||||||
|
#include <iostream>
|
||||||
|
#include <list>
|
||||||
|
#include <sstream>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <time.h>
|
||||||
|
#ifdef HAVE_UNISTD_H
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif // HAVE_UNISTD_H
|
||||||
|
|
||||||
#include "Diff.hpp"
|
#include "Diff.hpp"
|
||||||
#include "Diff3.hpp"
|
#include "Diff3.hpp"
|
||||||
#include "Lcs.hpp"
|
#include "Lcs.hpp"
|
@ -38,14 +38,16 @@
|
|||||||
#ifndef DTL_FUNCTORS_H
|
#ifndef DTL_FUNCTORS_H
|
||||||
#define DTL_FUNCTORS_H
|
#define DTL_FUNCTORS_H
|
||||||
|
|
||||||
|
#include "variables.hpp"
|
||||||
|
|
||||||
namespace dtl {
|
namespace dtl {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* printer class template
|
* printer class template
|
||||||
*/
|
*/
|
||||||
template <typename sesElem, typename stream = ostream> class Printer {
|
template <typename sesElem, typename stream = std::ostream> class Printer {
|
||||||
public:
|
public:
|
||||||
Printer() : out_(cout) {}
|
Printer() : out_(std::cout) {}
|
||||||
Printer(stream &out) : out_(out) {}
|
Printer(stream &out) : out_(out) {}
|
||||||
virtual ~Printer() {}
|
virtual ~Printer() {}
|
||||||
virtual void operator()(const sesElem &se) const = 0;
|
virtual void operator()(const sesElem &se) const = 0;
|
||||||
@ -57,7 +59,7 @@ protected:
|
|||||||
/**
|
/**
|
||||||
* common element printer class template
|
* common element printer class template
|
||||||
*/
|
*/
|
||||||
template <typename sesElem, typename stream = ostream>
|
template <typename sesElem, typename stream = std::ostream>
|
||||||
class CommonPrinter : public Printer<sesElem, stream> {
|
class CommonPrinter : public Printer<sesElem, stream> {
|
||||||
public:
|
public:
|
||||||
CommonPrinter() : Printer<sesElem, stream>() {}
|
CommonPrinter() : Printer<sesElem, stream>() {}
|
||||||
@ -71,7 +73,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* ses element printer class template
|
* ses element printer class template
|
||||||
*/
|
*/
|
||||||
template <typename sesElem, typename stream = ostream>
|
template <typename sesElem, typename stream = std::ostream>
|
||||||
class ChangePrinter : public Printer<sesElem, stream> {
|
class ChangePrinter : public Printer<sesElem, stream> {
|
||||||
public:
|
public:
|
||||||
ChangePrinter() : Printer<sesElem, stream>() {}
|
ChangePrinter() : Printer<sesElem, stream>() {}
|
@ -38,12 +38,6 @@
|
|||||||
#ifndef DTL_VARIABLES_H
|
#ifndef DTL_VARIABLES_H
|
||||||
#define DTL_VARIABLES_H
|
#define DTL_VARIABLES_H
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
#include <iostream>
|
|
||||||
#include <list>
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace dtl {
|
namespace dtl {
|
||||||
|
|
||||||
using std::cout;
|
using std::cout;
|
20
test/CMakeLists.txt
Normal file
20
test/CMakeLists.txt
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
enable_testing()
|
||||||
|
find_package(GTest REQUIRED)
|
||||||
|
|
||||||
|
add_executable(dtl_test
|
||||||
|
test/Intdifftest.cpp
|
||||||
|
test/Objdifftest.cpp
|
||||||
|
test/Patchtest.cpp
|
||||||
|
test/Strdiff3test.cpp
|
||||||
|
test/Strdifftest.cpp
|
||||||
|
test/dtl_test.cpp
|
||||||
|
test/dtl_test_common.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(dtl_test BEFORE PRIVATE
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/test
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(dtl_test GTest::gtest GTest::gtest_main)
|
||||||
|
|
||||||
|
add_test(AllTests dtl_test)
|
@ -1,6 +1,7 @@
|
|||||||
#include "comparators.hpp"
|
|
||||||
#include "dtl_test_common.hpp"
|
#include "dtl_test_common.hpp"
|
||||||
|
|
||||||
|
#include "comparators.hpp"
|
||||||
|
|
||||||
class Objdifftest : public ::testing::Test {
|
class Objdifftest : public ::testing::Test {
|
||||||
protected:
|
protected:
|
||||||
dtl_test_typedefs(string, vector<elem>) typedef struct case_t {
|
dtl_test_typedefs(string, vector<elem>) typedef struct case_t {
|
||||||
|
@ -1,40 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
# SConstrunct for dtl test
|
|
||||||
|
|
||||||
import os
|
|
||||||
|
|
||||||
|
|
||||||
def path_chomp(path):
|
|
||||||
if path[-1] == '/':
|
|
||||||
return path[:-1]
|
|
||||||
return path
|
|
||||||
|
|
||||||
|
|
||||||
env = Environment(
|
|
||||||
CPPFLAGS=['-Wall', '-O2'],
|
|
||||||
CPPPATH=['..'],
|
|
||||||
CXXFLAGS="-std=c++11",
|
|
||||||
)
|
|
||||||
|
|
||||||
conf = Configure(env)
|
|
||||||
|
|
||||||
if not conf.CheckCXX():
|
|
||||||
print("c++ compiler is not installed!")
|
|
||||||
Exit(1)
|
|
||||||
|
|
||||||
libs = ['stdc++', 'pthread', 'gtest']
|
|
||||||
for lib in libs:
|
|
||||||
if not conf.CheckLib(lib):
|
|
||||||
print("library " + lib + " not installed!")
|
|
||||||
Exit(1)
|
|
||||||
|
|
||||||
conf.Finish()
|
|
||||||
|
|
||||||
test = env.Program(
|
|
||||||
'dtl_test',
|
|
||||||
[Glob('*.cpp')],
|
|
||||||
)
|
|
||||||
|
|
||||||
test_alias = env.Alias('check', test, test[0].abspath)
|
|
||||||
|
|
||||||
env.AlwaysBuild(test_alias)
|
|
@ -1,6 +1,7 @@
|
|||||||
#include "comparators.hpp"
|
|
||||||
#include "dtl_test_common.hpp"
|
#include "dtl_test_common.hpp"
|
||||||
|
|
||||||
|
#include "comparators.hpp"
|
||||||
|
|
||||||
class Strdiff3test : public ::testing::Test {
|
class Strdiff3test : public ::testing::Test {
|
||||||
protected:
|
protected:
|
||||||
dtl_test_typedefs(char, string) typedef struct case_t {
|
dtl_test_typedefs(char, string) typedef struct case_t {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include "comparators.hpp"
|
|
||||||
#include "dtl_test_common.hpp"
|
#include "dtl_test_common.hpp"
|
||||||
|
|
||||||
|
#include "comparators.hpp"
|
||||||
|
|
||||||
class Strdifftest : public ::testing::Test {
|
class Strdifftest : public ::testing::Test {
|
||||||
protected:
|
protected:
|
||||||
dtl_test_typedefs(char, string) typedef struct case_t {
|
dtl_test_typedefs(char, string) typedef struct case_t {
|
||||||
|
@ -1,16 +1,18 @@
|
|||||||
#ifndef DTL_COMPARATORS
|
#ifndef DTL_COMPARATORS
|
||||||
#define DTL_COMPARATORS
|
#define DTL_COMPARATORS
|
||||||
|
|
||||||
|
#include "functors.hpp"
|
||||||
|
|
||||||
class CaseInsensitive : public dtl::Compare<char> {
|
class CaseInsensitive : public dtl::Compare<char> {
|
||||||
public:
|
public:
|
||||||
virtual bool impl(const char &a, const char &b) const {
|
virtual bool impl(const char &a, const char &b) const {
|
||||||
return tolower(a) == tolower(b);
|
return std::tolower(a) == std::tolower(b);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class StringCaseInsensitive : public dtl::Compare<string> {
|
class StringCaseInsensitive : public dtl::Compare<std::string> {
|
||||||
public:
|
public:
|
||||||
virtual bool impl(const string &a, const string &b) const {
|
virtual bool impl(const std::string &a, const std::string &b) const {
|
||||||
if (a.length() == b.length()) {
|
if (a.length() == b.length()) {
|
||||||
bool equal = (strncasecmp(a.c_str(), b.c_str(), a.length()) == 0);
|
bool equal = (strncasecmp(a.c_str(), b.c_str(), a.length()) == 0);
|
||||||
return equal;
|
return equal;
|
||||||
|
@ -1,8 +1,4 @@
|
|||||||
/**
|
#include "dtl_test_common.hpp"
|
||||||
* It is necessary to use googletest to run tests.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
::testing::InitGoogleTest(&argc, argv);
|
::testing::InitGoogleTest(&argc, argv);
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
#include "dtl_test_common.hpp"
|
#include "dtl_test_common.hpp"
|
||||||
|
|
||||||
string create_path(const string &test_name, string diff_name, enum type_diff t,
|
string create_path(const string &test_name, string diff_name, enum type_diff t,
|
||||||
|
@ -1,15 +1,9 @@
|
|||||||
|
|
||||||
#ifndef DTL_TEST_COMMON
|
#ifndef DTL_TEST_COMMON
|
||||||
#define DTL_TEST_COMMON
|
#define DTL_TEST_COMMON
|
||||||
|
|
||||||
#include <cstdio>
|
|
||||||
#include <dtl/dtl.hpp>
|
|
||||||
#include <fstream>
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <iostream>
|
|
||||||
#include <string>
|
#include "dtl.hpp"
|
||||||
#include <utility>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
using std::cerr;
|
using std::cerr;
|
||||||
using std::endl;
|
using std::endl;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user