Date: Sat, 18 Nov 2000 21:22:50 +0200 From: "Eli Zaretskii" Sender: halo1 AT zahav DOT net DOT il To: dj AT delorie DOT com Message-Id: <2593-Sat18Nov2000212249+0200-eliz@is.elta.co.il> X-Mailer: Emacs 20.6 (via feedmail 8.3.emacs20_6 I) and Blat ver 1.8.6 CC: djgpp-workers AT delorie DOT com In-reply-to: <200011181820.NAA03922@envy.delorie.com> (message from DJ Delorie on Sat, 18 Nov 2000 13:20:11 -0500) Subject: Re: snprintf() diff References: <200011132023 DOT PAA04930 AT qnx DOT com> <3A1328A7 DOT C9866232 AT bigfoot DOT com> <200011160105 DOT UAA01282 AT envy DOT delorie DOT com> <3A15C4B1 DOT 383439DB AT bigfoot DOT com> <200011180030 DOT TAA26797 AT envy DOT delorie DOT com> <9743-Sat18Nov2000101225+0200-eliz AT is DOT elta DOT co DOT il> <200011181820 DOT NAA03922 AT envy DOT delorie DOT com> Reply-To: djgpp-workers AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp-workers AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk > Date: Sat, 18 Nov 2000 13:20:11 -0500 > > > Not if we want to keep the existing behavior of putc, which only > > returns EOF when the whole call should fail. > > If you're trying to call putc on a string and there's no space left in > the string, yes, the putc call should fail. You are out of space. But that would conflict with how snprintf should work: it should NOT fail if it runs out of space. Instead, it needs to stop writing into the (full) buffer, but should still count characters _produced by doprnt, because it needs to return the number of characters that _would_ have been written had the buffer been large enough. The easiest way to do that is to hide the fact that the buffer overflowed from _doprnt, and let it keep going.