Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 7 Jan 2000 19:00:59 +1100 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        Archie Cobbs <archie@whistle.com>
Cc:        freebsd-bugs@FreeBSD.ORG
Subject:   Re: bin/15929: printf(1) truncates if it sees 000
Message-ID:  <Pine.BSF.4.10.10001071850410.5889-100000@alphplex.bde.org>
In-Reply-To: <200001061740.JAA81806@freefall.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 6 Jan 2000, Archie Cobbs wrote:

>  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.

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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.10.10001071850410.5889-100000>