From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12736 invoked from network); 9 Nov 2001 17:52:22 -0000 Received: from ns2.primenet.com.au (HELO primenet.com.au) (?ccxve8Eu3+cPdsS5sEYHRXBw+GzUz48Y?@203.24.36.3) by ns1.primenet.com.au with SMTP; 9 Nov 2001 17:52:22 -0000 Received: (qmail 1609 invoked from network); 9 Nov 2001 17:52:20 -0000 Received: from sunsite.dk (130.225.247.90) by proxy.melb.primenet.com.au with SMTP; 9 Nov 2001 17:52:20 -0000 Received: (qmail 10940 invoked by alias); 9 Nov 2001 17:52:13 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 16230 Received: (qmail 10928 invoked from network); 9 Nov 2001 17:52:12 -0000 X-VirusChecked: Checked X-Authentication-Warning: iris.logica.co.uk: Host kiddleo@rambo.logica.co.uk [158.234.33.58] claimed to be yahoo.co.uk Sender: kiddleo@iris.logica.co.uk Message-ID: <3BEC17AF.57E611FF@yahoo.co.uk> Date: Fri, 09 Nov 2001 17:51:43 +0000 From: Oliver Kiddle X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.2.15 i686) X-Accept-Language: en MIME-Version: 1.0 To: zsh-workers@sunsite.dk Subject: Re: printf again References: <3BEC04E4.91BE18D1@yahoo.co.uk> <1011109172426.ZM15726@candle.brasslantern.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Bart Schaefer wrote: > > On Nov 9, 4:31pm, Oliver Kiddle wrote: > } > } It is doing my head in to try to work out how to do the memory > } management for using sprintf so that print -f can work with -s/-z. > } Formats like `%#010000000x' don't make it easy. > > Not surprising. You basically have to emulate the action of the printf > implementation. This is why some C libraries have snprintf() which will > return the length of the result without actually doing the print. > > I suggest you punt: Just fprintf() to a temp file and then read it back. > If you wanted to get really fancy you could memory-map the file where > that is supported. Good, thanks, that'll be a lot easier. I thought about mmap() mainly because I was trying to think of a way to ensure that the OS didn't bother touching the actual disc to write a file unless it was large. Would it be worth using any of the setbuf() calls - I've never used them before but they look like they may do that job. Or should I just rely on the filesystem code having some intelligence? I may also try out open_memstream where it is available because it is fairly much perfect for the job. Oliver _____________________________________________________________________ This message has been checked for all known viruses by the MessageLabs Virus Scanning Service. For further information visit http://www.messagelabs.com/stats.asp