Skip to content

tsort: split edge data on any whitespace chars#7078

Merged
cakebaker merged 3 commits intouutils:mainfrom
jfinkels:tsort-split-whitespace
Jan 5, 2025
Merged

tsort: split edge data on any whitespace chars#7078
cakebaker merged 3 commits intouutils:mainfrom
jfinkels:tsort-split-whitespace

Conversation

@jfinkels
Copy link
Copy Markdown
Collaborator

@jfinkels jfinkels commented Jan 5, 2025

Make tsort split on any whitespace character instead of just
whitespace within a single line. This allows edge information to be
split with the source node on one line and the target node on another.

For example, after this commit

$ printf "a\nb\n" | tsort
a
b

whereas before this would print an error message.

This pull request also makes two other small changes. First, it introduces a TsortError enum implementing the UError trait to represent the various problems that tsort might encounter. Second, it uses the standard library std::io::read_to_string and std::fs::read_to_string in place of custom code that was ultimately doing the same thing.

Closes #7077

Make `tsort` split on any whitespace character instead of just
whitespace within a single line. This allows edge information to be
split with the source node on one line and the target node on another.

For example, after this commit

    $ printf "a\nb\n" | tsort
    a
    b

whereas before this would print an error message.

Closes uutils#7077
@github-actions
Copy link
Copy Markdown

github-actions bot commented Jan 5, 2025

GNU testsuite comparison:

Skipping an intermittent issue tests/timeout/timeout (passes in this run but fails in the 'main' branch)

@cakebaker cakebaker merged commit e3acd5a into uutils:main Jan 5, 2025
@cakebaker
Copy link
Copy Markdown
Contributor

A much cleaner approach, thanks!

@jfinkels jfinkels deleted the tsort-split-whitespace branch January 5, 2025 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tsort: incorrectly errors on odd number of tokens per line

2 participants