Skip to content
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

fmt: value of minlength should not be negative #6359

Merged
merged 2 commits into from
May 5, 2024

Conversation

ahmadabd
Copy link
Contributor

@ahmadabd ahmadabd commented May 5, 2024

closes #6354

@cakebaker cakebaker changed the title Fix: value of minlength should not be negetive fmt: value of minlength should not be negative May 5, 2024
@cakebaker
Copy link
Contributor

Can you please add a test so we don't regress in the future?

@ahmadabd ahmadabd force-pushed the negetive-minlength branch from 9d44d0e to 771f695 Compare May 5, 2024 10:48
@ahmadabd
Copy link
Contributor Author

ahmadabd commented May 5, 2024

Can you please add a test so we don't regress in the future?

Done

let minlength = if args.opts.goal >= stretch {
args.opts.goal - stretch
} else {
DEFAULT_GOAL_TO_WIDTH_RATIO
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is incorrect because DEFAULT_GOAL_TO_WIDTH_RATIO represents a ratio, 93% in this case, and not an absolute value.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont know what should be value of -g when minlength is negetive

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about using 1? The old code seems to use stretch as a guess for how much wiggle-room there is. And if minlength has to be at least 1 anyway, well, then just use 1 as the minimum value.

    // Would like to write (args.opts.goal - stretch).max(1), but that can underflow the unsigned integer:
    let minlength = args.opts.goal.max(stretch + 1) - stretch;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds reasonable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes sounds reasonable

@ahmadabd ahmadabd force-pushed the negetive-minlength branch 2 times, most recently from e29369c to c4029c2 Compare May 5, 2024 12:54
Copy link

github-actions bot commented May 5, 2024

GNU testsuite comparison:

Skip an intermittent issue tests/tail/inotify-dir-recreate (fails in this run but passes in the 'main' branch)

@ahmadabd ahmadabd force-pushed the negetive-minlength branch from c4029c2 to abade2d Compare May 5, 2024 16:54
@ahmadabd ahmadabd force-pushed the negetive-minlength branch from abade2d to 82710c1 Compare May 5, 2024 17:44
Copy link
Collaborator

@BenWiederhake BenWiederhake left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@BenWiederhake
Copy link
Collaborator

Remaining failure is #6275 and #6333

@BenWiederhake BenWiederhake merged commit a3d05e5 into uutils:main May 5, 2024
67 of 68 checks passed
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.

fmt: Crashes for some inputs (?)
3 participants