From archie@whistle.com  Wed Jan  5 17:16:23 2000
Return-Path: <archie@whistle.com>
Received: from bubba.whistle.com (bubba.whistle.com [207.76.205.7])
	by hub.freebsd.org (Postfix) with ESMTP id 3509015517
	for <FreeBSD-gnats-submit@freebsd.org>; Wed,  5 Jan 2000 17:16:08 -0800 (PST)
	(envelope-from archie@whistle.com)
Received: (from archie@localhost)
	by bubba.whistle.com (8.9.2/8.9.2) id RAA72721;
	Wed, 5 Jan 2000 17:14:14 -0800 (PST)
Message-Id: <200001060114.RAA72721@bubba.whistle.com>
Date: Wed, 5 Jan 2000 17:14:14 -0800 (PST)
From: Archie Cobbs <archie@whistle.com>
Reply-To: archie@whistle.com
To: FreeBSD-gnats-submit@freebsd.org
Subject: printf(1) truncates if it sees 000
X-Send-Pr-Version: 3.2

>Number:         15929
>Category:       docs
>Synopsis:       printf(1) truncates if it sees \000
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-doc
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jan  5 17:20:00 PST 2000
>Closed-Date:    Tue Jan 18 20:17:00 PST 2000
>Last-Modified:  Tue Jan 18 20:18:38 PST 2000
>Originator:     Archie Cobbs
>Release:        FreeBSD 3.4-RELEASE i386
>Organization:
Whistle Communications, Inc.
>Environment:

	FreeBSD 3.4-RELEASE i386

>Description:

	If '\000' is used in a printf(1) format string, the
	string is trunctated at that point

>How-To-Repeat:

	$ printf 'a\000truncated\n'

	This outputs "a" instead of "a<NUL>truncated"

>Fix:
	


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-alpha->freebsd-bugs 
Responsible-Changed-By: archie 
Responsible-Changed-When: Wed Jan 5 17:32:35 PST 2000 
Responsible-Changed-Why:  
Category should be 'bin' instead of 'alpha'. 

From: Steve Price <sprice@hiwaay.net>
To: Archie Cobbs <archie@whistle.com>
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: alpha/15929: printf(1) truncates if it sees 000
Date: Wed, 5 Jan 2000 19:36:15 -0600 (CST)

 On Wed, 5 Jan 2000, Archie Cobbs wrote:
 
 # >Number:         15929
 # >Category:       alpha
 # >Synopsis:       printf(1) truncates if it sees \000
 # >Description:
 # 
 # 	If '\000' is used in a printf(1) format string, the
 # 	string is trunctated at that point
 # 
 # >How-To-Repeat:
 # 
 # 	$ printf 'a\000truncated\n'
 # 
 # 	This outputs "a" instead of "a<NUL>truncated"
 
 This really isn't an Alpha-specific problem is it?  I just
 tried it on both i386 and Alpha boxes, and I get the similar
 results depending on the shell I use.  None I tried give
 the behavior you suggest.  Which shell were you using and
 what does 'which printf' say?
 
 Thanks.
 
 -steve
 
 
 

From: Sheldon Hearn <sheldonh@uunet.co.za>
To: archie@whistle.com
Cc: FreeBSD-gnats-submit@freebsd.org
Subject: Re: bin/15929: printf(1) truncates if it sees 000 
Date: Thu, 06 Jan 2000 17:43:39 +0200

 On Wed, 05 Jan 2000 17:14:14 PST, Archie Cobbs wrote:
 
 > 	$ printf 'a\000truncated\n'
 > 
 > 	This outputs "a" instead of "a<NUL>truncated"
 
 What would you expect to happen, given that printf(3) exhibits the same
 behaviour?
 
 Ciao,
 Sheldon.
 

From: Archie Cobbs <archie@whistle.com>
To: sheldonh@uunet.co.za (Sheldon Hearn)
Cc: archie@whistle.com, FreeBSD-gnats-submit@freebsd.org
Subject: Re: bin/15929: printf(1) truncates if it sees 000
Date: Thu, 6 Jan 2000 09:33:49 -0800 (PST)

 Sheldon Hearn writes:
 > > 	$ printf 'a\000truncated\n'
 > > 
 > > 	This outputs "a" instead of "a<NUL>truncated"
 > 
 > What would you expect to happen, given that printf(3) exhibits the same
 > behaviour?
 
 No, I'm not at all surprised.
 
 But that's not the point, of course.  Either the bug should be fixed
 or else at least declared 'normal' and so documented in the man page.
 
 -Archie
 
 ___________________________________________________________________________
 Archie Cobbs   *   Whistle Communications, Inc.  *   http://www.whistle.com
 

