Code Monkey home page Code Monkey logo

dtl's People

Contributors

cubicdaiya avatar jamesjer avatar wlawski avatar zaychukaleksey avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dtl's Issues

Compile errors with new GCC 14.1.1

Compile errors with new GCC 14.1.1 (on archlinux)

Below is the output from attempting to build the test subdir:

test (master u=) 0 % scons                                                                                                                                                                                                                             [15:39:56]
scons: Reading SConscript files ...
Checking whether the C++ compiler works... (cached) yes
Checking for C library stdc++... (cached) yes
Checking for C library pthread... (cached) yes
Checking for C library gtest... (cached) yes
scons: done reading SConscript files.
scons: Building targets ...
g++ -o Intdifftest.o -c -std=c++11 -Wall -O2 -I/tmp/uj.tmpdir/dtl.git Intdifftest.cpp
In file included from /usr/include/gtest/gtest-message.h:57,
                 from /usr/include/gtest/gtest-assertion-result.h:46,
                 from /usr/include/gtest/gtest.h:64,
                 from dtl_test_common.hpp:5,
                 from Intdifftest.cpp:1:
/usr/include/gtest/internal/gtest-port.h:279:2: error: #error C++ versions less than C++14 are not supported.
  279 | #error C++ versions less than C++14 are not supported.
      |  ^~~~~
/usr/include/gtest/gtest-assertion-result.h: In member function 'void testing::AssertionResult::AppendMessage(const testing::Message&)':
/usr/include/gtest/gtest-assertion-result.h:207:48: error: 'make_unique' is not a member of 'std'
  207 |     if (message_ == nullptr) message_ = ::std::make_unique<::std::string>();
      |                                                ^~~~~~~~~~~
/usr/include/gtest/gtest-assertion-result.h:207:48: note: 'std::make_unique' is only available from C++14 onwards
/usr/include/gtest/gtest-assertion-result.h:207:73: error: expected primary-expression before '>' token
  207 |     if (message_ == nullptr) message_ = ::std::make_unique<::std::string>();
      |                                                                         ^
/usr/include/gtest/gtest-assertion-result.h:207:75: error: expected primary-expression before ')' token
  207 |     if (message_ == nullptr) message_ = ::std::make_unique<::std::string>();
      |                                                                           ^
In file included from /usr/include/gtest/gtest-printers.h:122,
                 from /usr/include/gtest/gtest-matchers.h:49,
                 from /usr/include/gtest/internal/gtest-death-test-internal.h:47,
                 from /usr/include/gtest/gtest-death-test.h:43,
                 from /usr/include/gtest/gtest.h:65:
/usr/include/gtest/internal/gtest-internal.h: At global scope:
/usr/include/gtest/internal/gtest-internal.h:622:58: error: wrong number of template arguments (0, should be 1)
  622 |   typedef ::std::map<std::string, CodeLocation, std::less<>> RegisteredTestsMap;
      |                                                          ^
In file included from /usr/include/c++/14.1.1/string:49,
                 from /usr/include/c++/14.1.1/bits/locale_classes.h:40,
                 from /usr/include/c++/14.1.1/bits/ios_base.h:41,
                 from /usr/include/c++/14.1.1/iomanip:42,
                 from /usr/include/gtest/gtest.h:54:
/usr/include/c++/14.1.1/bits/stl_function.h:400:12: note: provided for 'template<class _Tp> struct std::less'
  400 |     struct less : public binary_function<_Tp, _Tp, bool>
      |            ^~~~
/usr/include/gtest/internal/gtest-internal.h:622:59: error: template argument 3 is invalid
  622 |   typedef ::std::map<std::string, CodeLocation, std::less<>> RegisteredTestsMap;
      |                                                           ^~
