unexpand: final newline prevents conversion of leading Unicode blanks
メンテナーはふだん 1 日以内に返信
評価
調査の方向性
src/uu/unexpand/src/unexpand.rsの512~523行付近にあるunexpand_bufの高速パスから始め、Unicodeの空白処理の前に、改行で終わる入力をどのように扱うか追ってください。issueのコマンドで再現し、デフォルトモードと-aを比較してください。デフォルトモードで先頭のU+3000文字が、最後の改行を伴うタブに変換され、関連するunexpandのテストが通れば完了です。
索引モデルが issue の本文から書いたものです。
説明
In a UTF-8 locale, unexpand leaves leading Unicode blanks unchanged when the line ends in a newline. Removing that newline makes the same blanks convert to a tab. GNU coreutils 9.12 converts them in both cases.
Reproduced on main c1f172886c6643f61ffde5a1ce3db0aaf14e182b on Linux, in both debug and release builds:
python3 -c 'print("\u3000" * 4 + "X")' |
LC_ALL=C.UTF-8 coreutils unexpand | od -An -tx1
The input is four U+3000 IDEOGRAPHIC SPACE characters (eight display columns), followed by X and a newline.
Expected, as printed by GNU unexpand 9.12:
09 58 0a
Actual:
e3 80 80 e3 80 80 e3 80 80 e3 80 80 58 0a
The same command with unexpand -a produces the expected tab. So does default unexpand if the final newline is omitted. --first-only has the same failure as default mode.
The first fast path in unexpand_buf (src/uu/unexpand/src/unexpand.rs:512-523) checks only for ASCII space and tab before copying a newline-terminated buffer unchanged. This bypasses the Unicode blank handling later in the function.
I compared 416 cases against GNU 9.12 across 13 Unicode blank characters, two UTF-8 locales, file/pipe input, with/without a final newline, and four option sets. Both uutils builds had the same 104 mismatches, all in default/--first-only mode with a final newline. All 44 existing unexpand integration tests pass.
- 主要言語
- Rust
- スター
- 24.3k
- フォーク
- 2.1k
- 平均マージ
- 1日 21時間
- マージ済み PR(30日)
- 357
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
uutils/coreutils のほかの issue
-
fmt: stops at an unreadable file operand and says only 'read error' for a directory対応中かも @emirmrkaljevic が 1 日前に担当しました。 オープンU - fmt
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
shuf: exhausted random source destroys the input during an in-place shuffle対応中かも @limadog9 が 1 日前に担当しました。 オープンU - shuf
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
paste: serial mode exhausts file descriptors by opening every input simultaneously対応中かも @binhvq が 1 日前に担当しました。 オープンU - paste
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
chmod -v: missing 'could not be accessed' line for operands that can't be stat'ed対応中かも @emirmrkaljevic が 2 日前に担当しました。 オープンU - chmod
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
chown, chgrp: 'cannot dereference' instead of 'cannot access' for a missing operand対応中かも @emirmrkaljevic が 2 日前に担当しました。 オープンU - chgrp U - chown
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信
uutils/coreutils の issue をすべて見る
似ている issue
-
desktop documentation
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
vfarcic/dot-agent-deck#2008 ·
メンテナーはふだん 1 日以内に返信
-
needs triage
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
pbakaus/impeccable#1210 ·
メンテナーはふだん 1 日以内に返信
-
enhancement ux-opportunities
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
area: ci priority: P4 ready-for-agent
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
shep-pm/shep#1249 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
`PartialEq` for `AssignedBigUint` treats different values as equal対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンstatus:untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
midnightntwrk/midnight-zk#600 ·
メンテナーはふだん 2 日以内に返信