Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There is a bug #3

Closed
tripolskypetr opened this issue Jul 26, 2019 · 3 comments
Closed

There is a bug #3

tripolskypetr opened this issue Jul 26, 2019 · 3 comments

Comments

@tripolskypetr
Copy link

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?

@cubicdaiya
Copy link
Owner

It's not a bug but expected behavior.

A diff with unified format is represented as a set of chunk and each chunk has common sequences up to N(>=0). N in dtl is 3. It's fixed.

@cubicdaiya
Copy link
Owner

FYI, GNU diffutils has the feature to change this number.

$ diff --help | grep "\-U"
  -u  -U NUM  --unified[=NUM]  Output NUM (default 3) lines of unified context.

@wingunder
Copy link

@cubicdaiya wrote:

A diff with unified format is represented as a set of chunk and each chunk has common sequences up to N(>=0). N in dtl is 3. It's fixed.

My PR #5, now enables the user to specify N, say 5, instead of the default 3:
d.composeUnifiedHunks(5);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants