From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16301 invoked from network); 8 Aug 2005 23:09:17 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 8 Aug 2005 23:09:17 -0000 Received: (qmail 79477 invoked from network); 8 Aug 2005 23:09:11 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 8 Aug 2005 23:09:11 -0000 Received: (qmail 18388 invoked by alias); 8 Aug 2005 23:09:09 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 21584 Received: (qmail 18379 invoked from network); 8 Aug 2005 23:09:08 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 8 Aug 2005 23:09:08 -0000 Received: (qmail 79172 invoked from network); 8 Aug 2005 23:09:08 -0000 Received: from dsl3-63-249-88-2.cruzio.com (HELO dot.blorf.net) (63.249.88.2) by a.mx.sunsite.dk with SMTP; 8 Aug 2005 23:09:04 -0000 Received: by dot.blorf.net (Postfix, from userid 1000) id E0E30949; Mon, 8 Aug 2005 16:09:02 -0700 (PDT) Date: Mon, 8 Aug 2005 16:09:02 -0700 From: Wayne Davison To: Thorsten Dahlheimer Cc: zsh-workers@sunsite.dk Subject: Re: PATCH: Slightly improve printf %s Message-ID: <20050808230902.GC2986@blorf.net> References: <024501c59c46$2ae19dc0$cc74fea9@pcdahl4201> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <024501c59c46$2ae19dc0$cc74fea9@pcdahl4201> User-Agent: Mutt/1.5.9i X-Spam-Checker-Version: SpamAssassin 3.0.4 (2005-06-05) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.0.4 On Mon, Aug 08, 2005 at 08:21:28PM +0200, Thorsten Dahlheimer wrote: > After I made this change, the test suite uncovered a bug (which I > introduced) in the handling of %b (and now %s) when no argument is > left, so the patch includes a fix for that, too. I didn't see that fix in the patch. I assume you're talking about this line (which is executed when the arg is missing): count += fprintf(fout, "%*c", width, ' '); ... since that would output a single space, even when "width" is 0. I changed the "else" that is in front of that line to "else if (width)", and it fixes the problem (I could have also changed the line to use fprintf(fout, "%*s", width, ""), but the former seems a litle more optimal). As for the change to how %s is handled, can you show me an example where this is needed? In my simple tests, if a variable has a literal null in it, using either %b or %s to print it out with printf truncates the variable at the null (and, of course, a backslash-zero can be passed to %b to get a real null, but %s doesn't evaluate backslashes). ..wayne..