Bug 53454

Summary: wrong sample code in manpage of wcwidth(3)
Product: Documentation Reporter: Kuang-che Wu <kcwu>
Component: Books & ArticlesAssignee: Tom Rhodes <trhodes>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Latest   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
wcwidth.3-patch none

Description Kuang-che Wu 2003-06-18 19:50:15 UTC
	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
Comment 1 Marc Silver 2004-02-03 13:34:28 UTC
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
Comment 2 Tom Rhodes freebsd_committer freebsd_triage 2004-02-05 17:45:43 UTC
Responsible Changed
From-To: freebsd-doc->trhodes

Take this PR.
Comment 3 Tom Rhodes freebsd_committer freebsd_triage 2004-08-17 08:07:03 UTC
State Changed
From-To: open->closed

Surprise surprise, tjr fixed this already.