Subject: bug#19186: [PATCH 2/2] diff: skip test if seek is not possible on OS/2 kLIBC

From: KO Myung-Hun <[email-masked]>
Date: Wed, 26 Nov 2014 11:29:39 +0900

This fixes the problem that 'diff - file' fails due to seek failure,
because seek does not work on stdin 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 | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/io.c b/src/io.c
index 05a898c..75c39a9 100644
--- a/src/io.c
+++ b/src/io.c
@@ -108,6 +108,11 @@ 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;
+#endif
+
       if (! skip_test)
 	{
 	  /* Check first part of file to see if it's a binary file.  */
-- 
1.8.5.2