From: Sheldon Hearn <sheldonh@uunet.co.za>
To: Archie Cobbs <archie@whistle.com>
Cc: FreeBSD-gnats-submit@freebsd.org
Subject: Re: bin/15929: printf(1) truncates if it sees 000 
Date: Fri, 07 Jan 2000 09:08:33 +0200

 On Thu, 06 Jan 2000 09:33:49 PST, Archie Cobbs wrote:
 
 > But that's not the point, of course.  Either the bug should be fixed
 > or else at least declared 'normal' and so documented in the man page.
 
 That's the bit I'm after.  What's the bug?  From printf(3):
 
      These functions return the number of characters printed (not including
      the trailing `\0' used to end output to strings).
 
 Presumably, you want some indication in the printf(1) manual page that a
 null character in the string terminates it?  Or is there something else
 you think we can do?
 
 Ciao,
 Sheldon.
 

From: Archie Cobbs <archie@whistle.com>
To: sheldonh@uunet.co.za (Sheldon Hearn)
Cc: FreeBSD-gnats-submit@freebsd.org, bde@whistle.com
Subject: Re: bin/15929: printf(1) truncates if it sees 000
Date: Fri, 7 Jan 2000 11:28:27 -0800 (PST)

 Sheldon Hearn writes:
 > > But that's not the point, of course.  Either the bug should be fixed
 > > or else at least declared 'normal' and so documented in the man page.
 > 
 > That's the bit I'm after.  What's the bug?  From printf(3):
 > 
 >      These functions return the number of characters printed (not including
 >      the trailing `\0' used to end output to strings).
 > 
 > Presumably, you want some indication in the printf(1) manual page that a
 > null character in the string terminates it?  Or is there something else
 > you think we can do?
 
 Yes, that would be good enough.  All I'm saying is that the behavior
 doesn't match what the man page says.  If you forget printf(3),
 POSIX, etc. and just read the man page, there's nothing in it
 that says that \000 is in any way special, yet in functionality
 it is.
 
 A simple note in the BUGS section (or wherever) would be just fine
 with me.
 
 -Archie
 
 ___________________________________________________________________________
 Archie Cobbs   *   Whistle Communications, Inc.  *   http://www.whistle.com
 

From: Daniel Hagan <dhagan@cs.vt.edu>
To: freebsd-gnats-submit@freebsd.org
Cc: archie@whistle.com
Subject: bin/15929 [patch] clarify manpage for printf(1)
Date: Tue, 18 Jan 2000 11:50:12 -0500 (EST)

 Does this adequately explain it?
 
 -Daniel
 
 Index: printf.1
 ===================================================================
 RCS file: /src/cvs/src/usr.bin/printf/printf.1,v
 retrieving revision 1.7
 diff -c -r1.7 printf.1
 *** printf.1	1999/09/14 11:46:03	1.7
 --- printf.1	2000/01/18 16:36:39
 ***************
 *** 281,283 ****
 --- 281,289 ----
   .Pp
   .Tn ANSI
   hexadecimal character constants were deliberately not provided.
 + .Pp
 + The escape sequence \e000 is the string terminator.  When present in the
 + .Ar format  ,
 + the 
 + .Ar format
 + will be truncated at the \e000 character.
 
 
 
 
 -- 
 Daniel Hagan                                             Computer Science CSE
 dhagan@cs.vt.edu                                http://www.cs.vt.edu/~dhagan/
 
 

From: Archie Cobbs <archie@whistle.com>
To: dhagan@cs.vt.edu (Daniel Hagan)
Cc: freebsd-gnats-submit@freebsd.org
Subject: Re: bin/15929 [patch] clarify manpage for printf(1)
Date: Tue, 18 Jan 2000 11:26:54 -0800 (PST)

 Daniel Hagan writes:
 > Does this adequately explain it?
 
 Looks great, thanks. .. but why "\e000" and not "\000" ?
 
 > + .Pp
 > + The escape sequence \e000 is the string terminator.  When present in the
 > + .Ar format  ,
 > + the 
 > + .Ar format
 > + will be truncated at the \e000 character.
 
 -Archie
 
 ___________________________________________________________________________
 Archie Cobbs   *   Whistle Communications, Inc.  *   http://www.whistle.com
 

From: Daniel Hagan <dhagan@cs.vt.edu>
To: Archie Cobbs <archie@whistle.com>
Cc: freebsd-gnats-submit@freebsd.org
Subject: Re: bin/15929 [patch] clarify manpage for printf(1)
Date: Tue, 18 Jan 2000 14:30:59 -0500 (EST)

 On Tue, 18 Jan 2000, Archie Cobbs wrote:
 
 > Looks great, thanks. .. but why "\e000" and not "\000" ?
 
 Well, I'm not familiar with man-page source formats (Troff?), but that's
 what it appears to take to make a \000 appear in the output.  For
 reference, refer to lines 90-106 where the ANSI escape sequences are
 listed.  \000 resulted in \00 when I tried it.
 
 Daniel
 
 -- 
 Daniel Hagan                                             Computer Science CSE
 dhagan@cs.vt.edu                                http://www.cs.vt.edu/~dhagan/
 
 

From: Archie Cobbs <archie@whistle.com>
To: dhagan@cs.vt.edu (Daniel Hagan)
Cc: archie@whistle.com (Archie Cobbs),
	freebsd-gnats-submit@freebsd.org
Subject: Re: bin/15929 [patch] clarify manpage for printf(1)
Date: Tue, 18 Jan 2000 13:01:05 -0800 (PST)

 Daniel Hagan writes:
 > > Looks great, thanks. .. but why "\e000" and not "\000" ?
 > 
 > Well, I'm not familiar with man-page source formats (Troff?), but that's
 > what it appears to take to make a \000 appear in the output.  For
 > reference, refer to lines 90-106 where the ANSI escape sequences are
 > listed.  \000 resulted in \00 when I tried it.
 
 Ah, of course..  my ignorance :-)
 
 -Archie
 
 ___________________________________________________________________________
 Archie Cobbs   *   Whistle Communications, Inc.  *   http://www.whistle.com
 
Responsible-Changed-From-To: freebsd-bugs->freebsd-doc 
Responsible-Changed-By: asmodai 
Responsible-Changed-When: Tue Jan 18 13:47:55 PST 2000 
Responsible-Changed-Why:  
Patch for -doc.  This way we will not loose track of it. 
State-Changed-From-To: open->closed 
State-Changed-By: chris 
State-Changed-When: Tue Jan 18 20:17:00 PST 2000 
State-Changed-Why:  
Daniel Hagan <dhagan@cs.vt.edu>'s patch was committed. 
>Unformatted:
