From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20529 invoked from network); 17 Sep 2000 16:15:47 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 17 Sep 2000 16:15:47 -0000 Received: (qmail 14264 invoked by alias); 17 Sep 2000 16:14:21 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 12822 Received: (qmail 14257 invoked from network); 17 Sep 2000 16:14:20 -0000 From: "Bart Schaefer" Message-Id: <1000917161356.ZM19396@candle.brasslantern.com> Date: Sun, 17 Sep 2000 16:13:56 +0000 In-Reply-To: <20000917110403.A4270@dman.com> Comments: In reply to Clint Adams "Re: PATCH: zasprintf" (Sep 17, 11:04am) References: <20000916145333.A29559@dman.com> <1000917004721.ZM18698@candle.brasslantern.com> <20000917002552.A31354@dman.com> <1000917053751.ZM18817@candle.brasslantern.com> <20000917110403.A4270@dman.com> X-Mailer: Z-Mail (5.0.0 30July97) To: Clint Adams Subject: Re: PATCH: zasprintf Cc: zsh-workers@sunsite.auc.dk MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Sep 17, 11:04am, Clint Adams wrote: } Subject: Re: PATCH: zasprintf } } > I don't believe there's any use zsh could make of asprintf() } > that isn't better solved another way. } } If by "better" you mean "avoiding asprintf and dealing with a specialized } case." I do, mostly because I don't think there are very many specialized cases. There are 96 uses of sprintf() in zsh, nearly all of them used to convert integers to strings (which hardly requires a dynamically allocated buffer). Several of the remaining ones are used for path concatenation. None have particularly complex format strings. I simply think that asprintf() is over-generalized. } > I don't have any such confidence that asprintf() would be cleaner or more } > efficient than, say, a realloc'ing version of tricat() } } Why, other than portability? For one thing, because it can't realloc(). That means that if you use it in a loop, you have to allocate and free the buffer every time around, even if you're always writing approximately the same size string. For another thing: } Speaking of the real tricat, this eliminates bin_dot's dependence on } PATH_MAX: This is a case where a zsh-heap-allocating version of tricat() would be slightly preferable to a permanent-heap-allocating version. -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net