/usr/include/gtest/internal/gtest-internal.h: In member function 'bool testing::internal::TypedTestSuitePState::AddTestName(const char*, int, const char*, const char*)':
/usr/include/gtest/internal/gtest-internal.h:599:23: error: request for member 'insert' in '((testing::internal::TypedTestSuitePState*)this)->testing::internal::TypedTestSuitePState::registered_tests_', which is of non-class type 'testing::internal::TypedTestSuitePState::RegisteredTestsMap' {aka 'int'}
  599 |     registered_tests_.insert(
      |                       ^~~~~~
/usr/include/gtest/internal/gtest-internal.h: In member function 'bool testing::internal::TypedTestSuitePState::TestExists(const std::string&) const':
/usr/include/gtest/internal/gtest-internal.h:605:30: error: request for member 'count' in '((const testing::internal::TypedTestSuitePState*)this)->testing::internal::TypedTestSuitePState::registered_tests_', which is of non-class type 'const testing::internal::TypedTestSuitePState::RegisteredTestsMap' {aka 'const int'}
  605 |     return registered_tests_.count(test_name) > 0;
      |                              ^~~~~
/usr/include/gtest/internal/gtest-internal.h: In member function 'const testing::internal::CodeLocation& testing::internal::TypedTestSuitePState::GetCodeLocation(const std::string&) const':
/usr/include/gtest/internal/gtest-internal.h:609:40: error: qualified-id in declaration before 'it'
  609 |     RegisteredTestsMap::const_iterator it = registered_tests_.find(test_name);
      |                                        ^~
/usr/include/gtest/internal/gtest-internal.h:610:5: error: 'it' was not declared in this scope; did you mean 'int'?
  610 |     GTEST_CHECK_(it != registered_tests_.end());
      |     ^~~~~~~~~~~~
/usr/include/gtest/internal/gtest-internal.h:610:5: error: request for member 'end' in '((const testing::internal::TypedTestSuitePState*)this)->testing::internal::TypedTestSuitePState::registered_tests_', which is of non-class type 'const testing::internal::TypedTestSuitePState::RegisteredTestsMap' {aka 'const int'}
  610 |     GTEST_CHECK_(it != registered_tests_.end());
      |     ^~~~~~~~~~~~
/usr/include/gtest/internal/gtest-internal.h:611:12: error: 'it' was not declared in this scope; did you mean 'int'?
  611 |     return it->second;
      |            ^~
      |            int
/usr/include/gtest/gtest-matchers.h: At global scope:
/usr/include/gtest/gtest-matchers.h:725:75: error: wrong number of template arguments (0, should be 1)
  725 | class EqMatcher : public ComparisonBase<EqMatcher<Rhs>, Rhs, std::equal_to<>> {
      |                                                                           ^
/usr/include/c++/14.1.1/bits/stl_function.h:370:12: note: provided for 'template<class _Tp> struct std::equal_to'
  370 |     struct equal_to : public binary_function<_Tp, _Tp, bool>
      |            ^~~~~~~~
/usr/include/gtest/gtest-matchers.h:725:76: error: template argument 3 is invalid
  725 | class EqMatcher : public ComparisonBase<EqMatcher<Rhs>, Rhs, std::equal_to<>> {
      |                                                                            ^~
/usr/include/gtest/gtest-matchers.h: In constructor 'testing::internal::EqMatcher<Rhs>::EqMatcher(const Rhs&)':
/usr/include/gtest/gtest-matchers.h:728:58: error: wrong number of template arguments (0, should be 1)
  728 |       : ComparisonBase<EqMatcher<Rhs>, Rhs, std::equal_to<>>(rhs) {}
      |                                                          ^
/usr/include/c++/14.1.1/bits/stl_function.h:370:12: note: provided for 'template<class _Tp> struct std::equal_to'
  370 |     struct equal_to : public binary_function<_Tp, _Tp, bool>
      |            ^~~~~~~~
/usr/include/gtest/gtest-matchers.h:728:59: error: template argument 3 is invalid
  728 |       : ComparisonBase<EqMatcher<Rhs>, Rhs, std::equal_to<>>(rhs) {}
      |                                                           ^~
/usr/include/gtest/gtest-matchers.h:728:61: error: expected '{' before '(' token
  728 |       : ComparisonBase<EqMatcher<Rhs>, Rhs, std::equal_to<>>(rhs) {}
      |                                                             ^
/usr/include/gtest/gtest-matchers.h: At global scope:
/usr/include/gtest/gtest-matchers.h:734:67: error: wrong number of template arguments (0, should be 1)
  734 |     : public ComparisonBase<NeMatcher<Rhs>, Rhs, std::not_equal_to<>> {
      |                                                                   ^
/usr/include/c++/14.1.1/bits/stl_function.h:380:12: note: provided for 'template<class _Tp> struct std::not_equal_to'
  380 |     struct not_equal_to : public binary_function<_Tp, _Tp, bool>
      |            ^~~~~~~~~~~~
/usr/include/gtest/gtest-matchers.h:734:68: error: template argument 3 is invalid
  734 |     : public ComparisonBase<NeMatcher<Rhs>, Rhs, std::not_equal_to<>> {
      |                                                                    ^~
/usr/include/gtest/gtest-matchers.h: In constructor 'testing::internal::NeMatcher<Rhs>::NeMatcher(const Rhs&)':
/usr/include/gtest/gtest-matchers.h:737:62: error: wrong number of template arguments (0, should be 1)
  737 |       : ComparisonBase<NeMatcher<Rhs>, Rhs, std::not_equal_to<>>(rhs) {}
      |                                                              ^
/usr/include/c++/14.1.1/bits/stl_function.h:380:12: note: provided for 'template<class _Tp> struct std::not_equal_to'
  380 |     struct not_equal_to : public binary_function<_Tp, _Tp, bool>
      |            ^~~~~~~~~~~~
/usr/include/gtest/gtest-matchers.h:737:63: error: template argument 3 is invalid
  737 |       : ComparisonBase<NeMatcher<Rhs>, Rhs, std::not_equal_to<>>(rhs) {}
      |                                                               ^~
/usr/include/gtest/gtest-matchers.h:737:65: error: expected '{' before '(' token
  737 |       : ComparisonBase<NeMatcher<Rhs>, Rhs, std::not_equal_to<>>(rhs) {}
      |                                                                 ^
/usr/include/gtest/gtest-matchers.h: At global scope:
/usr/include/gtest/gtest-matchers.h:742:71: error: wrong number of template arguments (0, should be 1)
  742 | class LtMatcher : public ComparisonBase<LtMatcher<Rhs>, Rhs, std::less<>> {
      |                                                                       ^
/usr/include/c++/14.1.1/bits/stl_function.h:400:12: note: provided for 'template<class _Tp> struct std::less'
  400 |     struct less : public binary_function<_Tp, _Tp, bool>
      |            ^~~~
/usr/include/gtest/gtest-matchers.h:742:72: error: template argument 3 is invalid
  742 | class LtMatcher : public ComparisonBase<LtMatcher<Rhs>, Rhs, std::less<>> {
      |                                                                        ^~
/usr/include/gtest/gtest-matchers.h: In constructor 'testing::internal::LtMatcher<Rhs>::LtMatcher(const Rhs&)':
/usr/include/gtest/gtest-matchers.h:745:54: error: wrong number of template arguments (0, should be 1)
  745 |       : ComparisonBase<LtMatcher<Rhs>, Rhs, std::less<>>(rhs) {}
      |                                                      ^
/usr/include/c++/14.1.1/bits/stl_function.h:400:12: note: provided for 'template<class _Tp> struct std::less'
  400 |     struct less : public binary_function<_Tp, _Tp, bool>
      |            ^~~~
/usr/include/gtest/gtest-matchers.h:745:55: error: template argument 3 is invalid
  745 |       : ComparisonBase<LtMatcher<Rhs>, Rhs, std::less<>>(rhs) {}
      |                                                       ^~
/usr/include/gtest/gtest-matchers.h:745:57: error: expected '{' before '(' token
  745 |       : ComparisonBase<LtMatcher<Rhs>, Rhs, std::less<>>(rhs) {}
      |                                                         ^
/usr/include/gtest/gtest-matchers.h: At global scope:
/usr/include/gtest/gtest-matchers.h:750:74: error: wrong number of template arguments (0, should be 1)
  750 | class GtMatcher : public ComparisonBase<GtMatcher<Rhs>, Rhs, std::greater<>> {
      |                                                                          ^
/usr/include/c++/14.1.1/bits/stl_function.h:390:12: note: provided for 'template<class _Tp> struct std::greater'
  390 |     struct greater : public binary_function<_Tp, _Tp, bool>
      |            ^~~~~~~
/usr/include/gtest/gtest-matchers.h:750:75: error: template argument 3 is invalid
  750 | class GtMatcher : public ComparisonBase<GtMatcher<Rhs>, Rhs, std::greater<>> {
      |                                                                           ^~
/usr/include/gtest/gtest-matchers.h: In constructor 'testing::internal::GtMatcher<Rhs>::GtMatcher(const Rhs&)':
/usr/include/gtest/gtest-matchers.h:753:57: error: wrong number of template arguments (0, should be 1)
  753 |       : ComparisonBase<GtMatcher<Rhs>, Rhs, std::greater<>>(rhs) {}
      |                                                         ^
/usr/include/c++/14.1.1/bits/stl_function.h:390:12: note: provided for 'template<class _Tp> struct std::greater'
  390 |     struct greater : public binary_function<_Tp, _Tp, bool>
      |            ^~~~~~~
/usr/include/gtest/gtest-matchers.h:753:58: error: template argument 3 is invalid
  753 |       : ComparisonBase<GtMatcher<Rhs>, Rhs, std::greater<>>(rhs) {}
      |                                                          ^~
/usr/include/gtest/gtest-matchers.h:753:60: error: expected '{' before '(' token
  753 |       : ComparisonBase<GtMatcher<Rhs>, Rhs, std::greater<>>(rhs) {}
      |                                                            ^
/usr/include/gtest/gtest-matchers.h: At global scope:
/usr/include/gtest/gtest-matchers.h:759:65: error: wrong number of template arguments (0, should be 1)
  759 |     : public ComparisonBase<LeMatcher<Rhs>, Rhs, std::less_equal<>> {
      |                                                                 ^
/usr/include/c++/14.1.1/bits/stl_function.h:420:12: note: provided for 'template<class _Tp> struct std::less_equal'
  420 |     struct less_equal : public binary_function<_Tp, _Tp, bool>
      |            ^~~~~~~~~~
/usr/include/gtest/gtest-matchers.h:759:66: error: template argument 3 is invalid
  759 |     : public ComparisonBase<LeMatcher<Rhs>, Rhs, std::less_equal<>> {
      |                                                                  ^~
/usr/include/gtest/gtest-matchers.h: In constructor 'testing::internal::LeMatcher<Rhs>::LeMatcher(const Rhs&)':
/usr/include/gtest/gtest-matchers.h:762:60: error: wrong number of template arguments (0, should be 1)
  762 |       : ComparisonBase<LeMatcher<Rhs>, Rhs, std::less_equal<>>(rhs) {}
      |                                                            ^
/usr/include/c++/14.1.1/bits/stl_function.h:420:12: note: provided for 'template<class _Tp> struct std::less_equal'
  420 |     struct less_equal : public binary_function<_Tp, _Tp, bool>
      |            ^~~~~~~~~~
/usr/include/gtest/gtest-matchers.h:762:61: error: template argument 3 is invalid
  762 |       : ComparisonBase<LeMatcher<Rhs>, Rhs, std::less_equal<>>(rhs) {}
      |                                                             ^~
/usr/include/gtest/gtest-matchers.h:762:63: error: expected '{' before '(' token
  762 |       : ComparisonBase<LeMatcher<Rhs>, Rhs, std::less_equal<>>(rhs) {}
      |                                                               ^
/usr/include/gtest/gtest-matchers.h: At global scope:
/usr/include/gtest/gtest-matchers.h:768:68: error: wrong number of template arguments (0, should be 1)
  768 |     : public ComparisonBase<GeMatcher<Rhs>, Rhs, std::greater_equal<>> {
      |                                                                    ^
/usr/include/c++/14.1.1/bits/stl_function.h:410:12: note: provided for 'template<class _Tp> struct std::greater_equal'
  410 |     struct greater_equal : public binary_function<_Tp, _Tp, bool>
      |            ^~~~~~~~~~~~~
/usr/include/gtest/gtest-matchers.h:768:69: error: template argument 3 is invalid
  768 |     : public ComparisonBase<GeMatcher<Rhs>, Rhs, std::greater_equal<>> {
      |                                                                     ^~
/usr/include/gtest/gtest-matchers.h: In constructor 'testing::internal::GeMatcher<Rhs>::GeMatcher(const Rhs&)':
/usr/include/gtest/gtest-matchers.h:771:63: error: wrong number of template arguments (0, should be 1)
  771 |       : ComparisonBase<GeMatcher<Rhs>, Rhs, std::greater_equal<>>(rhs) {}
      |                                                               ^
/usr/include/c++/14.1.1/bits/stl_function.h:410:12: note: provided for 'template<class _Tp> struct std::greater_equal'
  410 |     struct greater_equal : public binary_function<_Tp, _Tp, bool>
      |            ^~~~~~~~~~~~~
/usr/include/gtest/gtest-matchers.h:771:64: error: template argument 3 is invalid
  771 |       : ComparisonBase<GeMatcher<Rhs>, Rhs, std::greater_equal<>>(rhs) {}
      |                                                                ^~
/usr/include/gtest/gtest-matchers.h:771:66: error: expected '{' before '(' token
  771 |       : ComparisonBase<GeMatcher<Rhs>, Rhs, std::greater_equal<>>(rhs) {}
      |                                                                  ^
/usr/include/gtest/gtest.h: At global scope:
/usr/include/gtest/gtest.h:302:30: error: 'std::enable_if_t' has not been declared
  302 |   template <typename T, std::enable_if_t<std::is_convertible<T, int64_t>::value,
      |                              ^~~~~~~~~~~
/usr/include/gtest/gtest.h:302:41: error: expected '>' before '<' token
  302 |   template <typename T, std::enable_if_t<std::is_convertible<T, int64_t>::value,
      |                                         ^
In file included from /tmp/uj.tmpdir/dtl.git/dtl/dtl.hpp:44,
                 from dtl_test_common.hpp:12:
/tmp/uj.tmpdir/dtl.git/dtl/Diff.hpp: In member function 'void dtl::Diff<elem, sequence, comparator>::enableTrivial() const':
/tmp/uj.tmpdir/dtl.git/dtl/Diff.hpp:168:27: error: assignment of member 'trivial' in read-only object
  168 |             this->trivial = true;
      |             ~~~~~~~~~~~~~~^~~~~~
scons: *** [Intdifftest.o] Error 1
scons: building terminated because of errors.

substring matching

Hi,

Please consider adding an option to diff by substrings.
E.g. column 4-10 of file a and b instead of the whole line.

Diff3 merge is broken

std::string base_code_ = "0";
std::string left_code_ = "100";
std::string right_code_ = "200";

dtl::Diff3<char, std::string> diff3(base_code_, left_code_, right_code_);
diff3.compose();
if (!diff3.merge())
{
    std::cout << "Conflict" << std::endl;
}
else
{
    std::string merged = diff3.getMergedSequence(); // 20 here
}

I expect conflict

When traversing SES_DELETE in uniHunks, beforeIdx suddenly decreases

Hello, I am traversing the uniHunks in dtl and attempting to print out each element (type, beforeIdx, afterIdx).

However, I noticed that when traversing consecutive SES_DELETE elements, the value of beforeIdx was reduced from 15321 to 1452:

...
-1 15321 0
-1 1452 0
...

Additionally, I tested with other diff tools and found that there is no text change in line 1452.

This is my code:

#include <iostream>
#include <string>
#include <vector>
#include <filesystem>
#include <fstream>
#include "dtl/dtl.hpp"

namespace fs = std::filesystem;

void fatal(const std::string &msg) {
    std::cerr << msg << std::endl;
    exit(1);
}

void run(const fs::path &oldPath,
         const fs::path &newPath) {
    std::vector<std::string> oldLines;
    std::vector<std::string> newLines;

    std::ifstream oldFileFs(oldPath);
    if (!oldFileFs.is_open()) {
        fatal("Diff error: can not open oldFile: " +
                             oldPath.string());
    }
    std::string line;
    while (getline(oldFileFs, line)) {
        oldLines.push_back(line);
    }

    std::ifstream newFileFs(newPath);
    if (!newFileFs.is_open()) {
        fatal("Diff error: can not open newFile: " +
                             newPath.string());
    }
    while (getline(newFileFs, line)) {
        newLines.push_back(line);
    }

    dtl::Diff<std::string, std::vector<std::string>> diff(oldLines, newLines);
    diff.onHuge();
    diff.compose();
    diff.composeUnifiedHunks();
    auto uniHunks = diff.getUniHunks();

    for (const auto &hunk: uniHunks) {
        for (auto &diffLine: hunk.change) {
            auto &diffLineInfo = diffLine.second;

            std::cerr << diffLineInfo.type << " " <<
            diffLineInfo.beforeIdx << " " << diffLineInfo.afterIdx << std::endl;
        }
    }

}

int main() {
    run("../old.txt", "../new.txt");
}

This is my test files:

new.txt
old.txt

Make include guards unique

๐Ÿ’ญ I find that include guards like โ€œDTL_Hโ€ and โ€œDTL_SES_Hโ€ are too short for the safe reuse of your header files (when they belong to an application programming interface).

There is a bug

Steps to reproduce:

#include "3rdparty/dtl/dtl.hpp"
#include <iostream>
#include <vector>

int main(int argc, char *argv[]) {
    std::vector<char> a = {'a','b','c','d'};
    std::vector<char> b = {'a','b','c','d','e','f'};

    std::cout << "a: " << "abcd" << "\n";
    std::cout << "b: " << "abcdef" << "\n";

    dtl::Diff<char,std::vector<char>> d(b,a);
    d.compose();
    d.onHuge();
    d.composeUnifiedHunks();
    d.printUnifiedFormat();

    return 0;
}

Output:

a: abcd
b: abcdef
@@ -2,5 +2,3 @@
 b
 c
 d
-e
-f

Does anyone know why the first element 'a' is not defined as common to sequences? Is there any way around this mistake without losing performance?

New release

The latest release (v1.19) is from 2016. Even though there has been only one change to the library, I think it might be a good idea to have a new release, such as v1.20.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.