From owner-freebsd-bugs Fri Jan 7 0: 1:20 2000 Delivered-To: freebsd-bugs@freebsd.org Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by hub.freebsd.org (Postfix) with ESMTP id 9A3A2155D9 for ; Fri, 7 Jan 2000 00:01:10 -0800 (PST) (envelope-from bde@zeta.org.au) Received: from bde.zeta.org.au (beefcake.zeta.org.au [203.26.10.12]) by mailman.zeta.org.au (8.8.7/8.8.7) with ESMTP id TAA08573; Fri, 7 Jan 2000 19:01:01 +1100 Date: Fri, 7 Jan 2000 19:00:59 +1100 (EST) From: Bruce Evans X-Sender: bde@alphplex.bde.org To: Archie Cobbs Cc: freebsd-bugs@FreeBSD.ORG Subject: Re: bin/15929: printf(1) truncates if it sees 000 In-Reply-To: <200001061740.JAA81806@freefall.freebsd.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org On Thu, 6 Jan 2000, Archie Cobbs wrote: > Sheldon Hearn writes: > > > $ printf 'a\000truncated\n' > > > > > > This outputs "a" instead of "atruncated" > > > > 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. printf(1) does seem to be incompatible with printf(3) here. From a POSIX draft: (3) In addition to the escape sequences shown in Table 2-15 (see 2.12), \ddd, where ddd is a one-, two-, or three-digit octal number, shall be written as a byte with the numeric value specified by the octal number. converted string shall be written. There seems to be no special case for the escape sequence \000. I think this is a bug in the POSIX draft. In C, printf(3) would never see the escape sequence \000; it would see a hard \0. You would have to use %c format to print a hard \0. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message