+
Skip to content

Conversation

Misakait
Copy link
Contributor

@Misakait Misakait commented Oct 2, 2025

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 GNU ptx behavior. The changes correct how truncation is handled in the TeX format and fix an "over-reading" bug that affected all formats.

Changes Made

  1. 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 updates format_tex_line to suppress these markers, matching GNU's behavior.

  • GNU ptx (Correct Behavior):
image
  • uutils/ptx Before Fix:
image
  • uutils/ptx After Fix:
image
  1. Prevent Text Chunks from Over-reading at Boundaries
  • GNU ptx (Correct Behavior):
PixPin_2025-10-02_17-12-01 * **`uutils/ptx` Before Fix:** PixPin_2025-10-02_17-12-48
  • uutils/ptx After Fix:
PixPin_2025-10-02_17-12-23

@cakebaker
Copy link
Contributor

Can you please use text instead of images? Images are bad for accessibility :|

Copy link

github-actions bot commented Oct 2, 2025

GNU testsuite comparison:

Skip an intermittent issue tests/misc/tee (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/timeout/timeout (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/tail/overlay-headers (passes in this run but fails in the 'main' branch)

Copy link

codspeed-hq bot commented Oct 2, 2025

CodSpeed Performance Report

Merging #8787 will not alter performance

Comparing Misakait:fix/ptx-tex-format-bug (48b5439) with main (9064619)

Summary

✅ 65 untouched
⏩ 73 skipped1

Footnotes

  1. 73 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@Misakait
Copy link
Contributor Author

Misakait commented Oct 2, 2025

Can you please use text instead of images? Images are bad for accessibility :|

Ok,

  1. Remove Truncation Markers from TeX Output

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
GNU

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}

Copy link

github-actions bot commented Oct 2, 2025

GNU testsuite comparison:

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

@cakebaker cakebaker force-pushed the fix/ptx-tex-format-bug branch from cd5f899 to c33888b Compare October 2, 2025 14:07
@cakebaker
Copy link
Contributor

Can you please add one or more tests to ensure we don't regress in the future?

@Misakait
Copy link
Contributor Author

Misakait commented Oct 2, 2025

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.

Copy link

github-actions bot commented Oct 2, 2025

GNU testsuite comparison:

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

@Misakait Misakait force-pushed the fix/ptx-tex-format-bug branch from c33888b to 008b202 Compare October 3, 2025 06:54
Copy link

github-actions bot commented Oct 3, 2025

GNU testsuite comparison:

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

@Misakait
Copy link
Contributor Author

Misakait commented Oct 3, 2025

Hi, the Tests/BusyBox test suite job failed due to a network error when downloading a dependency. I was looking for the "Re-run jobs" button to restart it myself, but I couldn't seem to find it.

Could a maintainer please help re-run the failed jobs? Thank you

@Misakait
Copy link
Contributor Author

Misakait commented Oct 3, 2025

Hi, the Tests/BusyBox test suite job failed due to a network error when downloading a dependency. I was looking for the "Re-run jobs" button to restart it myself, but I couldn't seem to find it.

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 BusyBox test suite check. It seems like a persistent infrastructure issue. I'll wait for the CI problem to be resolved. Let me know if there's anything I can do to help.

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.
@cakebaker cakebaker force-pushed the fix/ptx-tex-format-bug branch from 00b18ff to 48b5439 Compare October 3, 2025 08:55
Copy link

github-actions bot commented Oct 3, 2025

GNU testsuite comparison:

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

@cakebaker cakebaker merged commit cea3f22 into uutils:main Oct 3, 2025
96 of 97 checks passed
@cakebaker
Copy link
Contributor

Thanks!

@Misakait
Copy link
Contributor Author

Misakait commented Oct 3, 2025

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.

@cakebaker
Copy link
Contributor

git rebase is your friend to clean up the commit history. In this case it was a trivial git rebase main ;-)

@Misakait Misakait deleted the fix/ptx-tex-format-bug branch October 3, 2025 12:09
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.

2 participants

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载