Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm
Precedence: bulk
X-No-Archive: yes
List-Id: Zsh Workers List <zsh-workers.zsh.org>
List-Post: <mailto:zsh-workers@zsh.org>
List-Help: <mailto:zsh-workers-help@zsh.org>
X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_DKIM_INVALID
	autolearn=ham autolearn_force=no version=3.4.0
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=brasslantern-com.20150623.gappssmtp.com; s=20150623;
        h=from:message-id:date:in-reply-to:comments:references:to:subject
         :mime-version:content-type;
        bh=q0vhGDPEO4xUCejCPxtSI+Yy9WIuvwhpMrfQpF/YglE=;
        b=S/XZO3b7sx6t6YzlxLQJAZfgG1Ccg3uX9h+05ndYusV6myyDrKxqQpuoK5iG7KzOWg
         eCjtpMq3f6/ZwNJH1Iq78CXx+R2eZK+CnOZSlGj4hfA5Hr+OtHSZgFJWuV/dF4imVlsP
         caNpzDsI5x8VG4q4cVgZ/jcfN4vL2vqGECP+OgJspI155N4WeZM4B901VKNxUDwfRUIG
         VoNnu4HZert8/NzPf62li1mKxjtFpfi1Gyk9SHQ+h4F8rrTRtuyQVsHrLBaoAk8X6L9p
         Yar/N0RDOJXxO70YsFqBoYRoNwsXrpu64+7fzRQyR/KuNLWxQlbc/Y7s1AVaQMi2HXOW
         sBaw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:from:message-id:date:in-reply-to:comments
         :references:to:subject:mime-version:content-type;
        bh=q0vhGDPEO4xUCejCPxtSI+Yy9WIuvwhpMrfQpF/YglE=;
        b=TBin1iumN6TBpuB4okFRLdSUQ+Dt83XkxcFsoSAiMErFrBtRsrr0h045PkQGHxkmZi
         dmGpBlrxzePm4xHzjpf+q060a0arGUp455Qx0X6xtUMHkB0Oe+fAL+uWBUKBQOJENOyM
         SIAfL1H5/z37A71IqY9+zg6eYfpc7pCuzokrGHvOdzdSHG8Ra1DMM0T/R+mWSM7klXpi
         ggKM9NFah9SH2xLssctcKMDWe9TVtQclcAb6SWl2r62CzTt1YX0MTjEqyIKs0cD3d8wj
         0lY0XVZpDFhErhHZmQkKeKwSU0qrxqU22XSR8/6vxKafadRdteWGJY+4MnptXnwYf20D
         ih6g==
X-Gm-Message-State: ALoCoQl3wi1cvhKJiWxvKqlXi2tDFPSDDAgRIkkevYlHN09AY3E7+9Go14/AcdHN0svUMcUeL6VDu/6wwmsUDEesDf6UqxQU8A==
X-Received: by 10.98.17.149 with SMTP id 21mr93929284pfr.15.1451708240467;
        Fri, 01 Jan 2016 20:17:20 -0800 (PST)
From: Bart Schaefer <schaefer@brasslantern.com>
Message-Id: <160101201724.ZM1844@torch.brasslantern.com>
Date: Fri, 1 Jan 2016 20:17:24 -0800
In-Reply-To: <CAKc7PVDsXof4TFRvtY15qThTEPqLz6NiSeL6dsKxqGXyK2aVeg@mail.gmail.com>
Comments: In reply to Sebastian Gniazdowski <sgniazdowski@gmail.com>
        "Re: Printf builtin missing v flag support" (Jan  1, 11:12pm)
References: <068ca8f5-315b-444c-b281-5f183e1daa8c@email.android.com> 
	<151231104858.ZM24513@torch.brasslantern.com> 
	<CAKc7PVCXaicToQHdgaqnOmoqHjqQLxUXQSUrBx=fjs9JH2USKQ@mail.gmail.com> 
	<160101135224.ZM10746@torch.brasslantern.com> 
	<CAKc7PVDsXof4TFRvtY15qThTEPqLz6NiSeL6dsKxqGXyK2aVeg@mail.gmail.com>
X-Mailer: OpenZMail Classic (0.9.2 24April2005)
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: Printf builtin missing v flag support
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Seq: zsh-workers 37485

On Jan 1, 11:12pm, Sebastian Gniazdowski wrote:
} Subject: Re: Printf builtin missing v flag support
}
} On 1 January 2016 at 22:52, Bart Schaefer <schaefer@brasslantern.com> wrote:
} >
} > To make it work with -x, -X, -C, etc. would require moving the memstream
} > code to the top of the function, plus some related fiddling around later.
} 
} Could you implement that? The move of memstream code seems like a
} cleanup, print would have full control of whether do memstream or not.

I looked at it, but it's more messy than I thought, because the printf
branch keeps a running count of the number of bytes printed, which is
then needed for handling the result.  No sub-part of the print branch
maintains that byte count, so a lot of fiddly little changes are needed.

Also the print branch does some extra work to detect write errors on
redirection -- which it looks like might actually be buggy in the
-z/-s case when HAVE_OPEN_MEMSTREAM is not defined, and which have to
be rewritten for the -v case -- so this is not going to happen quickly.

