Skip to content

Commit ec60c3b

Browse files
komhmeyering
authored andcommitted
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.
1 parent ecf6a42 commit ec60c3b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/io.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,13 @@ sip (struct file_data *current, bool skip_test)
108108
PTRDIFF_MAX - 2 * sizeof (word));
109109
current->buffer = xmalloc (current->bufsize);
110110

111+
#ifdef __KLIBC__
112+
/* Skip test if seek is not possible */
113+
skip_test = skip_test
114+
|| (lseek (current->desc, 0, SEEK_CUR) < 0
115+
&& errno == ESPIPE);
116+
#endif
117+
111118
if (! skip_test)
112119
{
113120
/* Check first part of file to see if it's a binary file. */

0 commit comments

Comments
 (0)