| Summary: | wrong sample code in manpage of wcwidth(3) | ||||||
|---|---|---|---|---|---|---|---|
| Product: | Documentation | Reporter: | Kuang-che Wu <kcwu> | ||||
| Component: | Books & Articles | Assignee: | Tom Rhodes <trhodes> | ||||
| Status: | Closed FIXED | ||||||
| Severity: | Affects Only Me | ||||||
| Priority: | Normal | ||||||
| Version: | Latest | ||||||
| Hardware: | Any | ||||||
| OS: | Any | ||||||
| Attachments: |
|
||||||
Hi, I've tested the aforementioned patch, and it correctly outputs information now. Perhaps someone could commit it? Diff attached. Cheers, Marc -- Success is never final. Failure is never fatal. It is courage that counts. -- Winston Churchill Responsible Changed From-To: freebsd-doc->trhodes Take this PR. State Changed From-To: open->closed Surprise surprise, tjr fixed this already. |
The sample code produces 19 column positions wide in first line, and 20 in rest lines. Fix: while ((ch = getwchar()) != WEOF) { if ((w = wcwidth(ch)) > 0) column += w; - if (column >= 20) { + if (column > 20) { putwchar(L'\n'); - column = 0; + column = w; } putwchar(ch); if (ch == L'\n') column = 0; } Maybe you would like to fix it some other way. How-To-Repeat: $ echo 123456789012345678901234567890123456789012345678901234567890 | ./w 1234567890123456789 01234567890123456789 01234567890123456789 0