Skip to content

df: fix column width for non-ASCII headers - #15247

Merged
sylvestre merged 1 commit into
uutils:mainfrom
Hekzory:df-header-width
Oct 11, 2026
Merged

sylvestre merged 1 commit into
uutils:mainfrom
Hekzory:df-header-width

Conversation

@Hekzory

@Hekzory Hekzory commented Oct 11, 2026

Copy link
Copy Markdown
Contributor

Closes #15246.

Table::new started each column at the header's length in bytes, while cells, the header row included, are measured in display columns. So a non-ASCII header made its column one space wider per extra byte. The header row already goes through the loop that widens columns for long values, so I dropped the byte-length start value and let that loop size it.

The new test runs df -h --output=used,target . with LANG=fr_FR.UTF-8 and checks that the header line is Utilisé Monté sur. On main it is Utilisé Monté sur. With a local Russian ru-RU.ftl, df -h goes from 96 to 59 columns. Output with ASCII headers doesn't change.

Table::new seeded each column width with the header's length in bytes,
while every cell, the header row included, is measured in display
columns. A non-ASCII header therefore widened its column by one space
per extra byte: with LANG=fr_FR.UTF-8, "Utilisé" gets 8 columns instead
of 7, Cyrillic headers come out twice as wide as they should, CJK ones
one and a half times.

The header row already goes through the same width loop as the data
rows, so drop the byte-length seed and let that loop size it.

Closes #15246.
@sylvestre
sylvestre merged commit e6eb5ad into uutils:main Oct 11, 2026
99 checks passed
@sylvestre

Copy link
Copy Markdown
Contributor

Thanks for your PR

@Hekzory
Hekzory deleted the df-header-width branch October 11, 2026 22:20
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.

df: columns with non-ASCII headers are too wide

2 participants