summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfedor-miron <[email protected]>2024-03-26 19:09:32 +0300
committerfedor-miron <[email protected]>2024-03-26 19:22:49 +0300
commitbb08fef4f96901b74dccb18e03b4ca658a63ff44 (patch)
tree5bd3442dcc3cb7f166bf16362b3cefba366a82ad
parentce034cd07e7ebbff42723e51067bac58d1943f47 (diff)
sync to ydb gh
c485fa07ffd78ecf7bcc7086b0a7cd4c2f20efd3
-rw-r--r--contrib/libs/dtl/.yandex_meta/devtools.copyrights.report54
-rw-r--r--contrib/libs/dtl/.yandex_meta/devtools.licenses.report129
-rw-r--r--contrib/libs/dtl/.yandex_meta/licenses.list.txt74
-rw-r--r--contrib/libs/dtl/CONTRIBUTORS2
-rw-r--r--contrib/libs/dtl/COPYING30
-rw-r--r--contrib/libs/dtl/ChangeLog264
-rw-r--r--contrib/libs/dtl/README.md685
-rw-r--r--contrib/libs/dtl/dtl/Diff.hpp706
-rw-r--r--contrib/libs/dtl/dtl/Diff3.hpp245
-rw-r--r--contrib/libs/dtl/dtl/Lcs.hpp55
-rw-r--r--contrib/libs/dtl/dtl/Sequence.hpp65
-rw-r--r--contrib/libs/dtl/dtl/Ses.hpp132
-rw-r--r--contrib/libs/dtl/dtl/dtl.hpp47
-rw-r--r--contrib/libs/dtl/dtl/functors.hpp151
-rw-r--r--contrib/libs/dtl/dtl/variables.hpp142
-rw-r--r--contrib/libs/dtl/ya.make18
16 files changed, 2799 insertions, 0 deletions
diff --git a/contrib/libs/dtl/.yandex_meta/devtools.copyrights.report b/contrib/libs/dtl/.yandex_meta/devtools.copyrights.report
new file mode 100644
index 00000000000..91f00704a76
--- /dev/null
+++ b/contrib/libs/dtl/.yandex_meta/devtools.copyrights.report
@@ -0,0 +1,54 @@
+# File format ($ symbol means the beginning of a line):
+#
+# $ # this message
+# $ # =======================
+# $ # comments (all commentaries should starts with some number of spaces and # symbol)
+# $ IGNORE_FILES {file1.ext1} {file2.ext2} - (optional) ignore listed files when generating license macro and credits
+# $ RENAME {original license id} TO {new license id} # user comments - (optional) use {new license id} instead {original license id} in ya.make files
+# $ # user comments
+# $
+# ${action} {license id} {license text hash}
+# $BELONGS ./ya/make/file/relative/path/1/ya.make ./ya/make/2/ya.make
+# ${all_file_action} filename
+# $ # user commentaries (many lines)
+# $ generated description - files with this license, license text... (some number of lines that starts with some number of spaces, do not modify)
+# ${action} {license spdx} {license text hash}
+# $BELONGS ./ya/make/file/relative/path/3/ya.make
+# ${all_file_action} filename
+# $ # user commentaries
+# $ generated description
+# $ ...
+#
+# You can modify action, all_file_action and add commentaries
+# Available actions:
+# keep - keep license in contrib and use in credits
+# skip - skip license
+# remove - remove all files with this license
+# rename - save license text/links into licenses texts file, but not store SPDX into LINCENSE macro. You should store correct license id into devtools.license.spdx.txt file
+#
+# {all file action} records will be generated when license text contains filename that exists on filesystem (in contrib directory)
+# We suppose that that files can contain some license info
+# Available all file actions:
+# FILE_IGNORE - ignore file (do nothing)
+# FILE_INCLUDE - include all file data into licenses text file
+# =======================
+
+KEEP COPYRIGHT_SERVICE_LABEL 3f620f1814a44ba65d1ffd0d1615c604
+BELONGS ya.make
+ License text:
+ Copyright (c) 2015 Tatsuhiko Kubo <[email protected]>
+ All rights reserved.
+ Scancode info:
+ Original SPDX id: COPYRIGHT_SERVICE_LABEL
+ Score : 100.00
+ Match type : COPYRIGHT
+ Files with this license:
+ COPYING [3:4]
+ dtl/Diff.hpp [6:7]
+ dtl/Diff3.hpp [6:7]
+ dtl/Lcs.hpp [6:7]
+ dtl/Sequence.hpp [6:7]
+ dtl/Ses.hpp [6:7]
+ dtl/dtl.hpp [6:7]
+ dtl/functors.hpp [6:7]
+ dtl/variables.hpp [6:7]
diff --git a/contrib/libs/dtl/.yandex_meta/devtools.licenses.report b/contrib/libs/dtl/.yandex_meta/devtools.licenses.report
new file mode 100644
index 00000000000..23c4410c90b
--- /dev/null
+++ b/contrib/libs/dtl/.yandex_meta/devtools.licenses.report
@@ -0,0 +1,129 @@
+# File format ($ symbol means the beginning of a line):
+#
+# $ # this message
+# $ # =======================
+# $ # comments (all commentaries should starts with some number of spaces and # symbol)
+# $ IGNORE_FILES {file1.ext1} {file2.ext2} - (optional) ignore listed files when generating license macro and credits
+# $ RENAME {original license id} TO {new license id} # user comments - (optional) use {new license id} instead {original license id} in ya.make files
+# $ # user comments
+# $
+# ${action} {license id} {license text hash}
+# $BELONGS ./ya/make/file/relative/path/1/ya.make ./ya/make/2/ya.make
+# ${all_file_action} filename
+# $ # user commentaries (many lines)
+# $ generated description - files with this license, license text... (some number of lines that starts with some number of spaces, do not modify)
+# ${action} {license spdx} {license text hash}
+# $BELONGS ./ya/make/file/relative/path/3/ya.make
+# ${all_file_action} filename
+# $ # user commentaries
+# $ generated description
+# $ ...
+#
+# You can modify action, all_file_action and add commentaries
+# Available actions:
+# keep - keep license in contrib and use in credits
+# skip - skip license
+# remove - remove all files with this license
+# rename - save license text/links into licenses texts file, but not store SPDX into LINCENSE macro. You should store correct license id into devtools.license.spdx.txt file
+#
+# {all file action} records will be generated when license text contains filename that exists on filesystem (in contrib directory)
+# We suppose that that files can contain some license info
+# Available all file actions:
+# FILE_IGNORE - ignore file (do nothing)
+# FILE_INCLUDE - include all file data into licenses text file
+# =======================
+
+KEEP LicenseRef-scancode-unknown-license-reference 27ff83b6d7e95b709c1a8b94532ebef1
+BELONGS ya.make
+ License text:
+ Please read the file [COPYING](https://github.com/cubicdaiya/dtl/blob/master/COPYING).
+ Scancode info:
+ Original SPDX id: LicenseRef-scancode-unknown-license-reference
+ Score : 22.00
+ Match type : REFERENCE
+ Links : https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/unknown-license-reference.LICENSE
+ Files with this license:
+ README.md [685:685]
+
+KEEP LicenseRef-scancode-unknown-license-reference AND BSD-3-Clause 3d436eacb955b50a8f94435e0ba12145
+BELONGS ya.make
+ License text:
+ In short, Diff Template Library is distributed under so called "BSD license",
+ Scancode info:
+ Original SPDX id: LicenseRef-scancode-unknown-license-reference
+ Score : 11.00
+ Match type : INTRO
+ Links : https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/unknown-license-reference.LICENSE
+ Files with this license:
+ dtl/Diff.hpp [4:4]
+ dtl/Diff3.hpp [4:4]
+ dtl/Lcs.hpp [4:4]
+ dtl/Sequence.hpp [4:4]
+ dtl/Ses.hpp [4:4]
+ dtl/dtl.hpp [4:4]
+ dtl/functors.hpp [4:4]
+ dtl/variables.hpp [4:4]
+ Scancode info:
+ Original SPDX id: BSD-3-Clause
+ Score : 99.00
+ Match type : REFERENCE
+ Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause
+ Files with this license:
+ dtl/Diff.hpp [4:4]
+ dtl/Diff3.hpp [4:4]
+ dtl/Lcs.hpp [4:4]
+ dtl/Sequence.hpp [4:4]
+ dtl/Ses.hpp [4:4]
+ dtl/dtl.hpp [4:4]
+ dtl/functors.hpp [4:4]
+ dtl/variables.hpp [4:4]
+
+KEEP BSD-3-Clause 56b06256bb85447fc6145d2460ad8aca
+BELONGS ya.make
+FILE_INCLUDE CONTRIBUTORS found in files: COPYING at line 20, COPYING at line 24
+ Note: matched license text is too long. Read it in the source files.
+ Scancode info:
+ Original SPDX id: BSD-3-Clause
+ Score : 100.00
+ Match type : TEXT
+ Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause
+ Files with this license:
+ COPYING [6:30]
+
+KEEP LicenseRef-scancode-unknown-license-reference AND BSD-3-Clause d9ebc19a46340bfaf128a098aade97ed
+BELONGS ya.make
+ License text:
+ In short, Diff Template Library is distributed under so called "BSD license",
+ Scancode info:
+ Original SPDX id: LicenseRef-scancode-unknown-license-reference
+ Score : 11.00
+ Match type : INTRO
+ Links : https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/unknown-license-reference.LICENSE
+ Files with this license:
+ COPYING [1:1]
+ Scancode info:
+ Original SPDX id: BSD-3-Clause
+ Score : 99.00
+ Match type : REFERENCE
+ Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause
+ Files with this license:
+ COPYING [1:1]
+
+KEEP BSD-3-Clause f915ab3bdea0afd017f002b31f72027d
+BELONGS ya.make
+FILE_INCLUDE CONTRIBUTORS found in files: dtl/Diff.hpp at line 23, dtl/Diff.hpp at line 27, dtl/Diff3.hpp at line 23, dtl/Diff3.hpp at line 27, dtl/Lcs.hpp at line 23, dtl/Lcs.hpp at line 27, dtl/Sequence.hpp at line 23, dtl/Sequence.hpp at line 27, dtl/Ses.hpp at line 23, dtl/Ses.hpp at line 27, dtl/dtl.hpp at line 23, dtl/dtl.hpp at line 27, dtl/functors.hpp at line 23, dtl/functors.hpp at line 27, dtl/variables.hpp at line 23, dtl/variables.hpp at line 27
+ Note: matched license text is too long. Read it in the source files.
+ Scancode info:
+ Original SPDX id: BSD-3-Clause
+ Score : 100.00
+ Match type : TEXT
+ Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause
+ Files with this license:
+ dtl/Diff.hpp [9:33]
+ dtl/Diff3.hpp [9:33]
+ dtl/Lcs.hpp [9:33]
+ dtl/Sequence.hpp [9:33]
+ dtl/Ses.hpp [9:33]
+ dtl/dtl.hpp [9:33]
+ dtl/functors.hpp [9:33]
+ dtl/variables.hpp [9:33]
diff --git a/contrib/libs/dtl/.yandex_meta/licenses.list.txt b/contrib/libs/dtl/.yandex_meta/licenses.list.txt
new file mode 100644
index 00000000000..523a76b40a1
--- /dev/null
+++ b/contrib/libs/dtl/.yandex_meta/licenses.list.txt
@@ -0,0 +1,74 @@
+====================BSD-3-Clause====================
+ Redistribution and use in source and binary forms, with or without modification,
+ are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ * Neither the name of the authors nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+====================BSD-3-Clause====================
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ * Neither the name of the authors nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+====================COPYRIGHT====================
+Copyright (c) 2015 Tatsuhiko Kubo <[email protected]>
+All rights reserved.
+
+
+====================File: CONTRIBUTORS====================
+Tatsuhiko Kubo <[email protected]>
+Jan Weiß <[email protected]>
+
+
+====================LicenseRef-scancode-unknown-license-reference====================
+Please read the file [COPYING](https://github.com/cubicdaiya/dtl/blob/master/COPYING).
+
+====================LicenseRef-scancode-unknown-license-reference AND BSD-3-Clause====================
+ In short, Diff Template Library is distributed under so called "BSD license",
+
+
+====================LicenseRef-scancode-unknown-license-reference AND BSD-3-Clause====================
+In short, Diff Template Library is distributed under so called "BSD license",
diff --git a/contrib/libs/dtl/CONTRIBUTORS b/contrib/libs/dtl/CONTRIBUTORS
new file mode 100644
index 00000000000..d02130a8cd6
--- /dev/null
+++ b/contrib/libs/dtl/CONTRIBUTORS
@@ -0,0 +1,2 @@
+Tatsuhiko Kubo <[email protected]>
+Jan Weiß <[email protected]>
diff --git a/contrib/libs/dtl/COPYING b/contrib/libs/dtl/COPYING
new file mode 100644
index 00000000000..50b2ef04efe
--- /dev/null
+++ b/contrib/libs/dtl/COPYING
@@ -0,0 +1,30 @@
+In short, Diff Template Library is distributed under so called "BSD license",
+
+Copyright (c) 2015 Tatsuhiko Kubo <[email protected]>
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ * Neither the name of the authors nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/contrib/libs/dtl/ChangeLog b/contrib/libs/dtl/ChangeLog
new file mode 100644
index 00000000000..de19a6bee3a
--- /dev/null
+++ b/contrib/libs/dtl/ChangeLog
@@ -0,0 +1,264 @@
+2022-04-11 Tatsuhiko Kubo <[email protected]>
+
+ * bugfix: fixed invalid offset in unified format difference when difference is too large.
+
+ * 1.20 released
+
+2015-05-03 Tatsuhiko Kubo <[email protected]>
+
+ * added some minor changes.
+
+ * 1.19 released
+
+2013-01-10 Tatsuhiko Kubo <[email protected]>
+
+ * add printSES function for custom Printer Thanks to Hu Shubin
+
+ * remove files related mercurial
+
+ * 1.18 released
+
+2012-11-18 Tatsuhiko Kubo <[email protected]>
+
+ * add version-string variable
+
+ * replace get_current_dir_name to getcwd(get_current_dir_name is not in Mountain Lion)
+
+ * fix small typo
+
+ * 1.17 released
+
+2012-10-26 Tatsuhiko Kubo <[email protected]>, Jan Weiß <[email protected]>
+
+ * Improving comments
+
+ * rewrite README with markdown-style
+
+ * support gtest1.6
+
+ * allow clients to handle if DTL swaps the arrays it is passed
+
+ * fix incorrect results for SES_COMMON when swapped
+
+ * add explicit initialization of ses
+
+ * implement option to force the order of sesElem objects in the ses
+
+ * fix problem -> issues/4(test succeeds when result-file does not exist)
+
+ * 1.16 released
+
+2011-11-10 Tatsuhiko Kubo <[email protected]>
+
+ * remove unused variable
+
+ * 1.15 released
+
+2011-06-18 Tatsuhiko Kubo <[email protected]>
+
+ * fix Issue #7 (isOnlyOneOperation returns incorrect value)
+
+ * 1.14 released
+
+2011-04-10 Tatsuhiko Kubo <[email protected]>
+
+ * add check for libraries with SCons
+
+ * add installer with SCons
+
+ * add sample of diff(bdiff)
+
+ * 1.13 released
+
+2011-01-23 Tatsuhiko Kubo <[email protected]>
+
+ * forget to add template parameter of stream for print methods of printUnifiedFormat
+
+ * 1.12 released
+
+2011-01-01 Tatsuhiko Kubo <[email protected]>
+
+ * add template parameter of stream for print methods
+
+ * function of importing ses
+
+ * 1.11 released
+
+2010-11-23 Tatsuhiko Kubo <[email protected]>
+
+ * use static_cast instead of C-style cast
+
+ * remove specifyConfliction
+
+ * 1.10 released
+
+2010-09-20 Tatsuhiko Kubo <[email protected]>
+
+ * fix bug of specifyConfliction
+
+ * add parameter for Diff3's comparator
+
+ * fix the bug which uniPatch fails
+
+ * add debug option for examples
+
+ * divide test sources
+
+ * 1.09 released
+
+2010-08-29 Tatsuhiko Kubo <[email protected]>
+
+ * fix the problem that comparator parameter is completely ignored.
+
+ * remove the warning 'comparison of unsigned expression >= 0 is always true' ( use -W )
+
+ * move directory 'src' to 'dtl'
+
+ * remove Makefile for examples and test
+
+ * 1.08 released
+
+2010-07-11 Tatsuhiko Kubo <[email protected]>
+
+ * fix potential risk on 64bit environment(size of 'int' and size of 'size_t')
+
+ * add scons
+
+ * fix bug of specifyConfliction
+
+ * fix memory leak when onlyEditDistance is true
+
+ * change indent size from 2 to 4
+
+ * 1.07 released
+
+2010-05-01 Tatsuhiko Kubo <[email protected]>
+
+ * add specifyConfliction
+
+ * 1.06 released
+
+2010-04-13 Tatsuhiko Kubo <[email protected]>
+
+ * constructors takes referenced parameter
+
+ * fix seg fault bug (http://code.google.com/p/dtl-cpp/issues/detail?id=2)
+
+ * 1.05 released
+
+2009-12-01 Tatsuhiko Kubo <[email protected]>
+
+ * add test programs with googletest
+
+ * add sample of diff(uintdiff)
+
+ * 1.04 released
+
+2009-10-02 Tatsuhiko Kubo <[email protected]>
+
+ * add function getLcsVec
+
+ * divide header files
+
+ * 1.03 released
+
+2009-09-08 Tatsuhiko Kubo <[email protected]>
+
+ * rename editType to edit_t
+
+ * add print functions
+
+ * add functor of compare
+
+ * use 'using' declaration
+
+ * refactoring
+
+ * add ignore patterns for Mercurial
+
+ * 1.02 released.
+
+2009-08-08 Tatsuhiko Kubo <[email protected]>
+
+ * append appropriate const keyword
+
+ * refactoring
+
+ * 1.01 released.
+
+2009-07-04 Tatsuhiko Kubo <[email protected]>
+
+ * resolve problem memory leak occurs when default copy constructor set in motion.
+
+ * 1.00 released.
+
+2009-06-08 Tatsuhiko Kubo <[email protected]>
+
+ * enhance readability
+
+ * change behavior when conflicted
+
+ * decliment parameter for patch function
+
+ * 0.07 released.
+
+2009-05-08 Tatsuhiko Kubo <[email protected]>
+
+ * add flag for recording only editdistance
+
+ * add sample of unidiff for string (unistrdiff)
+
+ * add unserious diff. ver 0.03 has this feture.
+
+ * fix bug for merge
+
+ * add function getUniHunks
+
+ * 0.06 released.
+
+2008-12-12 Tatsuhiko Kubo <[email protected]>
+
+ * add sample of diff3 (strdiff3, intdiff3)
+
+ * add diff3
+
+ * + -> - to - -> + with Unified Diff Format
+
+ * add function uniPatch. this function can patch with Unified Diff Format Data Structure
+
+ * dtl Import Unified Diff Format Data Structure from unidiff.cpp.
+
+ * fix bug. function check whether file exists(common.cpp)
+
+ * 0.05 released.
+
+2008-11-10 Tatsuhiko Kubo <[email protected]>
+
+ * Improves accuracy of diff
+
+ * fix serious memory bug for patch
+
+ * changed type of argument in function fileExists(common.hpp, common.cpp)
+
+ * 0.04 released.
+
+2008-11-06 Tatsuhiko Kubo <[email protected]>
+
+ * add erorr check for sample programs
+
+ * 0.03 released.
+
+2008-10-31 Tatsuhiko Kubo <[email protected]>
+
+ * rename ChangLog to ChangeLog
+
+ * modifiy README
+
+ * output OK message on patch and fpatch
+
+ * 0.02 released.
+
+2008-10-30 Tatsuhiko Kubo <[email protected]>
+
+ * 0.01 released.
+
diff --git a/contrib/libs/dtl/README.md b/contrib/libs/dtl/README.md
new file mode 100644
index 00000000000..4a8ee208d6b
--- /dev/null
+++ b/contrib/libs/dtl/README.md
@@ -0,0 +1,685 @@
+# dtl
+
+`dtl` is the diff template library written in C++. The name of template is derived C++'s Template.
+
+# Table of contents
+
+ * [Features](#features)
+ * [Getting started](#getting-started)
+ * [Compare two strings](#compare-two-strings)
+ * [Compare two data has arbitrary type](#compare-two-data-has-arbitrary-type)
+ * [Merge three sequences](#merge-three-sequences)
+ * [Patch function](#patch-function)
+ * [Difference as Unified Format](#difference-as-unified-format)
+ * [Compare large sequences](#compare-large-sequences)
+ * [Unserious difference](#unserious-difference)
+ * [Calculate only Edit Distance](#calculate-only-edit-distance)
+ * [Algorithm](#algorithm)
+ * [Computational complexity](#computational-complexity)
+ * [Comparison when difference between two sequences is very large](#comparison-when-difference-between-two-sequences-is-very-large)
+ * [Implementations with various programming languages](#implementations-with-various-programming-languages)
+ * [Examples](#examples)
+ * [strdiff](#strdiff)
+ * [intdiff](#intdiff)
+ * [unidiff](#unidiff)
+ * [unistrdiff](#unistrdiff)
+ * [strdiff3](#strdiff3)
+ * [intdiff3](#intdiff3)
+ * [patch](#patch)
+ * [fpatch](#fpatch)
+ * [Running tests](#running-tests)
+ * [Building test programs](#building-test-programs)
+ * [Running test programs](#running-test-programs)
+ * [Old commit histories](#old-commit-histories)
+ * [License](#license)
+
+# Features
+
+`dtl` provides the functions for comparing two sequences have arbitrary type. But sequences must support random access\_iterator.
+
+# Getting started
+
+To start using this library, all you need to do is include `dtl.hpp`.
+
+```c++
+#include "dtl/dtl.hpp"
+```
+
+## Compare two strings
+
+First of all, calculate the difference between two strings.
+
+```c++
+typedef char elem;
+typedef std::string sequence;
+sequence A("abc");
+sequence B("abd");
+dtl::Diff< elem, sequence > d(A, B);
+d.compose();
+```
+
+When the above code is run, `dtl` calculates the difference between A and B as Edit Distance and LCS and SES.
+
+The meaning of these three terms is below.
+
+| Edit Distance | Edit Distance is numerical value for declaring a difference between two sequences. |
+|:--------------|:-----------------------------------------------------------------------------------|
+| LCS | LCS stands for Longest Common Subsequence. |
+| SES | SES stands for Shortest Edit Script. I mean SES is the shortest course of action for tranlating one sequence into another sequence.|
+
+If one sequence is "abc" and another sequence is "abd", Edit Distance and LCS and SES is below.
+
+| Edit Distance | 2 |
+|:--------------|:----------------|
+| LCS | ab |
+| SES | C a C b D c A d |
+
+ * 「C」:Common
+ * 「D」:Delete
+ * 「A」:ADD
+
+If you want to know in more detail, please see [examples/strdiff.cpp](https://github.com/cubicdaiya/dtl/blob/master/examples/strdiff.cpp).
+
+This calculates Edit Distance and LCS and SES of two strings received as command line arguments and prints each.
+
+When one string is "abc" and another string "abd", the output of `strdiff` is below.
+
+```bash
+$ ./strdiff abc abd
+editDistance:2
+LCS:ab
+SES
+ a
+ b
+-c
++d
+$
+```
+
+## Compare two data has arbitrary type
+
+`dtl` can compare data has aribtrary type because of the C++'s template.
+
+But the compared data type must support the random access\_iterator.
+
+In the previous example, the string data compared,
+
+`dtl` can also compare two int vectors like the example below.
+
+```c++
+int a[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+int b[10] = {3, 5, 1, 4, 5, 1, 7, 9, 6, 10};
+std::vector<int> A(&a[0], &a[10]);
+std::vector<int> B(&b[0], &b[10]);
+dtl::Diff< int > d(A, B);
+d.compose();
+```
+
+If you want to know in more detail, please see [examples/intdiff.cpp](https://github.com/cubicdaiya/dtl/blob/master/examples/intdiff.cpp).
+
+## Merge three sequences
+
+`dtl` has the diff3 function.
+
+This function is that `dtl` merges three sequences.
+
+Additionally `dtl` detects the confliction.
+
+```c++
+typedef char elem;
+typedef std::string sequence;
+sequence A("qqqabc");
+sequence B("abc");
+sequence C("abcdef");
+dtl::Diff3<elem, sequence> diff3(A, B, C);
+diff3.compose();
+if (!diff3.merge()) {
+ std::cerr << "conflict." << std::endl;
+ return -1;
+}
+std::cout << "result:" << diff3.getMergedSequence() << std::endl;
+```
+
+When the above code is run, the output is below.
+
+```console
+result:qqqabcdef
+```
+
+If you want to know in more detail, please see [examples/strdiff3.cpp](https://github.com/cubicdaiya/dtl/blob/master/examples/strdiff3.cpp).
+
+## Patch function
+
+`dtl` can also translates one sequence to another sequence with SES.
+
+```c++
+typedef char elem;
+typedef std::string sequence;
+sequence A("abc");
+sequence B("abd");
+dtl::Diff<elem, sequence> d(A, B);
+d.compose();
+string s1(A);
+string s2 = d.patch(s1);
+```
+
+When the above code is run, s2 becomes "abd".
+The SES of A("abc") and B("abd") is below.
+
+```console
+Common a
+Common b
+Delete c
+Add d
+```
+
+The patch function translates a sequence as argument with SES.
+For this example, "abc" is translated to "abd" with above SES.
+
+Please see dtl's header files about the data structure of SES.
+
+## Difference as Unified Format
+
+`dtl` can also treat difference as Unified Format. See the example below.
+
+```c++
+typedef char elem;
+typedef std::string sequence;
+sequence A("acbdeaqqqqqqqcbed");
+sequence B("acebdabbqqqqqqqabed");
+dtl::Diff<elem, sequence > d(A, B);
+d.compose(); // construct an edit distance and LCS and SES
+d.composeUnifiedHunks(); // construct a difference as Unified Format with SES.
+d.printUnifiedFormat(); // print a difference as Unified Format.
+```
+
+The difference as Unified Format of "acbdeaqqqqqqqcbed" and "acebdabbqqqqqqqabed" is below.
+
+```diff
+@@ -1,9 +1,11 @@
+ a
+ c
++e
+ b
+ d
+-e
+ a
++b
++b
+ q
+ q
+ q
+@@ -11,7 +13,7 @@
+ q
+ q
+ q
+-c
++a
+ b
+ e
+ d
+```
+
+The data structure Unified Format is below.
+
+```c++
+/**
+ * Structure of Unified Format Hunk
+ */
+template <typename sesElem>
+struct uniHunk {
+ int a, b, c, d; // @@ -a,b +c,d @@
+ std::vector<sesElem> common[2]; // anteroposterior commons on changes
+ std::vector<sesElem> change; // changes
+ int inc_dec_count; // count of increace and decrease
+};
+```
+
+The actual blocks of Unified Format is this structure's vector.
+
+If you want to know in more detail, please see [examples/unistrdiff.cpp](https://github.com/cubicdaiya/dtl/blob/master/examples/unistrdiff.cpp)
+and [examples/unidiff.cpp](https://github.com/cubicdaiya/dtl/blob/master/examples/unidiff.cpp) and dtl's header files.
+
+In addtion, `dtl` has the function translates one sequence to another sequence with Unified Format.
+
+```c++
+typedef char elem;
+typedef std::string sequence;
+sequence A("abc");
+sequence B("abd");
+dtl::Diff<elem, sequence> d(A, B);
+d.compose();
+d.composeUnifiedHunks()
+string s1(A);
+string s2 = d.uniPatch(s1);
+```
+
+When the above code is run, s2 becomes "abd".
+The uniPatch function translates a sequence as argument with Unified Format blocks.
+
+For this example, "abc" is translated to "abd" with the Unified Format block below.
+
+```diff
+@@ -1,3 +1,3 @@
+ a
+ b
+-c
++d
+```
+
+## Compare large sequences
+
+When compare two large sequences, `dtl` can optimizes the calculation of difference with the onHuge function.
+
+This function is available when the compared data type is std::vector.
+
+When you use this function, you may call this function before calling compose function.
+
+```c++
+typedef char elem;
+typedef std::vector<elem> sequence;
+sequence A;
+sequence B;
+/* ・・・ */
+dtl::Diff< elem, sequence > d(A, B);
+d.onHuge();
+d.compose();
+```
+
+## Unserious difference
+
+The calculation of difference is very heavy.
+`dtl` uses An O(NP) Sequence Comparison Algorithm.
+
+Though this Algorithm is sufficiently fast,
+when difference between two sequences is very large,
+
+the calculation of LCS and SES needs massive amounts of memory.
+
+`dtl` avoids above-described problem by dividing each sequence into plural subsequences
+and joining the difference of each subsequence finally.
+
+As this way repeats allocating massive amounts of memory,
+`dtl` provides other way. It is the way of calculating unserious difference.
+
+For example, The normal SES of "abc" and "abd" is below.
+
+```console
+Common a
+Common b
+Delete c
+Add d
+```
+
+The unserious SES of "abc" and "abd" is below.
+
+```console
+Delete a
+Delete b
+Delete c
+Add a
+Add b
+Add d
+```
+
+Of course, when "abc" and "abd" are compared with `dtl`, above difference is not derived.
+
+`dtl` calculates the unserious difference when `dtl` judges the calculation of LCS and SES
+needs massive amounts of memory and unserious difference function is ON.
+
+`dtl` joins the calculated difference before `dtl` judges it and unserious difference finally.
+
+As a result, all difference is not unserious difference when unserious difference function is ON.
+
+When you use this function, you may call this function before calling compose function.
+
+```c++
+typedef char elem;
+typedef std::string sequence;
+sequence A("abc");
+sequence B("abd");
+dtl::Diff< elem, sequence > d(A, B);
+d.onUnserious();
+d.compose();
+```
+
+## Calculate only Edit Distance
+
+As using onOnlyEditDistance, `dtl` calculates the only edit distance.
+
+If you need only edit distance, you may use this function,
+because the calculation of edit distance is lighter than the calculation of LCS and SES.
+
+When you use this function, you may call this function before calling compose function.
+
+```c++
+typedef char elem;
+typedef std::string sequence;
+sequence A("abc");
+sequence B("abd");
+dtl::Diff< elem, sequence > d(A, B);
+d.onOnlyEditDistance();
+d.compose();
+```
+
+# Algorithm
+
+The algorithm `dtl` uses is based on "An O(NP) Sequence Comparison Algorithm" by described by Sun Wu, Udi Manber and Gene Myers.
+
+An O(NP) Sequence Comparison Algorithm(following, Wu's O(NP) Algorithm) is the efficient algorithm for comparing two sequences.
+
+## Computational complexity
+
+The computational complexity of Wu's O(NP) Algorithm is averagely O(N+PD), in the worst case, is O(NP).
+
+## Comparison when difference between two sequences is very large
+
+Calculating LCS and SES efficiently at any time is a little difficult.
+
+Because that the calculation of LCS and SES needs massive amounts of memory when a difference between two sequences is very large.
+
+The program uses that algorithm don't consider that will burst in the worst case.
+
+`dtl` avoids above-described problem by dividing each sequence into plural subsequences and joining the difference of each subsequence finally. (This feature is supported after version 0.04)
+
+## Implementations with various programming languages
+
+There are the Wu's O(NP) Algorithm implementations with various programming languages below.
+
+https://github.com/cubicdaiya/onp
+
+# Examples
+
+There are examples in [dtl/examples](https://github.com/cubicdaiya/dtl/tree/master/examples).
+`dtl` uses [SCons](http://scons.org/) for building examples and tests. If you build and run examples and tests, install SCons.
+
+## strdiff
+
+`strdiff` calculates a difference between two string sequences, but multi byte is not supported.
+
+```bash
+$ cd dtl/examples
+$ scons strdiff
+$ ./strdiff acbdeacbed acebdabbabed
+editDistance:6
+LCS:acbdabed
+SES
+ a
+ c
++ e
+ b
+ d
+- e
+ a
+- c
+ b
++ b
++ a
++ b
+ e
+ d
+$
+```
+
+## intdiff
+
+`intdiff` calculates a diffrence between two int arrays sequences.
+
+```bash
+$ cd dtl/examples
+$ scons intdiff
+$ ./intdiff # There are data in intdiff.cpp
+1 2 3 4 5 6 7 8 9 10
+3 5 1 4 5 1 7 9 6 10
+editDistance:8
+LCS: 3 4 5 7 9 10
+SES
+- 1
+- 2
+ 3
++ 5
++ 1
+ 4
+ 5
+- 6
++ 1
+ 7
+- 8
+ 9
++ 6
+ 10
+$
+```
+
+## unidiff
+
+`unidiff` calculates a diffrence between two text file sequences,
+and output the difference between files with unified format.
+
+```bash
+$ cd dtl/examples
+$ scons unidiff
+$ cat a.txt
+a
+e
+c
+z
+z
+d
+e
+f
+a
+b
+c
+d
+e
+f
+g
+h
+i
+$ cat b.txt
+a
+d
+e
+c
+f
+e
+a
+b
+c
+d
+e
+f
+g
+h
+i
+$ ./unidiff a.txt b.txt
+--- a.txt 2008-08-26 07:03:28 +0900
++++ b.txt 2008-08-26 03:02:42 +0900
+@@ -1,11 +1,9 @@
+ a
+-e
+-c
+-z
+-z
+ d
+ e
++c
+ f
++e
+ a
+ b
+ c
+$
+```
+
+## unistrdiff
+
+`unistrdiff` calculates a diffrence between two string sequences.
+and output the difference between strings with unified format.
+
+```bash
+$ cd dtl/examples
+$ scons unistrdiff
+$ ./unistrdiff acbdeacbed acebdabbabed
+editDistance:6
+LCS:acbdabed
+@@ -1,10 +1,12 @@
+ a
+ c
++e
+ b
+ d
+-e
+ a
+-c
+ b
++b
++a
++b
+ e
+ d
+$
+```
+
+## strdiff3
+
+`strdiff3` merges three string sequence and output the merged sequence.
+When the confliction has occured, output the string "conflict.".
+
+```bash
+$ cd dtl/examples
+$ scons strdiff3
+$ ./strdiff3 qabc abc abcdef
+result:qabcdef
+$
+```
+
+There is a output below when conflict occured.
+
+```bash
+$ ./strdiff3 adc abc aec
+conflict.
+$
+```
+
+## intdiff3
+
+`intdiff3` merges three integer sequence(vector) and output the merged sequence.
+
+```bash
+$ cd dtl/examples
+$ scons intdiff3
+$ ./intdiff3
+a:1 2 3 4 5 6 7 3 9 10
+b:1 2 3 4 5 6 7 8 9 10
+c:1 2 3 9 5 6 7 8 9 10
+s:1 2 3 9 5 6 7 3 9 10
+intdiff3 OK
+$
+```
+
+## patch
+
+`patch` is the test program. Supposing that there are two strings is called by A and B,
+`patch` translates A to B with Shortest Edit Script or unified format difference.
+
+```bash
+$ cd dtl/examples
+$ scons patch
+$ ./patch abc abd
+before:abc
+after :abd
+patch successed
+before:abc
+after :abd
+unipatch successed
+$
+```
+
+## fpatch
+
+`fpatch` is the test program. Supposing that there are two files is called by A and B,
+`fpatch` translates A to B with Shortest Edit Script or unified format difference.
+
+```bash
+$ cd dtl/examples
+$ scons fpatch
+$ cat a.txt
+a
+e
+c
+z
+z
+d
+e
+f
+a
+b
+c
+d
+e
+f
+g
+h
+i
+$ cat b.txt
+$ cat b.txt
+a
+d
+e
+c
+f
+e
+a
+b
+c
+d
+e
+f
+g
+h
+i
+$ ./fpatch a.txt b.txt
+fpatch successed
+unipatch successed
+$
+```
+
+# Running tests
+
+`dtl` uses [googletest](https://github.com/google/googletest) and [SCons](http://www.scons.org/) with testing dtl-self.
+
+# Building test programs
+
+If you build test programs for `dtl`, run `scons` in test direcotry.
+
+```bash
+$ scons
+```
+
+# Running test programs
+
+If you run all tests for `dtl`, run 'scons check' in test direcotry. (it is necessary that gtest is compiled)
+
+```bash
+$ scons check
+```
+
+If you run sectional tests, you may exeucte `dtl_test` directly after you run `scons`.
+Following command is the example for testing only Strdifftest.
+
+```bash
+$ ./dtl_test --gtest_filter='Strdifftest.*'
+```
+
+`--gtest-filters` is the function of googletest. googletest has many useful functions for testing software flexibly.
+If you want to know other functions of googletest, run `./dtl_test --help`.
+
+# Old commit histories
+
+Please see [cubicdaiya/dtl-legacy](https://github.com/cubicdaiya/dtl-legacy).
+
+# License
+
+Please read the file [COPYING](https://github.com/cubicdaiya/dtl/blob/master/COPYING).
diff --git a/contrib/libs/dtl/dtl/Diff.hpp b/contrib/libs/dtl/dtl/Diff.hpp
new file mode 100644
index 00000000000..8c9c774f5dc
--- /dev/null
+++ b/contrib/libs/dtl/dtl/Diff.hpp
@@ -0,0 +1,706 @@
+/**
+ dtl -- Diff Template Library
+
+ In short, Diff Template Library is distributed under so called "BSD license",
+
+ Copyright (c) 2015 Tatsuhiko Kubo <[email protected]>
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without modification,
+ are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ * Neither the name of the authors nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+/* If you use this library, you must include dtl.hpp only. */
+
+#ifndef DTL_DIFF_H
+#define DTL_DIFF_H
+
+namespace dtl {
+
+ /**
+ * diff class template
+ * sequence must support random_access_iterator.
+ */
+ template <typename elem, typename sequence = vector< elem >, typename comparator = Compare< elem > >
+ class Diff
+ {
+ private :
+ dtl_typedefs(elem, sequence)
+ sequence A;
+ sequence B;
+ size_t M;
+ size_t N;
+ size_t delta;
+ size_t offset;
+ long long *fp;
+ long long editDistance;
+ Lcs< elem > lcs;
+ Ses< elem > ses;
+ editPath path;
+ editPathCordinates pathCordinates;
+ bool swapped;
+ bool huge;
+ bool trivial;
+ bool editDistanceOnly;
+ uniHunkVec uniHunks;
+ comparator cmp;
+ long long ox;
+ long long oy;
+ public :
+ Diff () {}
+
+ Diff (const sequence& a,
+ const sequence& b) : A(a), B(b), ses(false) {
+ init();
+ }
+
+ Diff (const sequence& a,
+ const sequence& b,
+ bool deletesFirst) : A(a), B(b), ses(deletesFirst) {
+ init();
+ }
+
+ Diff (const sequence& a,
+ const sequence& b,
+ const comparator& comp) : A(a), B(b), ses(false), cmp(comp) {
+ init();
+ }
+
+ Diff (const sequence& a,
+ const sequence& b,
+ bool deleteFirst,
+ const comparator& comp) : A(a), B(b), ses(deleteFirst), cmp(comp) {
+ init();
+ }
+
+ ~Diff() {}
+
+ long long getEditDistance () const {
+ return editDistance;
+ }
+
+ Lcs< elem > getLcs () const {
+ return lcs;
+ }
+
+ elemVec getLcsVec () const {
+ return lcs.getSequence();
+ }
+
+ Ses< elem > getSes () const {
+ return ses;
+ }
+
+ uniHunkVec getUniHunks () const {
+ return uniHunks;
+ }
+
+ /* These should be deprecated */
+ bool isHuge () const {
+ return huge;
+ }
+
+ void onHuge () {
+ this->huge = true;
+ }
+
+ void offHuge () {
+ this->huge = false;
+ }
+
+ bool isUnserious () const {
+ return trivial;
+ }
+
+ void onUnserious () {
+ this->trivial = true;
+ }
+
+ void offUnserious () {
+ this->trivial = false;
+ }
+
+ void onOnlyEditDistance () {
+ this->editDistanceOnly = true;
+ }
+
+ /* These are the replacements for the above */
+ bool hugeEnabled () const {
+ return huge;
+ }
+
+ void enableHuge () {
+ this->huge = true;
+ }
+
+ void disableHuge () {
+ this->huge = false;
+ }
+
+ bool trivialEnabled () const {
+ return trivial;
+ }
+
+ void enableTrivial () const {
+ this->trivial = true;
+ }
+
+ void disableTrivial () {
+ this->trivial = false;
+ }
+
+ void editDistanceOnlyEnabled () {
+ this->editDistanceOnly = true;
+ }
+
+ /**
+ * patching with Unified Format Hunks
+ */
+ sequence uniPatch (const sequence& seq) {
+ elemList seqLst(seq.begin(), seq.end());
+ sesElemVec shunk;
+ sesElemVec_iter vsesIt;
+ elemList_iter lstIt = seqLst.begin();
+ long long inc_dec_total = 0;
+ long long gap = 1;
+ for (uniHunkVec_iter it=uniHunks.begin();it!=uniHunks.end();++it) {
+ joinSesVec(shunk, it->common[0]);
+ joinSesVec(shunk, it->change);
+ joinSesVec(shunk, it->common[1]);
+ it->a += inc_dec_total;
+ inc_dec_total += it->inc_dec_count;
+ for (long long i=0;i<it->a - gap;++i) {
+ ++lstIt;
+ }
+ gap = it->a + it->b + it->inc_dec_count;
+ vsesIt = shunk.begin();
+ while (vsesIt!=shunk.end()) {
+ switch (vsesIt->second.type) {
+ case SES_ADD :
+ seqLst.insert(lstIt, vsesIt->first);
+ break;
+ case SES_DELETE :
+ if (lstIt != seqLst.end()) {
+ lstIt = seqLst.erase(lstIt);
+ }
+ break;
+ case SES_COMMON :
+ if (lstIt != seqLst.end()) {
+ ++lstIt;
+ }
+ break;
+ default :
+ // no fall-through
+ break;
+ }
+ ++vsesIt;
+ }
+ shunk.clear();
+ }
+
+ sequence patchedSeq(seqLst.begin(), seqLst.end());
+ return patchedSeq;
+ }
+
+ /**
+ * patching with Shortest Edit Script (SES)
+ */
+ sequence patch (const sequence& seq) const {
+ sesElemVec sesSeq = ses.getSequence();
+ elemList seqLst(seq.begin(), seq.end());
+ elemList_iter lstIt = seqLst.begin();
+ for (sesElemVec_iter sesIt=sesSeq.begin();sesIt!=sesSeq.end();++sesIt) {
+ switch (sesIt->second.type) {
+ case SES_ADD :
+ seqLst.insert(lstIt, sesIt->first);
+ break;
+ case SES_DELETE :
+ lstIt = seqLst.erase(lstIt);
+ break;
+ case SES_COMMON :
+ ++lstIt;
+ break;
+ default :
+ // no through
+ break;
+ }
+ }
+ sequence patchedSeq(seqLst.begin(), seqLst.end());
+ return patchedSeq;
+ }
+
+ /**
+ * compose Longest Common Subsequence and Shortest Edit Script.
+ * The algorithm implemented here is based on "An O(NP) Sequence Comparison Algorithm"
+ * described by Sun Wu, Udi Manber and Gene Myers
+ */
+ void compose() {
+
+ 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);
+ path = editPath(M + N + 3);
+ fill(path.begin(), path.end(), -1);
+ ONP:
+ do {
+ ++p;
+ for (long long k=-p;k<=static_cast<long long>(delta)-1;++k) {
+ fp[k+offset] = snake(k, fp[k-1+offset]+1, fp[k+1+offset]);
+ }
+ for (long long k=static_cast<long long>(delta)+p;k>=static_cast<long long>(delta)+1;--k) {
+ fp[k+offset] = snake(k, fp[k-1+offset]+1, fp[k+1+offset]);
+ }
+ fp[delta+offset] = snake(static_cast<long long>(delta), fp[delta-1+offset]+1, fp[delta+1+offset]);
+ } while (fp[delta+offset] != static_cast<long long>(N) && pathCordinates.size() < MAX_CORDINATES_SIZE);
+
+ editDistance += static_cast<long long>(delta) + 2 * p;
+ long long r = path[delta+offset];
+ P cordinate;
+ editPathCordinates epc(0);
+
+ // recording edit distance only
+ if (editDistanceOnly) {
+ delete[] this->fp;
+ return;
+ }
+
+ while(r != -1) {
+ cordinate.x = pathCordinates[(size_t)r].x;
+ cordinate.y = pathCordinates[(size_t)r].y;
+ epc.push_back(cordinate);
+ r = pathCordinates[(size_t)r].k;
+ }
+
+ // record Longest Common Subsequence & Shortest Edit Script
+ if (!recordSequence(epc)) {
+ pathCordinates.resize(0);
+ epc.resize(0);
+ p = -1;
+ goto ONP;
+ }
+ delete[] this->fp;
+ }
+
+ /**
+ * print difference between A and B as an SES
+ */
+ template < typename stream >
+ void printSES (stream& out) const {
+ sesElemVec ses_v = ses.getSequence();
+ for_each(ses_v.begin(), ses_v.end(), ChangePrinter< sesElem, stream >(out));
+ }
+
+ void printSES (ostream& out = cout) const {
+ printSES< ostream >(out);
+ }
+
+ /**
+ * print differences given an SES
+ */
+ template < typename stream >
+ static void printSES (const Ses< elem >& s, stream& out) {
+ sesElemVec ses_v = s.getSequence();
+ for_each(ses_v.begin(), ses_v.end(), ChangePrinter< sesElem, stream >(out));
+ }
+
+ static void printSES (const Ses< elem >& s, ostream& out = cout) {
+ printSES< ostream >(s, out);
+ }
+
+ /**
+ * print difference between A and B as an SES with custom printer
+ */
+ template < typename stream, template < typename SEET, typename STRT > class PT >
+ void printSES (stream& out) const {
+ sesElemVec ses_v = ses.getSequence ();
+ for_each (ses_v.begin (), ses_v.end(), PT < sesElem, stream > (out));
+ }
+
+ /**
+ * store difference between A and B as an SES with custom storage
+ */
+ template < typename storedData, template < typename SEET, typename STRT > class ST >
+ void storeSES(storedData& sd) const {
+ sesElemVec ses_v = ses.getSequence();
+ for_each(ses_v.begin(), ses_v.end(), ST < sesElem, storedData >(sd));
+ }
+
+ /**
+ * print difference between A and B in the Unified Format
+ */
+ template < typename stream >
+ void printUnifiedFormat (stream& out) const {
+ for_each(uniHunks.begin(), uniHunks.end(), UniHunkPrinter< sesElem, stream >(out));
+ }
+
+ void printUnifiedFormat (ostream& out = cout) const {
+ printUnifiedFormat< ostream >(out);
+ }
+
+ /**
+ * print unified format difference with given unified format hunks
+ */
+ template < typename stream >
+ static void printUnifiedFormat (const uniHunkVec& hunks, stream& out) {
+ for_each(hunks.begin(), hunks.end(), UniHunkPrinter< sesElem >(out));
+ }
+
+ static void printUnifiedFormat (const uniHunkVec& hunks, ostream& out = cout) {
+ printUnifiedFormat< ostream >(hunks, out);
+ }
+
+ /**
+ * compose Unified Format Hunks from Shortest Edit Script
+ */
+ void composeUnifiedHunks () {
+ sesElemVec common[2];
+ sesElemVec change;
+ sesElemVec ses_v = ses.getSequence();
+ long long l_cnt = 1;
+ long long length = distance(ses_v.begin(), ses_v.end());
+ long long middle = 0;
+ bool isMiddle, isAfter;
+ elemInfo einfo;
+ long long a, b, c, d; // @@ -a,b +c,d @@
+ long long inc_dec_count = 0;
+ uniHunk< sesElem > hunk;
+ sesElemVec adds;
+ sesElemVec deletes;
+
+ isMiddle = isAfter = false;
+ a = b = c = d = 0;
+
+ for (sesElemVec_iter it=ses_v.begin();it!=ses_v.end();++it, ++l_cnt) {
+ einfo = it->second;
+ switch (einfo.type) {
+ case SES_ADD :
+ middle = 0;
+ ++inc_dec_count;
+ adds.push_back(*it);
+ if (!isMiddle) isMiddle = true;
+ if (isMiddle) ++d;
+ if (l_cnt >= length) {
+ joinSesVec(change, deletes);
+ joinSesVec(change, adds);
+ isAfter = true;
+ }
+ break;
+ case SES_DELETE :
+ middle = 0;
+ --inc_dec_count;
+ deletes.push_back(*it);
+ if (!isMiddle) isMiddle = true;
+ if (isMiddle) ++b;
+ if (l_cnt >= length) {
+ joinSesVec(change, deletes);
+ joinSesVec(change, adds);
+ isAfter = true;
+ }
+ break;
+ case SES_COMMON :
+ ++b;++d;
+ if (common[1].empty() && adds.empty() && deletes.empty() && change.empty()) {
+ if (static_cast<long long>(common[0].size()) < DTL_CONTEXT_SIZE) {
+ if (a == 0 && c == 0) {
+ if (!wasSwapped()) {
+ a = einfo.beforeIdx;
+ c = einfo.afterIdx;
+ } else {
+ a = einfo.afterIdx;
+ c = einfo.beforeIdx;
+ }
+ }
+ common[0].push_back(*it);
+ } else {
+ rotate(common[0].begin(), common[0].begin() + 1, common[0].end());
+ common[0].pop_back();
+ common[0].push_back(*it);
+ ++a;++c;
+ --b;--d;
+ }
+ }
+ if (isMiddle && !isAfter) {
+ ++middle;
+ joinSesVec(change, deletes);
+ joinSesVec(change, adds);
+ change.push_back(*it);
+ if (middle >= DTL_SEPARATE_SIZE || l_cnt >= length) {
+ isAfter = true;
+ }
+ adds.clear();
+ deletes.clear();
+ }
+ break;
+ default :
+ // no through
+ break;
+ }
+ // compose unified format hunk
+ if (isAfter && !change.empty()) {
+ sesElemVec_iter cit = it;
+ long long cnt = 0;
+ for (long long i=0;i<DTL_SEPARATE_SIZE && (cit != ses_v.end());++i, ++cit) {
+ if (cit->second.type == SES_COMMON) {
+ ++cnt;
+ }
+ }
+ if (cnt < DTL_SEPARATE_SIZE && l_cnt < length) {
+ middle = 0;
+ isAfter = false;
+ continue;
+ }
+ if (static_cast<long long>(common[0].size()) >= DTL_SEPARATE_SIZE) {
+ long long c0size = static_cast<long long>(common[0].size());
+ rotate(common[0].begin(),
+ common[0].begin() + (size_t)c0size - DTL_SEPARATE_SIZE,
+ common[0].end());
+ for (long long i=0;i<c0size - DTL_SEPARATE_SIZE;++i) {
+ common[0].pop_back();
+ }
+ a += c0size - DTL_SEPARATE_SIZE;
+ c += c0size - DTL_SEPARATE_SIZE;
+ }
+ if (a == 0) ++a;
+ if (c == 0) ++c;
+ if (wasSwapped()) swap(a, c);
+ hunk.a = a;
+ hunk.b = b;
+ hunk.c = c;
+ hunk.d = d;
+ hunk.common[0] = common[0];
+ hunk.change = change;
+ hunk.common[1] = common[1];
+ hunk.inc_dec_count = inc_dec_count;
+ uniHunks.push_back(hunk);
+ isMiddle = false;
+ isAfter = false;
+ common[0].clear();
+ common[1].clear();
+ adds.clear();
+ deletes.clear();
+ change.clear();
+ a = b = c = d = middle = inc_dec_count = 0;
+ }
+ }
+ }
+
+ /**
+ * compose ses from stream
+ */
+ template <typename stream>
+ static Ses< elem > composeSesFromStream (stream& st)
+ {
+ elem line;
+ Ses< elem > ret;
+ long long x_idx, y_idx;
+ x_idx = y_idx = 1;
+ while (getline(st, line)) {
+ elem mark(line.begin(), line.begin() + 1);
+ elem e(line.begin() + 1, line.end());
+ if (mark == SES_MARK_DELETE) {
+ ret.addSequence(e, x_idx, 0, SES_DELETE);
+ ++x_idx;
+ } else if (mark == SES_MARK_ADD) {
+ ret.addSequence(e, y_idx, 0, SES_ADD);
+ ++y_idx;
+ } else if (mark == SES_MARK_COMMON) {
+ ret.addSequence(e, x_idx, y_idx, SES_COMMON);
+ ++x_idx;
+ ++y_idx;
+ }
+ }
+ return ret;
+ }
+
+ private :
+ /**
+ * initialize
+ */
+ void init () {
+ M = distance(A.begin(), A.end());
+ N = distance(B.begin(), B.end());
+ if (M < N) {
+ swapped = false;
+ } else {
+ swap(A, B);
+ swap(M, N);
+ swapped = true;
+ }
+ editDistance = 0;
+ delta = N - M;
+ offset = M + 1;
+ huge = false;
+ trivial = false;
+ editDistanceOnly = false;
+ fp = NULL;
+ }
+
+ /**
+ * search shortest path and record the path
+ */
+ long long snake(const long long& k, const long long& above, const long long& below) {
+ long long r = above > below ? path[(size_t)k-1+offset] : path[(size_t)k+1+offset];
+ long long y = max(above, below);
+ long long x = y - k;
+ while ((size_t)x < M && (size_t)y < N && (swapped ? cmp.impl(B[(size_t)y], A[(size_t)x]) : cmp.impl(A[(size_t)x], B[(size_t)y]))) {
+ ++x;++y;
+ }
+
+ path[(size_t)k+offset] = static_cast<long long>(pathCordinates.size());
+ if (!editDistanceOnly) {
+ P p;
+ p.x = x;p.y = y;p.k = r;
+ pathCordinates.push_back(p);
+ }
+ return y;
+ }
+
+ /**
+ * record SES and LCS
+ */
+ bool recordSequence (const editPathCordinates& v) {
+ sequence_const_iter x(A.begin());
+ sequence_const_iter y(B.begin());
+ long long x_idx, y_idx; // line number for Unified Format
+ long long px_idx, py_idx; // cordinates
+ bool complete = false;
+ x_idx = y_idx = 1;
+ px_idx = py_idx = 0;
+ for (size_t i=v.size()-1;!complete;--i) {
+ 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 + oy, SES_ADD);
+ } else {
+ 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 + ox, 0, SES_DELETE);
+ } else {
+ 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 + ox, y_idx + oy, SES_COMMON);
+ } else {
+ lcs.addSequence(*y);
+ ses.addSequence(*y, y_idx + oy, x_idx + ox, SES_COMMON);
+ }
+ ++x;
+ ++y;
+ ++x_idx;
+ ++y_idx;
+ ++px_idx;
+ ++py_idx;
+ }
+ }
+ if (i == 0) complete = true;
+ }
+
+ if (x_idx > static_cast<long long>(M) && y_idx > static_cast<long long>(N)) {
+ // all recording succeeded
+ } else {
+ // trivial difference
+ if (trivialEnabled()) {
+ if (!wasSwapped()) {
+ recordOddSequence(x_idx, M, x, SES_DELETE);
+ recordOddSequence(y_idx, N, y, SES_ADD);
+ } else {
+ recordOddSequence(x_idx, M, x, SES_ADD);
+ recordOddSequence(y_idx, N, y, SES_DELETE);
+ }
+ return true;
+ }
+
+ // nontrivial difference
+ sequence A_(A.begin() + (size_t)x_idx - 1, A.end());
+ sequence B_(B.begin() + (size_t)y_idx - 1, B.end());
+ A = A_;
+ B = B_;
+ M = distance(A.begin(), A.end());
+ N = distance(B.begin(), B.end());
+ delta = N - M;
+ offset = M + 1;
+ delete[] fp;
+ 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;
+ }
+
+ /**
+ * record odd sequence in SES
+ */
+ void inline recordOddSequence (long long idx, long long length, sequence_const_iter it, const edit_t et) {
+ while(idx < length){
+ ses.addSequence(*it, idx, 0, et);
+ ++it;
+ ++idx;
+ ++editDistance;
+ }
+ ses.addSequence(*it, idx, 0, et);
+ ++editDistance;
+ }
+
+ /**
+ * join SES vectors
+ */
+ void inline joinSesVec (sesElemVec& s1, sesElemVec& s2) const {
+ if (!s2.empty()) {
+ for (sesElemVec_iter vit=s2.begin();vit!=s2.end();++vit) {
+ s1.push_back(*vit);
+ }
+ }
+ }
+
+ /**
+ * check if the sequences have been swapped
+ */
+ bool inline wasSwapped () const {
+ return swapped;
+ }
+
+ };
+}
+
+#endif // DTL_DIFF_H
diff --git a/contrib/libs/dtl/dtl/Diff3.hpp b/contrib/libs/dtl/dtl/Diff3.hpp
new file mode 100644
index 00000000000..854864efd46
--- /dev/null
+++ b/contrib/libs/dtl/dtl/Diff3.hpp
@@ -0,0 +1,245 @@
+/**
+ dtl -- Diff Template Library
+
+ In short, Diff Template Library is distributed under so called "BSD license",
+
+ Copyright (c) 2015 Tatsuhiko Kubo <[email protected]>
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without modification,
+ are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ * Neither the name of the authors nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+/* If you use this library, you must include dtl.hpp only. */
+
+#ifndef DTL_DIFF3_H
+#define DTL_DIFF3_H
+
+namespace dtl {
+
+ /**
+ * diff3 class template
+ * sequence must support random_access_iterator.
+ */
+ template <typename elem, typename sequence = vector< elem >, typename comparator = Compare< elem > >
+ class Diff3
+ {
+ private:
+ dtl_typedefs(elem, sequence)
+ sequence A;
+ sequence B;
+ sequence C;
+ sequence S;
+ Diff< elem, sequence, comparator > diff_ba;
+ Diff< elem, sequence, comparator > diff_bc;
+ bool conflict;
+ elem csepabegin;
+ elem csepa;
+ elem csepaend;
+ public :
+ Diff3 () {}
+ Diff3 (const sequence& a,
+ const sequence& b,
+ const sequence& c) : A(a), B(b), C(c),
+ diff_ba(b, a), diff_bc(b, c),
+ conflict(false) {}
+
+ ~Diff3 () {}
+
+ bool isConflict () const {
+ return conflict;
+ }
+
+ sequence getMergedSequence () const {
+ return S;
+ }
+
+ /**
+ * merge changes B and C into A
+ */
+ bool merge () {
+ if (diff_ba.getEditDistance() == 0) { // A == B
+ if (diff_bc.getEditDistance() == 0) { // A == B == C
+ S = B;
+ return true;
+ }
+ S = C;
+ return true;
+ } else { // A != B
+ if (diff_bc.getEditDistance() == 0) { // A != B == C
+ S = A;
+ return true;
+ } else { // A != B != C
+ S = merge_();
+ if (isConflict()) { // conflict occured
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ /**
+ * compose differences
+ */
+ void compose () {
+ diff_ba.compose();
+ diff_bc.compose();
+ }
+
+ private :
+ /**
+ * merge implementation
+ */
+ sequence merge_ () {
+ elemVec seq;
+ Ses< elem > ses_ba = diff_ba.getSes();
+ Ses< elem > ses_bc = diff_bc.getSes();
+ sesElemVec ses_ba_v = ses_ba.getSequence();
+ sesElemVec ses_bc_v = ses_bc.getSequence();
+ sesElemVec_iter ba_it = ses_ba_v.begin();
+ sesElemVec_iter bc_it = ses_bc_v.begin();
+ sesElemVec_iter ba_end = ses_ba_v.end();
+ sesElemVec_iter bc_end = ses_bc_v.end();
+
+ while (!isEnd(ba_end, ba_it) || !isEnd(bc_end, bc_it)) {
+ while (true) {
+ if (!isEnd(ba_end, ba_it) &&
+ !isEnd(bc_end, bc_it) &&
+ ba_it->first == bc_it->first &&
+ ba_it->second.type == SES_COMMON &&
+ bc_it->second.type == SES_COMMON) {
+ // do nothing
+ } else {
+ break;
+ }
+ if (!isEnd(ba_end, ba_it)) seq.push_back(ba_it->first);
+ else if (!isEnd(bc_end, bc_it)) seq.push_back(bc_it->first);
+ forwardUntilEnd(ba_end, ba_it);
+ forwardUntilEnd(bc_end, bc_it);
+ }
+ if (isEnd(ba_end, ba_it) || isEnd(bc_end, bc_it)) break;
+ if ( ba_it->second.type == SES_COMMON
+ && bc_it->second.type == SES_DELETE) {
+ forwardUntilEnd(ba_end, ba_it);
+ forwardUntilEnd(bc_end, bc_it);
+ } else if (ba_it->second.type == SES_COMMON &&
+ bc_it->second.type == SES_ADD) {
+ seq.push_back(bc_it->first);
+ forwardUntilEnd(bc_end, bc_it);
+ } else if (ba_it->second.type == SES_DELETE &&
+ bc_it->second.type == SES_COMMON) {
+ forwardUntilEnd(ba_end, ba_it);
+ forwardUntilEnd(bc_end, bc_it);
+ } else if (ba_it->second.type == SES_DELETE &&
+ bc_it->second.type == SES_DELETE) {
+ if (ba_it->first == bc_it->first) {
+ forwardUntilEnd(ba_end, ba_it);
+ forwardUntilEnd(bc_end, bc_it);
+ } else {
+ // conflict
+ conflict = true;
+ return B;
+ }
+ } else if (ba_it->second.type == SES_DELETE &&
+ bc_it->second.type == SES_ADD) {
+ // conflict
+ conflict = true;
+ return B;
+ } else if (ba_it->second.type == SES_ADD &&
+ bc_it->second.type == SES_COMMON) {
+ seq.push_back(ba_it->first);
+ forwardUntilEnd(ba_end, ba_it);
+ } else if (ba_it->second.type == SES_ADD &&
+ bc_it->second.type == SES_DELETE) {
+ // conflict
+ conflict = true;
+ return B;
+ } else if (ba_it->second.type == SES_ADD &&
+ bc_it->second.type == SES_ADD) {
+ if (ba_it->first == bc_it->first) {
+ seq.push_back(ba_it->first);
+ forwardUntilEnd(ba_end, ba_it);
+ forwardUntilEnd(bc_end, bc_it);
+ } else {
+ // conflict
+ conflict = true;
+ return B;
+ }
+ }
+ }
+
+ if (isEnd(ba_end, ba_it)) {
+ addDecentSequence(bc_end, bc_it, seq);
+ } else if (isEnd(bc_end, bc_it)) {
+ addDecentSequence(ba_end, ba_it, seq);
+ }
+
+ sequence mergedSeq(seq.begin(), seq.end());
+ return mergedSeq;
+ }
+
+ /**
+ * join elem vectors
+ */
+ void inline joinElemVec (elemVec& s1, elemVec& s2) const {
+ if (!s2.empty()) {
+ for (elemVec_iter vit=s2.begin();vit!=s2.end();++vit) {
+ s1.push_back(*vit);
+ }
+ }
+ }
+
+ /**
+ * check if sequence is at end
+ */
+ template <typename T_iter>
+ bool inline isEnd (const T_iter& end, const T_iter& it) const {
+ return it == end ? true : false;
+ }
+
+ /**
+ * increment iterator until iterator is at end
+ */
+ template <typename T_iter>
+ void inline forwardUntilEnd (const T_iter& end, T_iter& it) const {
+ if (!isEnd(end, it)) ++it;
+ }
+
+ /**
+ * add elements whose SES's type is ADD
+ */
+ void inline addDecentSequence (const sesElemVec_iter& end, sesElemVec_iter& it, elemVec& seq) const {
+ while (!isEnd(end, it)) {
+ if (it->second.type == SES_ADD) seq.push_back(it->first);
+ ++it;
+ }
+ }
+
+ };
+}
+
+#endif // DTL_DIFF3_H
diff --git a/contrib/libs/dtl/dtl/Lcs.hpp b/contrib/libs/dtl/dtl/Lcs.hpp
new file mode 100644
index 00000000000..e47c2381a3f
--- /dev/null
+++ b/contrib/libs/dtl/dtl/Lcs.hpp
@@ -0,0 +1,55 @@
+/**
+ dtl -- Diff Template Library
+
+ In short, Diff Template Library is distributed under so called "BSD license",
+
+ Copyright (c) 2015 Tatsuhiko Kubo <[email protected]>
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without modification,
+ are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ * Neither the name of the authors nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+/* If you use this library, you must include dtl.hpp only. */
+
+#ifndef DTL_LCS_H
+#define DTL_LCS_H
+
+namespace dtl {
+
+ /**
+ * Longest Common Subsequence template class
+ */
+ template <typename elem>
+ class Lcs : public Sequence< elem >
+ {
+ public :
+ Lcs () {}
+ ~Lcs () {}
+ };
+}
+
+#endif // DTL_LCS_H
diff --git a/contrib/libs/dtl/dtl/Sequence.hpp b/contrib/libs/dtl/dtl/Sequence.hpp
new file mode 100644
index 00000000000..eeab0ed77e0
--- /dev/null
+++ b/contrib/libs/dtl/dtl/Sequence.hpp
@@ -0,0 +1,65 @@
+/**
+ dtl -- Diff Template Library
+
+ In short, Diff Template Library is distributed under so called "BSD license",
+
+ Copyright (c) 2015 Tatsuhiko Kubo <[email protected]>
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without modification,
+ are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ * Neither the name of the authors nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+/* If you use this library, you must include dtl.hpp only. */
+
+#ifndef DTL_SEQUENCE_H
+#define DTL_SEQUENCE_H
+
+namespace dtl {
+
+ /**
+ * sequence class template
+ */
+ template <typename elem>
+ class Sequence
+ {
+ public :
+ typedef vector< elem > elemVec;
+ Sequence () {}
+ virtual ~Sequence () {}
+
+ elemVec getSequence () const {
+ return sequence;
+ }
+ void addSequence (elem e) {
+ sequence.push_back(e);
+ }
+ protected :
+ elemVec sequence;
+ };
+}
+
+#endif // DTL_SEQUENCE_H
diff --git a/contrib/libs/dtl/dtl/Ses.hpp b/contrib/libs/dtl/dtl/Ses.hpp
new file mode 100644
index 00000000000..281144e0617
--- /dev/null
+++ b/contrib/libs/dtl/dtl/Ses.hpp
@@ -0,0 +1,132 @@
+/**
+ dtl -- Diff Template Library
+
+ In short, Diff Template Library is distributed under so called "BSD license",
+
+ Copyright (c) 2015 Tatsuhiko Kubo <[email protected]>
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without modification,
+ are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ * Neither the name of the authors nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+/* If you use this library, you must include dtl.hpp only. */
+
+#ifndef DTL_SES_H
+#define DTL_SES_H
+
+namespace dtl {
+
+ /**
+ * Shortest Edit Script template class
+ */
+ template <typename elem>
+ class Ses : public Sequence< elem >
+ {
+ private :
+ typedef pair< elem, elemInfo > sesElem;
+ typedef vector< sesElem > sesElemVec;
+ public :
+
+ Ses () : onlyAdd(true), onlyDelete(true), onlyCopy(true), deletesFirst(false) {
+ nextDeleteIdx = 0;
+ }
+ Ses (bool moveDel) : onlyAdd(true), onlyDelete(true), onlyCopy(true), deletesFirst(moveDel) {
+ nextDeleteIdx = 0;
+ }
+ ~Ses () {}
+
+ bool isOnlyAdd () const {
+ return onlyAdd;
+ }
+
+ bool isOnlyDelete () const {
+ return onlyDelete;
+ }
+
+ bool isOnlyCopy () const {
+ return onlyCopy;
+ }
+
+ bool isOnlyOneOperation () const {
+ return isOnlyAdd() || isOnlyDelete() || isOnlyCopy();
+ }
+
+ bool isChange () const {
+ return !onlyCopy;
+ }
+
+ using Sequence< elem >::addSequence;
+ void addSequence (elem e, long long beforeIdx, long long afterIdx, const edit_t type) {
+ elemInfo info;
+ info.beforeIdx = beforeIdx;
+ info.afterIdx = afterIdx;
+ info.type = type;
+ sesElem pe(e, info);
+ if (!deletesFirst) {
+ sequence.push_back(pe);
+ }
+ switch (type) {
+ case SES_DELETE:
+ onlyCopy = false;
+ onlyAdd = false;
+ if (deletesFirst) {
+ sequence.insert(sequence.begin() + nextDeleteIdx, pe);
+ nextDeleteIdx++;
+ }
+ break;
+ case SES_COMMON:
+ onlyAdd = false;
+ onlyDelete = false;
+ if (deletesFirst) {
+ sequence.push_back(pe);
+ nextDeleteIdx = sequence.size();
+ }
+ break;
+ case SES_ADD:
+ onlyDelete = false;
+ onlyCopy = false;
+ if (deletesFirst) {
+ sequence.push_back(pe);
+ }
+ break;
+ }
+ }
+
+ sesElemVec getSequence () const {
+ return sequence;
+ }
+ private :
+ sesElemVec sequence;
+ bool onlyAdd;
+ bool onlyDelete;
+ bool onlyCopy;
+ bool deletesFirst;
+ size_t nextDeleteIdx;
+ };
+}
+
+#endif // DTL_SES_H
diff --git a/contrib/libs/dtl/dtl/dtl.hpp b/contrib/libs/dtl/dtl/dtl.hpp
new file mode 100644
index 00000000000..b6231ba7990
--- /dev/null
+++ b/contrib/libs/dtl/dtl/dtl.hpp
@@ -0,0 +1,47 @@
+/**
+ dtl -- Diff Template Library
+
+ In short, Diff Template Library is distributed under so called "BSD license",
+
+ Copyright (c) 2015 Tatsuhiko Kubo <[email protected]>
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without modification,
+ are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ * Neither the name of the authors nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef DTL_H
+#define DTL_H
+
+#include "variables.hpp"
+#include "functors.hpp"
+#include "Sequence.hpp"
+#include "Lcs.hpp"
+#include "Ses.hpp"
+#include "Diff.hpp"
+#include "Diff3.hpp"
+
+#endif // DTL_H
diff --git a/contrib/libs/dtl/dtl/functors.hpp b/contrib/libs/dtl/dtl/functors.hpp
new file mode 100644
index 00000000000..86d8709df72
--- /dev/null
+++ b/contrib/libs/dtl/dtl/functors.hpp
@@ -0,0 +1,151 @@
+/**
+ dtl -- Diff Template Library
+
+ In short, Diff Template Library is distributed under so called "BSD license",
+
+ Copyright (c) 2015 Tatsuhiko Kubo <[email protected]>
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without modification,
+ are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ * Neither the name of the authors nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+/* If you use this library, you must include dtl.hpp only. */
+
+#ifndef DTL_FUNCTORS_H
+#define DTL_FUNCTORS_H
+
+namespace dtl {
+
+ /**
+ * printer class template
+ */
+ template <typename sesElem, typename stream = ostream >
+ class Printer
+ {
+ public :
+ Printer () : out_(cout) {}
+ Printer (stream& out) : out_(out) {}
+ virtual ~Printer () {}
+ virtual void operator() (const sesElem& se) const = 0;
+ protected :
+ stream& out_;
+ };
+
+ /**
+ * common element printer class template
+ */
+ template <typename sesElem, typename stream = ostream >
+ class CommonPrinter : public Printer < sesElem, stream >
+ {
+ public :
+ CommonPrinter () : Printer < sesElem, stream > () {}
+ CommonPrinter (stream& out) : Printer < sesElem, stream > (out) {}
+ ~CommonPrinter () {}
+ void operator() (const sesElem& se) const {
+ this->out_ << SES_MARK_COMMON << se.first << endl;
+ }
+ };
+
+ /**
+ * ses element printer class template
+ */
+ template <typename sesElem, typename stream = ostream >
+ class ChangePrinter : public Printer < sesElem, stream >
+ {
+ public :
+ ChangePrinter () : Printer < sesElem, stream > () {}
+ ChangePrinter (stream& out) : Printer < sesElem, stream > (out) {}
+ ~ChangePrinter () {}
+ void operator() (const sesElem& se) const {
+ switch (se.second.type) {
+ case SES_ADD:
+ this->out_ << SES_MARK_ADD << se.first << endl;
+ break;
+ case SES_DELETE:
+ this->out_ << SES_MARK_DELETE << se.first << endl;
+ break;
+ case SES_COMMON:
+ this->out_ << SES_MARK_COMMON << se.first << endl;
+ break;
+ }
+ }
+ };
+
+ /**
+ * unified format element printer class template
+ */
+ template <typename sesElem, typename stream = ostream >
+ class UniHunkPrinter
+ {
+ public :
+ UniHunkPrinter () : out_(cout) {}
+ UniHunkPrinter (stream& out) : out_(out) {}
+ ~UniHunkPrinter () {}
+ void operator() (const uniHunk< sesElem >& hunk) const {
+ out_ << "@@"
+ << " -" << hunk.a << "," << hunk.b
+ << " +" << hunk.c << "," << hunk.d
+ << " @@" << endl;
+
+ for_each(hunk.common[0].begin(), hunk.common[0].end(), CommonPrinter< sesElem, stream >(out_));
+ for_each(hunk.change.begin(), hunk.change.end(), ChangePrinter< sesElem, stream >(out_));
+ for_each(hunk.common[1].begin(), hunk.common[1].end(), CommonPrinter< sesElem, stream >(out_));
+ }
+ private :
+ stream& out_;
+ };
+
+ /**
+ * storage class template
+ */
+ template <typename sesElem, typename storedData >
+ class Storage
+ {
+ public:
+ Storage(storedData& sd) : storedData_(sd) {}
+ virtual ~Storage() {}
+ virtual void operator() (const sesElem& se) const = 0;
+ protected:
+ storedData& storedData_;
+ };
+
+ /**
+ * compare class template
+ */
+ template <typename elem>
+ class Compare
+ {
+ public :
+ Compare () {}
+ virtual ~Compare () {}
+ virtual inline bool impl (const elem& e1, const elem& e2) const {
+ return e1 == e2;
+ }
+ };
+}
+
+#endif // DTL_FUNCTORS_H
diff --git a/contrib/libs/dtl/dtl/variables.hpp b/contrib/libs/dtl/dtl/variables.hpp
new file mode 100644
index 00000000000..6720ec86634
--- /dev/null
+++ b/contrib/libs/dtl/dtl/variables.hpp
@@ -0,0 +1,142 @@
+/**
+ dtl -- Diff Template Library
+
+ In short, Diff Template Library is distributed under so called "BSD license",
+
+ Copyright (c) 2015 Tatsuhiko Kubo <[email protected]>
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without modification,
+ are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ * Neither the name of the authors nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+/* If you use this library, you must include dtl.hpp only. */
+
+#ifndef DTL_VARIABLES_H
+#define DTL_VARIABLES_H
+
+#include <vector>
+#include <list>
+#include <string>
+#include <algorithm>
+#include <iostream>
+
+namespace dtl {
+
+ using std::vector;
+ using std::string;
+ using std::pair;
+ using std::ostream;
+ using std::list;
+ using std::for_each;
+ using std::distance;
+ using std::fill;
+ using std::cout;
+ using std::endl;
+ using std::rotate;
+ using std::swap;
+ using std::max;
+
+ /**
+ * version string
+ */
+ const string version = "1.20";
+
+ /**
+ * type of edit for SES
+ */
+ typedef int edit_t;
+ const edit_t SES_DELETE = -1;
+ const edit_t SES_COMMON = 0;
+ const edit_t SES_ADD = 1;
+
+ /**
+ * mark of SES
+ */
+#define SES_MARK_DELETE "-"
+#define SES_MARK_COMMON " "
+#define SES_MARK_ADD "+"
+
+ /**
+ * info for Unified Format
+ */
+ typedef struct eleminfo {
+ long long beforeIdx; // index of prev sequence
+ long long afterIdx; // index of after sequence
+ edit_t type; // type of edit(Add, Delete, Common)
+ bool operator==(const eleminfo& other) const{
+ return (this->beforeIdx == other.beforeIdx && this->afterIdx == other.afterIdx && this->type == other.type);
+ }
+ } elemInfo;
+
+ const long long DTL_SEPARATE_SIZE = 3;
+ const long long DTL_CONTEXT_SIZE = 3;
+
+ /**
+ * cordinate for registering route
+ */
+ typedef struct Point {
+ long long x; // x cordinate
+ long long y; // y cordinate
+ long long k; // vertex
+ } P;
+
+ /**
+ * limit of cordinate size
+ */
+ const unsigned long long MAX_CORDINATES_SIZE = 2000000;
+
+ typedef vector< long long > editPath;
+ typedef vector< P > editPathCordinates;
+
+ /**
+ * Structure of Unified Format Hunk
+ */
+ template <typename sesElem>
+ struct uniHunk {
+ long long a, b, c, d; // @@ -a,b +c,d @@
+ vector< sesElem > common[2]; // anteroposterior commons on changes
+ vector< sesElem > change; // changes
+ long long inc_dec_count; // count of increace and decrease
+ };
+
+#define dtl_typedefs(elem, sequence) \
+ typedef pair< elem, elemInfo > sesElem; \
+ typedef vector< sesElem > sesElemVec; \
+ typedef vector< uniHunk< sesElem > > uniHunkVec; \
+ typedef list< elem > elemList; \
+ typedef vector< elem > elemVec; \
+ typedef typename uniHunkVec::iterator uniHunkVec_iter; \
+ typedef typename sesElemVec::iterator sesElemVec_iter; \
+ typedef typename elemList::iterator elemList_iter; \
+ typedef typename sequence::iterator sequence_iter; \
+ typedef typename sequence::const_iterator sequence_const_iter; \
+ typedef typename elemVec::iterator elemVec_iter;
+
+
+}
+
+#endif // DTL_VARIABLES_H
diff --git a/contrib/libs/dtl/ya.make b/contrib/libs/dtl/ya.make
new file mode 100644
index 00000000000..de589603ba7
--- /dev/null
+++ b/contrib/libs/dtl/ya.make
@@ -0,0 +1,18 @@
+# Generated by devtools/yamaker from nixpkgs 22.11.
+
+LIBRARY()
+
+LICENSE(
+ BSD-3-Clause AND
+ LicenseRef-scancode-unknown-license-reference
+)
+
+LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
+
+OWNER(g:cpp-contrib)
+
+VERSION(1.20)
+
+ORIGINAL_SOURCE(https://github.com/cubicdaiya/dtl/archive/v1.20.tar.gz)
+
+END()