bug-diffutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-diffutils] Funny behaviour of diff 2.8.1


From: Paul Eggert
Subject: Re: [bug-diffutils] Funny behaviour of diff 2.8.1
Date: Thu, 12 Aug 2010 22:03:38 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.11) Gecko/20100713 Thunderbird/3.0.6

On 08/12/10 10:38, Philipp Thomas wrote:
> As I wrote in the subject diff is 2.8.1. ksh is at 93t 2010-03-09 and
> platform is SUSE LINUX Enterprise 11 SP1.

Ah, sorry, I missed that.

> I asked my collegue to do a ltrace and that identified the culprit. diff
> (and cmp) do a reopen if input or output isn't a terminal.

But diff and cmp do this only if O_BINARY is nonzero, which should be
true only on MS-DOS or Microsoft Windows hosts.  O_BINARY should be
zero on SuSE, since it's a Linux host and Linux doesn't distinguish
between text and binary mode.  Can you please investigate why O_BINARY
is nonzero on your platform?

Furthermore, even if O_BINARY is zero, diff does a reopen only if the
--binary option is set, which it wasn't in your test cases.  So I'm
still mystified as to why you observed that misbehavior.  Can you
please investigate why diff did a reopen even though --binary was
not used?

One other thing.  Even if diff and cmp are, despite the above
discussion, using freopen (NULL, "rb", stdin), then if freopen is
doing the funny dance with dup that your strace output described,
surely that would be a bug in freopen, not in cmp or diff proper.

> The solution is to stat the file first and then add a test for !
> S_ISSOCK before reopening.  The patch I came up with is attached.

Now I'm confused even more.  The patch you came up with was not
against diff 2.8.1; it appears to be against a more-recent version.
Have you observed the exact same bug with diffutils 3.0, and did this
patch fix the bug?  If so, can you please send strace output before
and after the patch, for both diff and cmp?  We can't simply apply the
patch as-is, since I'm pretty sure it will mess things up on MS-DOS or
Windows; and given the questions above I'm afraid that I still don't
understand the need for a patch on SUSE.

Thanks.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]