Date: Thu, 19 Jun 2003 02:45:05 +0800 (CST) From: Kuang-che Wu <kcwu@kcwu.homeip.net> To: FreeBSD-gnats-submit@FreeBSD.org Subject: docs/53454: wrong sample code in manpage of wcwidth(3) Message-ID: <200306181845.h5IIj5ZA004058@kcwu.homeip.net> Resent-Message-ID: <200306181850.h5IIoGMi057204@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 53454 >Category: docs >Synopsis: wrong sample code in manpage of wcwidth(3) >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-doc >State: open >Quarter: >Keywords: >Date-Required: >Class: doc-bug >Submitter-Id: current-users >Arrival-Date: Wed Jun 18 11:50:15 PDT 2003 >Closed-Date: >Last-Modified: >Originator: Kuang-che Wu >Release: FreeBSD 5.1-BETA i386 >Organization: >Environment: System: FreeBSD kcwu.homeip.net 5.1-BETA FreeBSD 5.1-BETA #2: Wed May 7 16:00:34 CST 2003 root@kcwu.homeip.net:/files/usr.obj/usr/src/sys/DESKTOP i386 >Description: The sample code produces 19 column positions wide in first line, and 20 in rest lines. >How-To-Repeat: $ echo 123456789012345678901234567890123456789012345678901234567890 | ./w 1234567890123456789 01234567890123456789 01234567890123456789 0 >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. >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200306181845.h5IIj5ZA004058>