[9.0a] Compare tool syncs wrong lines

The behaviour described in the bug report is either by design, or would be far too complex/time-consuming to be changed

Moderators: white, Hacker, petermad, Stefan2

Post Reply
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

[9.0a] Compare tool syncs wrong lines

Post by *MVV »

Well, it may be not easy to meet the conditions but I face it pretty often...

1. Please compare these two text files aaa.txt and bbb.txt in compare tool (in this order) with enabled "Ignore repeated spaces" and disabled "Ignore frequent lines" options:

Code: Select all

function get_gettimeofday() {
    return gettimeofday();
}



class MyClass {
    // some comment
    // some other comment
    var $files = array();
    var $var1;
    var $var2;


    //TODO go sleep
    function process($filename){
        do_something(FALSE, $filename);
        return result($filename);
    }

usage() {
    echo "usage: $0 COMMAND"
    echo
    echo "Manage php source tarball lifecycle."
    echo
    echo "Commands:"
    echo "   extract  extract php source tarball into directory $dir if not already done."
    echo "   delete   delete extracted php source located into $dir if not already done."
    echo
}

case "$1" in
extract)
    mkdir -p "$dir"
    if [ ! -f "$dir/.docker-extracted" ]; then
        tar -Jxf /usr/src/php.tar.xz -C "$dir" --strip-components=1
        touch "$dir/.docker-extracted"
    fi
    ;;

delete)
    rm -rf "$dir"
    ;;

*)
    usage
    exit 1
    ;;
esac

Code: Select all

function get_gettimeofday() {
    return gettimeofday();
}

function get_true() {
    return FALSE;
}

if (!function_exists('test_function')) {
    function test_function($s) {
        // yohoh
        // gfhggggg
        //dfgdfgdfgdfg
    }
}



class MyClass {
    // some comment
    // some other comment
    var $files = array();
    var $var1;
    var $var2;

    // ini="/usr/local/etc/php/conf.d/${iniName:-"docker-php-ext-$ext.ini"}"


    //TODO go sleep
    function process($filename){
        do_something(FALSE, $filename);
        return result($filename);
    }

usage() {
    echo "usage: $0 COMMAND"
    echo
    echo "Manage php source tarball lifecycle."
    echo
    echo "Commands:"
    echo "   extract  extract php source tarball into directory $dir if not already done."
    echo "   delete   delete extracted php source located into $dir if not already done."
    echo
}

case "$1" in
extract)
    mkdir -p "$dir"
    if [ ! -f "$dir/.docker-extracted" ]; then
        tar -Jxf /usr/src/php.tar.xz -C "$dir" --strip-components=1
        touch "$dir/.docker-extracted"
    fi
    ;;

delete)
    rm -rf "$dir"
    ;;

*)
    usage
    exit 1
    ;;
esac
Note that comparer has synced wrong lines at some moment and all other lines are synced incorrectly (though they are 100% equal).

2. Simply swap panels (from context menu) and press Compare button! Now comparer have synced proper lines!

3. Swap panels back and press Compare button to get bad sync again, and enable "Ignore frequent lines" option or disable "Ignore repeated spaces" option to set them into same state (enabled or disabled) and press Compare again. Comparer have synced proper lines again!


So it is quite strange why TC syncs these files (which provide only a sample of real situation of course) in first case.
User avatar
petermad
Power Member
Power Member
Posts: 14793
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Post by *petermad »

I can confirm the described behavior - it is not a new thing - TC 8.52a behaves the same way.
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48077
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

The tool goes from line to line in the left file, and looks for matching lines in the right. Since there is no "correct" way to do this, this may lead to different results. That's why there is the function "Resync from here", so you can match the lines to gether where YOU think they belong together.

The problem here are the lines with a single "}" in them. TC finds them as a match, and therefore misses the match of longer lines.
Author of Total Commander
https://www.ghisler.com
Post Reply