>From 7b7ebe9c5716a39cff4478e6e83720b9a9648c62 Mon Sep 17 00:00:00 2001 From: KO Myung-Hun Date: Tue, 15 Jul 2014 11:50:53 +0900 Subject: [PATCH] diff: skip test if seek is not possible on OS/2 kLIBC This fixes the problem that 'diff - file' and 'cat file | diff - file' fail due to a seek failure with a message 'diff.exe: -: Invalid seek', because seek does not work on stdin and a pipe on OS/2 kLIBC. * src/io.c (sip): Set skip_test to true if seek is not possible on OS/2 kLIBC. --- src/io.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/io.c b/src/io.c index 1a8b936..e564f40 100644 --- a/src/io.c +++ b/src/io.c @@ -108,6 +108,13 @@ sip (struct file_data *current, bool skip_test) PTRDIFF_MAX - 2 * sizeof (word)); current->buffer = xmalloc (current->bufsize); +#ifdef __KLIBC__ + /* Skip test if seek is not possible */ + skip_test = skip_test + || (lseek (current->desc, 0, SEEK_CUR) < 0 + && errno == ESPIPE); +#endif + if (! skip_test) { /* Check first part of file to see if it's a binary file. */ -- 1.8.5.2