Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

unexpand: final newline prevents conversion of leading Unicode blanks

已关闭 适合新手
#15,898 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

已经有一个关联 PR 被合并了。

  • #15925 来自 @Ybucaille —— 已合并

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
86/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
rust
领域
cli

调研方向

从src/uu/unexpand/src/unexpand.rs中unexpand_buf的快速路径(约第512–523行)开始,追踪它在处理 Unicode 空白之前如何处理以换行符结尾的输入。使用 issue 中的命令复现,并比较默认模式与-a;当默认模式将开头的 U+3000 字符转换为一个制表符并保留末尾换行符,且相关的 unexpand 测试通过时,即为完成。

由索引模型根据 Issue 内容生成。

描述

U - unexpand

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 小时
30 天内合并 PR
360

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

uutils/coreutils 的其他 Issue

查看 uutils/coreutils 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。