-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
fix(ptx): Correct various output formatting bugs #8787
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
Conversation
Can you please use text instead of images? Images are bad for accessibility :| |
GNU testsuite comparison:
|
CodSpeed Performance ReportMerging #8787 will not alter performanceComparing Summary
Footnotes
|
Ok,
GNU wanan@Misakait ~ via C v12.2.0-gcc via v18.19.0 at 18:20:35
❯ echo "Hello World\nRust is funnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn" | ptx -G -w 30 --format=tex
\xx {}{}{Hello}{}{}
\xx {is}{Hello}{World\backslash{}nRust}{}{}
\xx {}{is}{funnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn}{}{}
\xx {}{World\backslash{}nRust}{is}{}{Hello} Before fix ╭─[misakait@Misakait]─[D:\..\..\..\..\ptx]─(#) (1.90.0)()─[ 79%]─[ 2,18:21]
╰─[ main ● ?1 ~5]- echo "Hello World\nRust is funnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn" | cargo run -- -G -w 30 --format=tex
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.14s
Running `D:\Project\coreutils\target\debug\ptx.exe -G -w 30 --format=tex`
\xx {}{}{Hello}{/}{}
\xx {is/}{Hello}{World\backslash{}nRust}{}{}
\xx {}{/is}{funnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn}{}{}
\xx {}{World\backslash{}nRust}{is}{/}{Hello} After fix ╭─[misakait@Misakait]─[D:\..\..\..\..\ptx]─(#) (1.90.0)()─[ 79%]─[ 2,18:28]
╰─[ fix/ptx-tex-format-bug ● ?1]- echo "Hello World\nRust is funnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn" | cargo run -- -G -w 30 --format=tex
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.23s
Running `D:\Project\coreutils\target\debug\ptx.exe -G -w 30 --format=tex`
\xx {}{}{Hello}{}{}
\xx {is}{Hello}{World\backslash{}nRust}{}{}
\xx {}{is}{funnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn}{}{}
\xx {}{World\backslash{}nRust}{is}{}{Hello} 2.Prevent Text Chunks from Over-reading at Boundaries wanan@Misakait ~ via C v12.2.0-gcc via v18.19.0 at 18:25:56
❯ echo "Hello World\nRust is a funnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn" | ptx -G -w 30 --format=tex
\xx {}{}{Hello}{}{}
\xx {is}{Hello}{World\backslash{}nRust}{}{}
\xx {}{is}{a}{}{}
\xx {}{is a}{funnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn}{}{}
\xx {}{World\backslash{}nRust}{is}{ a}{Hello} Before fix ╭─[misakait@Misakait]─[D:\..\..\..\..\ptx]─(#) (1.90.0)()─[ 79%]─[ 2,18:30]
╰─[ main ● ?1]- echo "Hello World\nRust is a funnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn" | cargo run -- -G -w 30 --format=tex
Compiling uu_ptx v0.2.2 (D:\Project\coreutils\src\uu\ptx)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.86s
Running `D:\Project\coreutils\target\debug\ptx.exe -G -w 30 --format=tex`
\xx {}{}{Hello}{ /}{}
\xx {is a/}{Hello}{World\backslash{}nRust}{ }{}
\xx {}{/is}{a}{ /}{}
\xx {}{/is a}{funnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn}{}{}
\xx {}{World\backslash{}nRust}{is}{ a/}{Hello} After fix ╭─[misakait@Misakait]─[D:\..\..\..\..\ptx]─(#) (1.90.0)()─[ 79%]─[ 2,18:28]
╰─[ fix/ptx-tex-format-bug ● ?1]- echo "Hello World\nRust is a funnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn" | cargo run -- -G -w 30 --format=tex
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.21s
Running `D:\Project\coreutils\target\debug\ptx.exe -G -w 30 --format=tex`
\xx {}{}{Hello}{}{}
\xx {is}{Hello}{World\backslash{}nRust}{}{}
\xx {}{is}{a}{}{}
\xx {}{is a}{funnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn}{}{}
\xx {}{World\backslash{}nRust}{is}{ a}{Hello} |
GNU testsuite comparison:
|
cd5f899
to
c33888b
Compare
Can you please add one or more tests to ensure we don't regress in the future? |
Thanks for taking the time to review this! I'd be happy to add more tests. I'm a little busy at the moment, but I'll work on it tomorrow. |
GNU testsuite comparison:
|
c33888b
to
008b202
Compare
GNU testsuite comparison:
|
Hi, the Could a maintainer please help re-run the failed jobs? Thank you |
Thank you for re-running the job, @cakebaker ! I noticed that another PR (#8794) and (#8786) are also failing on the same |
The GNU `ptx` implementation does not display truncation markers (e.g., "/") when using the TeX (`--format=tex`) output format. This change updates the `format_tex_line` function to prevent truncation markers from being included in the TeX output, aligning uutils' behavior with GNU's.
Fixes a bug in `get_output_chunks` where calculated text chunks (e.g., `tail`) would incorrectly include a trailing space and the first character of the next word. The fix explicitly checks for and trims this pattern to ensure chunk boundaries are respected, matching GNU ptx behavior.
Adds two fixture-based tests to verify GNU-compatible behavior: - `test_tex_format_no_truncation_markers`: Ensures TeX format does not display truncation markers. - `gnu_ext_disabled_chunk_no_over_reading`: Verifies that text chunks do not over-read at boundaries in traditional mode.
00b18ff
to
48b5439
Compare
GNU testsuite comparison:
|
Thanks! |
Thank you so much for merging this! I know my commit history was messy as I'm still a beginner, so I really appreciate you taking the extra time to clean it up into a polished PR. It's a great example for me to learn from. |
|
IMPORTANT: This PR depends on #8784 and should be reviewed and merged after it.
Summary
This PR fixes two compatibility issues in
ptx
's formatted output to better align with GNUptx
behavior. The changes correct how truncation is handled in the TeX format and fix an "over-reading" bug that affected all formats.Changes Made
Remove Truncation Markers from TeX Output
The GNU
ptx
implementation does not display truncation markers (e.g.,/
) when using the TeX (--format=tex
) output format. This change updatesformat_tex_line
to suppress these markers, matching GNU's behavior.ptx
(Correct Behavior):uutils/ptx
Before Fix:uutils/ptx
After Fix:ptx
(Correct Behavior):uutils/ptx
After Fix: