bin/126657: [patch] w(1) breaks multibyte date format

Johan van Selst johans at
Tue Aug 19 13:00:09 UTC 2008

>Number:         126657
>Category:       bin
>Synopsis:       [patch] w(1) breaks multibyte date format
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Aug 19 13:00:08 UTC 2008
>Originator:     Johan van Selst
>Release:        FreeBSD 6.3-STABLE i386
System: FreeBSD 6.3-STABLE FreeBSD 6.3-STABLE #0: Mon May 26 15:49:18 CEST 2008 root at i386


	w(1) uses strftime %b with to print the abbreviated month name
	if a user logged in more than a week ago.
	This may contain multibyte characters (e.g. when using UTF-8).
	This string is then aligned on byte-length rathern than char-length,
	resulting in misalignment and unfinished multibyte characters.


	If you have a user logged on for more than a week:
	$ env LANG=ru_RU.UTF-8 w


	replace printf by wprintf (to use character length):

--- w/pr_time.c	2008-08-19 14:14:03.000000000 +0200
+++ w/pr_time.c	2008-08-19 14:23:17.000000000 +0200
@@ -43,6 +43,7 @@
 #include <sys/time.h>
 #include <stdio.h>
+#include <wchar.h>
 #include <string.h>
 #include "extern.h"
@@ -82,7 +83,7 @@
 	(void)strftime(buf, sizeof(buf), fmt, &tp);
-	(void)printf("%-7.7s", buf);
+	(void)wprintf(L"%-7.7s", buf);


More information about the freebsd-bugs mailing list