-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Tuesday, 10.07.2012 at 01:52 +0200, Christoph Anton Mitterer wrote:
> Not sure whether this is a bug or simply a "not possible",
> but when using colordiff like:
> wdiff .bashrc_* | colordiff
> on the two attached files... I get no colors.
> It works on other files, though.
I suspect this is an edge case where the particular files you're diffing
have content which confuses colordiff's regex parser for wdiff markup.
The simple diff is:
$ /usr/bin/diff bashrc_*
60c60
<
PS1='${debian_chroot:+($debian_chroot)}\[\033[0;31m\]\u@\h\[\033[0m\]:\[\033[1;34m\]\w\[\033[0m\]\$
'
- ---
> PS1='${debian_chroot:+($debian_chroot)}\[\033[0;32m\]\u@\h\[\033[0m\]:\[\033[1;34m\]\w\[\033[0m\]\$
> '
where one is looking for the 31m -> 32m to be picked up, I presume.
Note first of all that wdiff is "word diff" and so the entire string
'PS1' to '$' will be considered a word. Therefore in this particular
example, even if the colour markup was working properly, you'd not get
much better output that using diff/colordiff (instead of wdiff), because
of the lack of spaces!
However, to address the actual issue: wdiff produces this output:
[-PS1='${debian_chroot:+($debian_chroot)}\[\033[0;31m\]\u@\h\[\033[0m\]:\[\033[1;34m\]\w\[\033[0m\]\$-]
{+PS1='${debian_chroot:+($debian_chroot)}\[\033[0;32m\]\u@\h\[\033[0m\]:\[\033[1;34m\]\w\[\033[0m\]\$+}
'
which colordiff's parser fails to recognise as wdiff format, even when
forced with the option '--diff-type=wdiff'. I presume the existence of
'-', '+', '[' and '{' etc. in the text confuses the regex, specifically
colordiff.pl 1.0.10 lines 253 to 262 (for detection):
# wdiff deleted/added patterns
# should almost always be pairwaise?
elsif ($record =~ /\[-.*?-\]/s) {
$diff_type = 'wdiff';
last DIFF_TYPE;
}
elsif ($record =~ /\{\+.*?\+\}/s) {
$diff_type = 'wdiff';
last DIFF_TYPE;
}
and
colordiff.pl 1.0.10 lines 442 to 445 (for output):
elsif ($diff_type eq 'wdiff') {
$_ =~ s/(\[-[^]]*?-\])/$file_old$1$colour{off}/g;
$_ =~ s/(\{\+[^]]*?\+\})/$file_new$1$colour{off}/g;
}
I don't immediately see the fix, since I appear to be suffering from
regex blindness(!), but I'll record it here in case anyone else can spot
it.
Dave.
- --
Dave Ewart [email protected], http://twitter.com/DaveEwart
All email from me is digitally signed, http://www.sungate.co.uk/
Fingerprint: AEC5 9360 0A35 7F66 66E9 82E4 9E10 6769 CD28 DA92
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
iEYEARECAAYFAk/8CoMACgkQnhBnac0o2pLv7ACgsPCVKWvbtMZS6rhHbz57ZiO3
24sAn03LuIYyowK3Gg7xGn5OtQf/FHqC
=Dh6d
-----END PGP SIGNATURE-----
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]