From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13756 invoked from network); 17 Sep 2000 05:39:52 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 17 Sep 2000 05:39:52 -0000 Received: (qmail 18400 invoked by alias); 17 Sep 2000 05:38:59 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 12819 Received: (qmail 18392 invoked from network); 17 Sep 2000 05:38:54 -0000 From: "Bart Schaefer" Message-Id: <1000917053751.ZM18817@candle.brasslantern.com> Date: Sun, 17 Sep 2000 05:37:50 +0000 In-Reply-To: <20000917002552.A31354@dman.com> Comments: In reply to Clint Adams "Re: PATCH: zasprintf" (Sep 17, 12:25am) References: <20000916145333.A29559@dman.com> <1000917004721.ZM18698@candle.brasslantern.com> <20000917002552.A31354@dman.com> X-Mailer: Z-Mail (5.0.0 30July97) To: zsh-workers@sunsite.auc.dk Subject: Re: PATCH: zasprintf MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Sep 17, 12:25am, Clint Adams wrote: } Subject: Re: PATCH: zasprintf } } > This seems to me to be the wrong way to approach this issue. If you } > can't provide a non-broken implementation -- and I don't see how you } > can, if you don't plan to implement a printf-format-string parser -- } } I don't think it's impossible to provide a non-broken implementation; I don't think it's impossible either, but the only way to "provide a compatibility function for vsnprintf()" is to implement a parser for printf format-strings. There simply is no way to fake it if you don't have it. I don't believe there's any use zsh could make of asprintf() that isn't better solved another way. In particular: } > 3) Pasting a string obtained from readdir() onto a known path prefix. } > In this case, it would be sufficient to use NAME_MAX + strlen() } > (and use pathconf() to get NAME_MAX if necessary). } } I'm uncomfortable with this after the other pathconf episode, especially } since pathconf() might return -1 for NAME_MAX, and then we've got } to deal with that by either arbitrarily setting a value or by dynamically } resizing, whereas I presume asprintf() would be cleaner and more } efficient. I don't have any such confidence that asprintf() would be cleaner or more efficient than, say, a realloc'ing version of tricat() that takes a char** to an allocated string as its first parameter. As for pathconf() ... as far as I can tell NAME_MAX has none of the odd problems associated with PATH_MAX. It doesn't, for example, potentially vary from call to call within the same directory. The only tricky bit is dealing with -1, which brings us back to the realloc'ing tricat(). -- 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