Skip to content

ls: measure the rendered directory header for dired offsets - #14656

Open
ChihweiLHBird wants to merge 1 commit into
uutils:mainfrom
ChihweiLHBird:zhiwei/fix-ls-dired-header-offsets
Open

ChihweiLHBird wants to merge 1 commit into
uutils:mainfrom
ChihweiLHBird:zhiwei/fix-ls-dired-header-offsets

Conversation

@ChihweiLHBird

@ChihweiLHBird ChihweiLHBird commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Summary

--dired offsets must delimit the exact bytes written. write_dir_header measured directory headers by their raw path length, while show_dir_name prints them quoted according to the quoting style in force, so any quoting that lengthens a header (-Q, --quoting-style=shell-escape, a name with a space) cut its //SUBDIRED// entry short and shifted every later //DIRED// offset. show_dir_name now returns the rendered byte length and the bookkeeping uses that. Split out of #14590.

Example

mkdir 'a b' && touch 'a b/x'
ls --dired -R --quoting-style=shell-escape 'a b'

Before: the header is printed as 'a b' (5 bytes) but counted as a b (3 bytes), so //SUBDIRED// 2 5 covers 'a and //DIRED// 62 63 lands on the 0 of the size column instead of x.

  'a b':
  total 0
  -rw-r--r--+ 1 zhiwei zhiwei 0 Sep 17 19:20 x
//DIRED// 62 63
//SUBDIRED// 2 5
//DIRED-OPTIONS// --quoting-style=shell-escape-show-control

After: //SUBDIRED// 2 7 covers 'a b' and //DIRED// 64 65 covers x, the same offsets GNU prints.

  'a b':
  total 0
  -rw-r--r--+ 1 zhiwei zhiwei 0 Sep 17 19:20 x
//DIRED// 64 65
//SUBDIRED// 2 7
//DIRED-OPTIONS// --quoting-style=shell-escape-show-control

Signed-off-by: Zhiwei Liang <zhiwei.liang@zliang.me>
@ChihweiLHBird
ChihweiLHBird marked this pull request as ready for review September 17, 2026 19:13
@github-actions

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/tail/tail-n0f (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/date/date-locale-hour (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/expand/bounded-memory is now passing!
Note: The gnu test tests/env/env-signal-handler was skipped on 'main' but is now failing.

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.

1 participant