From owner-svn-src-all@FreeBSD.ORG Sat May 28 14:32:47 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 88D48106564A; Sat, 28 May 2011 14:32:47 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5FB208FC13; Sat, 28 May 2011 14:32:47 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p4SEWlUW088133; Sat, 28 May 2011 14:32:47 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p4SEWlNl088131; Sat, 28 May 2011 14:32:47 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <201105281432.p4SEWlNl088131@svn.freebsd.org> From: Jilles Tjoelker Date: Sat, 28 May 2011 14:32:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r222421 - head/usr.bin/printf X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 May 2011 14:32:47 -0000 Author: jilles Date: Sat May 28 14:32:47 2011 New Revision: 222421 URL: http://svn.freebsd.org/changeset/base/222421 Log: printf(1): Document that %c and precision for %b/%s use bytes, not chars. This means these features do not work as expected with multibyte characters. This perhaps less than ideal behaviour matches printf(3) and is specified by POSIX. Modified: head/usr.bin/printf/printf.1 Modified: head/usr.bin/printf/printf.1 ============================================================================== --- head/usr.bin/printf/printf.1 Sat May 28 13:54:19 2011 (r222420) +++ head/usr.bin/printf/printf.1 Sat May 28 14:32:47 2011 (r222421) @@ -171,7 +171,7 @@ A `\-' overrides a `0' if both are used; .It "Field Width:" An optional digit string specifying a .Em field width ; -if the output string has fewer characters than the field width it will +if the output string has fewer bytes than the field width it will be blank-padded on the left (or right, if the left-adjustment indicator has been given) to make up the field width (note that a leading zero is a flag, but an embedded zero is part of a field width); @@ -185,7 +185,7 @@ for .Cm e and .Cm f -formats, or the maximum number of characters to be printed +formats, or the maximum number of bytes to be printed from a string; if the digit string is missing, the precision is treated as zero; .It Format: @@ -271,15 +271,15 @@ and .Ql nan , respectively. .It Cm c -The first character of +The first byte of .Ar argument is printed. .It Cm s -Characters from the string +Bytes from the string .Ar argument -are printed until the end is reached or until the number of characters +are printed until the end is reached or until the number of bytes indicated by the precision specification is reached; however if the -precision is 0 or missing, all characters in the string are printed. +precision is 0 or missing, the string is printed entirely. .It Cm b As for .Cm s , @@ -346,6 +346,17 @@ to interpret the dash as a program argum .Nm -- must be used before .Ar format . +.Pp +If the locale contains multibyte characters +(such as UTF-8), +the +.Cm c +format and +.Cm b +and +.Cm s +formats with a precision +may not operate as expected. .Sh BUGS Since the floating point numbers are translated from .Tn ASCII