Skip to content

tsort: split edge data on any whitespace chars #7078

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 5, 2025

Conversation

jfinkels
Copy link
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
Copy link

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
65 checks passed
@cakebaker
Copy link
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