Subject: tsort reporting false loop in input. unix2dos fixes the problem.

From: Ivan Ivanov <[email-masked]>
Date: Wed, 16 May 2018 12:23:12 +0300

Hi all,

tsort is reporting loop in my input file, but the loop doesn't exist
really. 

I have checked this manually, examining the contents of the file,
related to the reported loop. 

Further more, if I run the input file trhough unix2dos – it works, so I
suspect some strange problem with the unix newlines. 

The input file is generated with python script on the Ubuntu 16.04.3 so
all newlines should be the same.

Test environments (acting the same way):
---------------------------------------

Ubuntu 16.04.3 LTS
tsort (coreutils) 8.25

and

Debian GNU/Linux 9 (stretch)
tsort (coreutils) 8.26

Reproduction steps:
---------------------------------------
$ unxz for-tsort-bug-example.txt.xz
$ tsort for-tsort-bug-example.txt > /dev/null

the above command should produce:
tsort: for-tsort-bug-example.txt: input contains a loop:
tsort: 15731101
tsort: 15731102

$ cat for-tsort-bug-example.txt | unix2dos | tsort > /dev/null

should exit properly.

You may choose to first convert the file and than call tsort and it
will exit properly again:
$ unix2dos for-tsort-bug-example.txt
$ tsort for-tsort-bug-example.txt > /dev/null

If you have further questions to investigate the issue, feel free to
write back!

Best wishes,

Ivan Ivanov