awk: numbers are printed with full precision, OFMT and CONVFMT are ignored
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
研究方向
Start by tracing how numeric values are formatted for print and converted to strings during concatenation; the issue does not name implementation files, so locate those paths in the Rust source. Use the included print_uses_ofmt_and_concat_uses_convfmt test case as the first check, then compare behavior with the stated GNU awk reproduction. Done means print honors OFMT, other number-to-string conversions honor CONVFMT, and the shown test passes.
由索引模型根據 Issue 內容生成。
描述
Non-integer numbers are converted to strings with Rust's shortest round-trip
representation. POSIX awk uses OFMT (default %.6g) for print and
CONVFMT (default %.6g) for every other number-to-string conversion
(concatenation, array subscripts, ...). So print 1/3 gives
0.3333333333333333 instead of 0.333333, and array keys built from
non-integer numbers differ.
Reproduction
Rust (incorrect)
$ ./target/release/awk 'BEGIN { x = 1 / 3; print x; y = x ""; print y; OFMT = "%.2f"; print 3.14159 }'
0.3333333333333333
0.3333333333333333
3.14159
GNU (correct)
$ gawk 'BEGIN { x = 1 / 3; print x; y = x ""; print y; OFMT = "%.2f"; print 3.14159 }'
0.333333
0.333333
3.14
Test
#[test]
fn print_uses_ofmt_and_concat_uses_convfmt() {
ucmd()
.arg("BEGIN { v = 2 / 7; print v; print v \"\"; OFMT = \"%.3f\"; print v; print v \"\" }")
.succeeds()
.stdout_only("0.285714\n0.285714\n0.286\n0.285714\n");
}
Exposed by the GNU awk test suite: divzero2, getnr2tb, and many tests that
are now stopped earlier by printf.
- 主要語言
- Rust
- 星號
- 31
- 分支
- 13
- 平均合併
- 23 小時 42 分鐘
- 30 天內合併 PR
- 29
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
uutils/awk 的其他 Issue
-
bug gnu-compat good first issue
難度 2/5 1-3 小時 新手友好度 82/100
維護者通常 1 天內回覆
-
bug crash gnu-compat good first issue
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
bug gnu-compat good first issue
難度 2/5 1-3 小時 新手友好度 85/100
維護者通常 1 天內回覆
-
bug gnu-compat good first issue
難度 2/5 1-3 小時 新手友好度 82/100
維護者通常 1 天內回覆
-
awk: `-f missing-file` and `--source` panic可能已有人在做 @VanshajPoonia 於 4 天前認領。 未關閉bug crash gnu-compat good first issue
難度 2/5 1-3 小時 新手友好度 80/100
維護者通常 1 天內回覆
相似的 Issue
-
Ignore entry for RUSTSEC-2026-0002 no longer matches anything (`lru` is no longer in `Cargo.lock`)未關閉
難度 1/5 1 小時以內 新手友好度 72/100
influxdata/influxdb#27767 ·
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 78/100
shell-pool/shpool#463 ·
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 65/100
oras-project/rust-oci-client-node#132 ·
維護者通常 2 天內回覆
-
Ignore entry for RUSTSEC-2020-0168 no longer matches anything (`mach` is no longer in `Cargo.lock`)可能已有人在做 @zyl71 今天認領。 未關閉
難度 1/5 1 小時以內 新手友好度 72/100
Blockstream/lwk#213 ·
-
難度 2/5 1-3 小時 新手友好度 62/100
libracoder/kiri#749 ·
維護者通常 1 天內回覆